使用yocto启用系统服务 [英] Enable systemd services using yocto

查看:353
本文介绍了使用yocto启用系统服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的图层树

├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-hello
    ├── helloworld
    │   ├── helloworld-0.1
    │   │   ├── helloworld.c
    │   │   ├── helloworld.patch
    │   │   └── newhelloworld.c
    │   └── helloworld_0.1.bb
    ├── message
    │   ├── message-0.1
    │   │   └── message.txt
    │   └── message_0.1.bb
    └── service
        ├── service-0.1
        │   ├── test_systemd.service
        │   └── test_systemd.sh
        └── service_0.1.bb

这里test_systemd.service是必须调用test_systemd.sh的服务文件,我正在尝试使用service_0.1.bb来实现

Here test_systemd.service is the service file which have to invoke test_systemd.sh, which I am trying to achieve using service_0.1.bb

    # This recipe performs the following tasks
    # 1) Install .sh file in /home/root/ and .sh script creates a random text file
    # 2) Install the .service file in systemd directory
    # 3) Invoke the .sh script via .service file
    inherit systemd

SUMMARY = "Install and start a systemd service"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

#here we specify the source we want to build
SRC_URI = "file://test_systemd.sh"
SRC_URI += "file://test_systemd.service"
#here we specify the source directory, where we can do all the building and expect sources to be placed
S = "${WORKDIR}"

SYSTEMD_SERVICE_${PN} = "test_systemd.service"


#bitbake task
#created a directory /home/root for target install the script
do_install() {
             install -d ${D}/home/root
             install -m 0755 ${WORKDIR}/test_systemd.sh ${D}/home/root

             install -d ${D}{systemd_system_unitdir}
             install -m 0644 ${WORKDIR}/test_systemd.service ${D}{systemd_system_unitdir}
}

#Pack the path
FILES_${PN} += "/home/root"
FILES_${PN} += "/lib/systemd/system"

REQUIRED_DISTRO_FEATURES= "systemd"

问题是当我尝试对系统配方进行bitbake时,bitbake抛出错误,提示未找到test_systemd.service. 我设法通过先前的尝试将两个文件都安装在RFS中,但是当我包含systemd概念时.我收到没有此类文件错误.可能是什么原因 ? 错误消息

The problem is when I try to bitbake system recipe, bitbake throws an error saying test_systemd.service not found. I managed to install both the files in RFS with a previous attempt but when I include the systemd concept. I get the no such file error. What could be the reason ? Error message

 NOTE: Executing SetScene Tasks
NOTE: Executing RunQueue Tasks
ERROR: service-0.1-r0 do_package: SYSTEMD_SERVICE_service value test_systemd.service does not exist
ERROR: service-0.1-r0 do_package: Function failed: systemd_populate_packages
ERROR: Logfile of failure stored in: /home/guest/yocto_practice/poky/build-beaglebone/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/service/0.1-r0/temp/log.do_package.2860
ERROR: Task (/home/guest/yocto_practice/meta-testlayer/recipes-hello/service/service_0.1.bb:do_package) failed with exit code '1'
NOTE: Tasks Summary: Attempted 514 tasks of which 506 didn't need to be rerun and 1 failed.

Summary: 1 task failed:
  /home/guest/yocto_practice/meta-testlayer/recipes-hello/service/service_0.1.bb:do_package
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

这也是为systemd编写bb配方的正确方法,这是什么意思

Also is this the correct way to write bb recipe for systemd and what is the significance of writing this

#Pack the path
    FILES_${PN} += "/home/root"
    FILES_${PN} += "/lib/systemd/system"

没有进行此位烘烤将引发错误.

without this bitbake throws error.

推荐答案

SYSTEMD_SERVICE_${PN} += "file://test_systemd.service"

这应该是:

SYSTEMD_SERVICE_${PN} = "test_systemd.service"

其他注释(与错误无关)

Other notes (unrelated to the error):

  • 在/home中安装东西可能不是一个好主意(您可以将${libexecdir}用于其他脚本所需的脚本.
  • 没有理由在bb文件中包含do_install_append():您只需将所有内容放入do_install()
  • 如果您的Yocto是最新的,则使用${systemd_system_unitdir}代替/lib/systemd/system是个好主意(在较早的版本中,${systemd_unitdir}/system/可以使用)
  • Installing things into /home is probably not a great idea (you could use e.g. ${libexecdir} for scripts that other scripts need.
  • there's no reason for having a do_install_append() in a bb file: you can just put everything in do_install()
  • If your Yocto is recent, using ${systemd_system_unitdir} instead of /lib/systemd/system is a good idea (in older releases ${systemd_unitdir}/system/ works)

这篇关于使用yocto启用系统服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