Yocto do_package: Didn't find service unit specified in SYSTEMD_SERVICE_ - linux

Description
I want to install a service into my image, but it is failing with following errors
ERROR: mypackage-git-r0 do_package: Didn't find service unit 'mypackage.service', specified in SYSTEMD_SERVICE_mypackage.
ERROR: Logfile of failure stored in: <build-location>/poky/build/tmp/work/cortexa53-poky-linux/mypackage/git-r0/temp/log.do_package.7924
ERROR: Task (<layer-location>/meta-mypackage-oe/recipes-mypackage/mypackage/mypackage_git.bb:do_package) failed with exit code '1'
Recipe
Python sources are cloned from git, now I want to create a service to run at boot. Here is the recipe
SUMMARY = " "
DESCRIPTION = " "
HOMEPAGE = " todo "
LICENSE = "CLOSED"
SRC_URI += "<URL>"
SRC_URI += "file://mypackage.service"
SRCREV = "<srcrev>"
S = "${WORKDIR}/git"
inherit setuptools3 systemd
RDEPENDS_${PN} = " \
${PYTHON_PN}-pyserial \
${PYTHON_PN}-pyusb \
${PYTHON_PN}-terminal \
"
SYSTEMD_PACKAGES = "${PN}"
do_install_append () {
install -d ${D}${system_unitdir}
install -m 0755 ${WORKDIR}/mypackage.service ${D}{system_unitdir}
}
SYSTEMD_SERVICE_${PN} = "mypackage.service"
FILES_${PN} += "${system_unitdir}/mypackage.service"
Recipe structure
recipes-mypackage/mypackage/
├── mypackage
│   └── mypackage.service
└── mypackage_git.bb
1 directory, 2 files
Service file
NOTE: mypackage has feature to run as daemon using -d option
[Unit]
Description=mypackage service
[Service]
Type=simple
ExecStart=/usr/bin/mypackage -d
[Install]
WantedBy=multi-user.target
Build configurations
Image recipe inherits core-image-base and contains
IMAGE_FEATURES += "package-management"
PACKAGE_CLASSES ?= "rpm deb package_deb"
DISTRO_FEATURES_append = " systemd"
VIRTUAL-RUNTIME_init_manager += "systemd"
inherit extrausers
local.conf contents
MACHINE = "raspberrypi3-64"
ENABLE_UART = "1"
RPI_USE_U_BOOT = "1"
GPU_FREQ = "250"
I might have messed up a lot of things in the recipe, so need some pointer to clean up the recipe as well as resolve the issue.
Thanks.

Replace system_unitdir by systemd_system_unitdir.
SYSTEMD_PACKAGES already contains ${PN} so you can ignore it, same for FILES_${PN} += "${systemd_system_unitdir}/mypackage.service" as if systemd.bbclass finds your unit, it'll be added to the appropriate FILES_ automatically.
c.f. https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/systemd.bbclass#n4
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/systemd.bbclass#n109
https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/classes/systemd.bbclass#n148
And for completeness, thanks to #Jussi Kukkonen for the comment, missing $ sign before {systemd_system_unitdir}.

Related

Yocto add Shared Library

