我需要将 systemd 服务安装到我自己的映像中,但它失败并出现以下错误:
*ERROR: hellosystemd-1.00-r0 do_package: Didn't find service unit 'hello.service', specified in SYSTEMD_SERVICE:hellosystemd.
ERROR: Logfile of failure stored in: /home/milaap/WORKSPACE/yocto-kirkstone/build-qemux86-64/tmp/work/core2-64-poky-linux/hellosystemd/1.00-r0/temp/log.do_package.1304921
ERROR: Task (/home/milaap/WORKSPACE/yocto-kirkstone/layers/meta-test/recipes-example/systemd/hellosystemd_1.00.bb:do_package) failed with exit code '1'*
我已经配置了所需的所有 DISTRO_FEATURES。但是,无法解决。 找到以下代码:
本地.conf
# set machine
MACHINE = "qemux86-64"
# enable some features for the distro
DISTRO_FEATURES:append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
INIT_MANAGER = "systemd"
VIRTUAL-RUNTIME:init_manager = "systemd"
VIRTUAL-RUNTIME:initscripts = ""
hellosystemd.bb
SUMMARY = "Systemd Example Recipe"
DESCRIPTION = "Run hellosystemd script"
LICENSE = "CLOSED"
SRC_URI = "file://hello.service"
DEPENDS += "systemd"
RDEPENDS:${PN} += "systemd"
S = "${WORKDIR}"
inherit pkgconfig systemd
SYSTEMD_AUTO_ENABLE = "enable"
SYSTEMD_SERVICE:${PN} = " hello.service"
FILES:${PN} += "/system/hello.service"
hello.service 被复制到以下位置:
./tmp/work/core2-64-poky-linux/systemd/1_250.5-r0/git/test/units/hello.service
./tmp/work/core2-64-poky-linux/hellosystemd/1.00-r0/hello.service
请提供解决方案。
我看到一个主要问题,您没有在
do_install
任务中安装该文件。
do_install() {
install -d ${D}/${systemd_system_unitdir}
install -m 0644 ${S}/hello.service ${D}/${systemd_system_unitdir}/
}
你的
FILES:{PN}
需要进行相应的设置(设置目录就足够了):
FILES:${PN} += "${systemd_system_unitdir}"
还有两点备注:
你最终的食谱应该是这样的:
SUMMARY = "Systemd Example Recipe"
DESCRIPTION = "Run hellosystemd script"
LICENSE = "CLOSED"
SRC_URI = "file://hello.service"
S = "${WORKDIR}"
inherit systemd
SYSTEMD_SERVICE:${PN} = " hello.service"
do_install() {
install -d ${D}/${systemd_system_unitdir}
install -m 0644 ${S}/hello.service ${D}/${systemd_system_unitdir}/
}
FILES:${PN} += "${systemd_system_unitdir}"