【发布时间】:2022-01-21 17:44:38
【问题描述】:
我正在尝试在启动时启动服务,但是我在构建时遇到了问题。 这是我的自定义层中的树结构
michael@michael-VirtualBox:~/Documents/simple_daemon/sources/meta-simpledaemon$ tree
.
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
├── example
│ └── example_0.1.bb
└── simpledaemon
├── files
│ └── simpledaemon.service
└── simpledaemon_git.bb
在我的 local.conf 中,我在末尾添加了以下内容:
IMAGE_INSTALL_append = " bbexample "
IMAGE_INSTALL_append = " simpledaemon "
IMAGE_INSTALL_append = " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append = " openssh-sftp-server "
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED = "sysvinit"
VIRTUAL-RUNTIME_initscripts = ""
我的.bb文件如下:
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ca119cf6dcda0f0883a416a3e7f94cc2"
SRC_URI = "git://github.com/MichaelBMiner/simpledaemon;protocol=https"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "a37a89df4d53bca97c12c8908cbe8552032417b4"
inherit systemd
S = "${WORKDIR}/git"
SYSTEMD_SERVICE_${PN} = "simpledaemon.service"
do_compile () {
${CC} ${LDFLAGS} simpledaemon.c -o simpledaemon
}
do_install () {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/simpledaemon ${D}${bindir}
install -d ${D}${systemd_unitdir}/system
install -m 0644 ${WORKDIR}/simpledaemon.service ${D}${systemd_unitdir}/system sed -i -e 's,@BINDIR@,${bindir},g' ${D}${systemd_unitdir}/system/simpledaemon.service
}
# NOTE: if this software is not capable of being built in a separate build directory
# from the source, you should replace autotools with autotools-brokensep in the
# inherit line
inherit autotools
# Specify any options you want to pass to the configure script using EXTRA_OECONF:
EXTRA_OECONF = ""
我的simpledaemon.service如下:
[Unit]
Description=Example service
[Service]
Type=forking
ExecStart=@BINDIR@/simple-service
[Install]
WantedBy=multi-user.target
我从《使用 Yocto Project Cookbook 第二版进行嵌入式 Linux 开发》一书中获得了所有这些信息。
在我尝试添加这项新服务之前,我的所有构建都已成功。这本书没有提到 systemd 服务的 init shell 脚本。我还从 GitHub 中提取代码,而不是在我的构建目录中提取代码(您可以查看 repo)。
当我运行bitbake 时,我收到错误Didn't find service unit 'simpledaemon.service', specified in SYSTEMD_SERVICE_simpledaemon.。这告诉我这是一个路径错误,我只能假设它是由我的 GitHub 结构引起的。任何人都可以对此有所了解吗?
【问题讨论】:
标签: yocto systemd bitbake nxp-microcontroller