I am trying to compile this GitHub project I found and add the resulting shared library to my SDK.
The project uses CMake. My recipe can download, and build this project. The resulting binary files work as expected, the given .so files contain what I need. When trying to add the .so files to my image I get the errors
ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA Issue: -dev package dbcppp-dev contains non-symlink .so '/usr/lib/libdbcppp.so'
-dev package dbcppp-dev contains non-symlink .so '/usr/lib/libxmlmm.so' [dev-elf]
ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA Issue: dbcppp rdepends on dbcppp-dev [dev-deps]
ERROR: dbcppp-1.0+gitrAUTOINC+917c925638-r0 do_package_qa: QA run found fatal errors. Please consider fixing them.
ERROR: Logfile of failure stored in: /home/michael/Documents/MAIN_Application/build-fb/tmp/work/cortexa7t2hf-neon-poky-linux-gnueabi/dbcppp/1.0+gitrAUTOINC+917c925638-r0/temp/log.do_package_qa.10943
ERROR: Task (/home/michael/Documents/MAIN_Application/MAIN_layers/meta-MAINapplication/recipes-core/dbcppp/dbcppp_0.0.bb:do_package_qa) failed with exit code '1'
My recipe is as follows:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
PV = "1.0+gitr${SRCPV}"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
inherit pkgconfig cmake
INSANE_SKIP:${PN} = "ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""
do_install() {
install -d ${D}${bindir}
install -m 0755 ${B}/bin/dbcppp ${D}${bindir}
install -d ${D}${libdir}
install -m 0755 ${B}/src/libdbcppp/libdbcppp.so ${D}${libdir}
install -m 0755 ${B}/libxmlmm.so ${D}${libdir}
install -m 0755 ${B}/third-party/libxml2/libxml2.so.2.9.10 ${D}${libdir}
}
FILES_${PN} += "${libdir}/*"
FILES_${PN}-dev = "${libdir}/* ${includedir}"
I have been searching for a while but I cannot find a solution. What do I need to do for this to work?
Edit 1: I updated my bb file to the following. This works but it does not place the necessary header files into my SDK.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
PV = "1.0+gitr${SRCPV}"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
inherit cmake
INSANE_SKIP:${PN} = "ldflags"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""
do_install() {
install -d ${D}${bindir}
install -m 0755 ${B}/bin/dbcppp ${D}${bindir}
install -d ${D}${libdir}
install -m 0755 ${B}/src/libdbcppp/libdbcppp.so ${D}${libdir}
install -m 0755 ${B}/libxmlmm.so ${D}${libdir}
install -m 0755 ${B}/third-party/libxml2/libxml2.so ${D}${libdir}
}
FILES_${PN} += "${libdir}/*.so"
FILES_${PN}-dev = "${includedir}"
The dbcppp Cmake file already has an install target that installs everything automatically, so you do not need do_install.
Try the following recipe:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "gitsm://github.com/xR3b0rn/dbcppp.git;protocol=https;branch=master"
PV = "1.0+gitr${SRCPV}"
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
inherit cmake
FILES_${PN} += "/usr/lib/xml2Conf.sh /usr/lib/lib*.so.*"
SOLIBS = ".so"
FILES_SOLIBSDEV = ""
INSANE_SKIP_${PN} += "dev-so"
The non-versioned shared libraries .so topic is difficult in Yocto, that's why skipping the QA shared library issue is the way to go here if you have no control on the source project's files/libraries.
The above recipe splits into multiple packages:
dbcppp (If you want just the dbcppp binary (.so files are shipped for the binary to run)
dbcppp-dev (If you want the header files and the shared libraries)
dbcppp-doc (If you want the man and html pages)

Yocto build could not invoke dnf . command && no Match for the argument : recipe-name

I tried to build my custom recipe for the project which contains programs for sensors. All the task and library making is taken care of by CMakeLists.txt it also has python dependencies. I added all the required dependencies within my recipe and tried to build it using the "bitbake soofierecp" command execution got successful. Whereas while attempting to install it with the local.conf using "IMAGE_INSTALL += soofierecp" it is giving an error as listed below:
Error is:
ERROR: soofie-img-1.0-r0 do_rootfs: Could not invoke dnf. Command '/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/etc/yum.repos.d --installroot=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs --setopt=logdir=/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/temp --repofrompath=oe-repo,/home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/oe-rootfs-repo --nogpgcheck install i2c-tools packagegroup-base-extended packagegroup-core-boot packagegroup-core-ssh-dropbear psplash python3 python3-dev python3-pip python3-requests run-postinsts soofierecp usbutils locale-base-en-us locale-base-en-gb' returned 1:
DNF version: 4.12.0
cachedir: /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/rootfs/var/cache/dnf
Added oe-repo repo from /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/oe-rootfs-repo
User-Agent: falling back to 'libdnf': could not detect OS or basearch
repo: using cache for: oe-repo
oe-repo: using metadata from Thu 26 May 2022 05:31:19 AM UTC.
Last metadata expiration check: 0:00:01 ago on Thu 26 May 2022 05:31:20 AM UTC.
No match for argument: soofierecp
Error: Unable to find a match: soofierecp
ERROR: Logfile of failure stored in: /home/anvation/nitish/source/build/tmp/work/qemux86_64-poky-linux/soofie-img/1.0-r0/temp/log.do_rootfs.1379711
ERROR: Task (/home/anvation/nitish/workspace/meta-soofie/recipes-example/images/soofie-img.bb:do_rootfs) failed with exit code '1'
NOTE: Tasks Summary: Attempted 4873 tasks of which 4872 didn't need to be rerun and 1 failed. "added the meta-layer in bblayer.conf file"
Recipe is:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
S = "${WORKDIR}"
PR = "r0"
DEPENDS = "openssl python3-six-native python3-pytest-runner-native"
SRC_URI = "\
file://src/ \
file://third_party/pybind11/ \
file://third_party/CLI11/ \
file://third_party/c-periphery/ \
file://CMakeLists.txt \
"
do_configure() {
cmake ../
}
RDEPENDS_${PN} = "python-requests python-six"
inherit pkgconfig cmake python3native
EXTRA_OEMAKE = ""
ALLOW_EMPTY_${PN}="1"
FILES_${PN} = "${bindir}/*"
DEPENDS += "udev"
Please help me to reach for the solution
I really appreciate any help you can provide.
I got the above code working with the suggestion and help
Thank you so much
The updated recipe is:
'
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
S = "${WORKDIR}"
PR = "r0"
SRC_URI = "\
file://src/ \
file://third_party/pybind11/ \
file://third_party/CLI11/ \
file://third_party/c-periphery/ \
file://CMakeLists.txt \
"
inherit cmake pkgconfig python3native
DEPENDS += "openssl python3-six-native python3-pytest-runner-native"
EXTRA_OECMAKE = ""
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/build/datagen ${D}${bindir}
}
DEPENDS += "udev"
FILES_${PN} += "${D}${bindir}/"
ALLOW_EMPTY_${PN} = "1"
'

Can not install cronjob file in yocto build, run.do_install error

I am trying to add a file my-cronjob.cron to /etc/cron.d inside my new meta-layer
The file tree is the following:
meta-customLayer
└── recipes-myCustomLayer
└── myCustomLayer
├── files
│ └── my-cronjob.cron
└── myCustomLayer.bb
my CustomLayer.bb :
PR = "r0"
PACKAGES = "${PN} ${PN}-dev ${PN}-dbg ${PN}-staticdev"
RDEPENDS_${PN}-staticdev = ""
RDEPENDS_${PN}-dev = ""
RDEPENDS_${PN}-dbg = ""
RDEPENDS_${PN} = ""
do_install() {
install -d ${D}/${sysconfdir}/cron.d
install -m 755 "${THISDIR}/files/testApp-cronjob.cron" ${sysconfdir}/cron.d/
}
FILES_${PN} += "${sysconfdir}/cron.d/testApp-cronjob"
And when i try to build the imahge i get the following error:
ERROR: myCustomLayer-1.0-r0 do_install: Execution of '/***/imx-yocto/build-core-image-base/tmp/work/cortexa35-poky-linux/myCustomLayer/1.0-r0/temp/run.do_install.16326' failed with exit code 1:
install: cannot create regular file '/etc/cron.d/testApp-cronjob.cron': Permission denied
Any idea why I get this error? Any way to add this cronjob to yocto?
You have missed the destination sufix:
install -m 755 "${THISDIR}/files/testApp-cronjob.cron" ${D}${sysconfdir}/cron.d/

Yocto:Execute shell script inside my source repository environment (inside downloads folder ?)

in Yocto I need to execute a bash script that depends on the source repository environment. My current approach is to execute the script directly in the downloads folder.
Pseudocode (hope you know what I mean):
do_patch_append () {
os.system(' \
pushd ${DL_DIR}/svn/*/svn/myapp/Src; \
dos2unix ./VersionBuild/MakeVersionList.sh; \
./VersionBuild/MakeVersionList.sh ${S}/Src/VersionList.h; \
popd \
')
}
Before I start fiddling with the details: Is this a valid approach ? And is do_patch the right place ?
Reason: The script MakeVersionList.sh generates a header file containing revision info from subversion. It executes "svn info" on several folders and parses its output into the header file VersionList.h, which will later be accessed in ${S} during compilation.
Thanks a lot.
Thanks for giving helpful advice. Here's how I finally did it. To minimize dependencies to server infrastructure (SVN server) I put the version generation into do_fetch. I had to do a manual do_unpack as well, because adding the generated file to SRC_URI (like ${DL_DIR}/svn/...) made the fetcher try to fetch it.
#
# Build bitstone application
#
SUMMARY = "Bitstone mega wallet"
SECTION = "Rockefeller"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"
#Register for root file system aggregation
APP_NAME = "bst-wallet"
FILES_${PN} += "${bindir}/${APP_NAME}"
PV = "${SRCPV}"
SRCREV = "${AUTOREV}"
SVN_SRV = "flints-svn"
SRC_URI = "svn://${SVN_SRV}/svn/${APP_NAME};module=Src;protocol=http;user=fred;pswd=pebbles "
S = "${WORKDIR}/Src"
GEN_FILE = "VersionList.h"
do_fetch_append () {
os.system(' \
cd ./svn/{0}/svn/{1}/Src; \
TZ=Pacific/Yap ./scripts/MakeVersionList.sh {2}; \
'.format(d.getVar("SVN_SRV"), d.getVar("APP_NAME"), d.getVar("GEN_FILE"))
)
}
do_unpack_append () {
os.system(' \
cp {3}/svn/{0}/svn/{1}/Src/{2} {4} \
'.format(d.getVar("SVN_SRV"), d.getVar("APP_NAME"), d.getVar("GEN_FILE"), \
d.getVar("DL_DIR"), d.getVar("S")) \
)
}
do_install_append () {
install -d ${D}${bindir}
install -m 0755 ${APP_NAME} ${D}${bindir}/
}

How do I write a yocto/bitbake recipe to replace the default vsftpd.conf file with my own file?

I want to replace the default vsftpd.conf file with my own file!
My bitbake file looks following:
bbexample_1.0.bb
DESCRIPTION = "Configuration and extra files for TX28"
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
S = "${WORKDIR}"
SRC_URI += " \
file://ld.so.conf \
file://nginx/nginx.conf \
file://init.d/myscript.sh"
inherit allarch
do_install () {
install -d ${D}${sysconfdir}
install -d ${D}${sysconfdir}/nginx
install -d ${D}${sysconfdir}/init.d
rm -f ${D}${sysconfdir}/ld.so.conf
install -m 0755 ${WORKDIR}/ld.so.conf ${D}${sysconfdir}
install -m 0755 ${WORKDIR}/nginx/nginx.conf ${D}${sysconfdir}/nginx/
install -m 0755 ${WORKDIR}/init.d/myscript.sh ${D}${sysconfdir}/init.d/
}
bbexample_1.0.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
SRC_URI += " \
file://vsftpd.conf"
do_install_append () {
install -m 0755 ${WORKDIR}/vsftpd.conf ${D}${sysconfdir}
}
But, the file could not be replaced!
What is wrong?
What you need to do is to use a bbappend in your own layer,
vsftpd recipe is located in meta-openembedded/meta-networking/recipes-daemons
Thus you need to create a file called vstfpd_%.bbappend (% makes it valid for every version)
This file must be located in <your-layer>/meta-networking/recipes-daemons. You also need to put your custom vsftpd.conf in <your-layer>/meta-networking/recipes-daemons/vsftpd folder
Its content should be:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
do_install_append(){
install -m 644 ${WORKDIR}/vsftpd.conf ${D}${sysconfdir}
}
Example from meta-openembedded here
you should add to your recipe:
FILES_${PN} += " file you installed"

Resources