Yocto bitbake .bbappend not installing file - yocto

I am trying to add a json to /etc on a device.
Have read many SO answers and not found a solution.
The new json is called audio_config.json, it is under files/ in the same directory as the .bbappend. Am using append because this file is needed only on one device model while the main recipe is on many models.
Doing this:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://audio_config.json"
do_install_append() {
install -d ${D}${sysconfdir}
install -m 644 ${B}/audio_config.json ${D}${sysconfdir}
}
Gets an error saying that the json is not in the work directory.
The same thing happens if I use ${WORKDIR} instead of ${B}.
Other recipes in this tree follow this same model, not sure what the problem is.
If I use ${THISDIR} then it says that the json is not located in the base recipe directory - which it's not supposed to be.
From SO posts I have tried
FILES_${PN}-audio_config.json = "${sysconfdir}/audio_config.json"
But that seems to have no effect.
TIA!

In do_unpack() the file is copied to ${WORKDIR}, not ${B} (build dir) and not ${S} (sources dir). This recipe works for me with Yocto Dunfell:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://audio_config.json"
do_install_append() {
install -d ${D}${sysconfdir}
install -m 644 ${WORKDIR}/audio_config.json ${D}${sysconfdir}
}
Note the different source path argument in the second call to install.
I'm guessing that there was a yocto/bitbake bug that affected you.

According to users and documentation, what I had above should have worked. But it didn't.
What did work was this:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
AUDIO_CONFIG_FILES := "${THISDIR}/files"
do_install_append() {
install -d ${D}${sysconfdir}
install -m 644 ${AUDIO_CONFIG_FILES}/audio_config.json ${D}${sysconfdir}
}
Using a variable for immediate expansion of $THISDIR set the local path correctly and the install occurs.

You were right to add the FILES_${PN} to add the file to the image. But do not add any suffix to it, just append your file to the variable:
FILES_${PN} += "${sysconfdir}/audio_config.json"
Also, you should use the ${WORKDIR} in your install.
install -m 644 ${WORKDIR}/audio_config.json ${D}${sysconfdir}
Also check the work directory of your package to get some logs and see the files actually retrieved for an easier debugging.

Related

How can I install a file to /boot in yocto?

I need to add a file to the /boot directory produced by a yocto build. I've created a recipe that is trying to do this:
SRCREV = "48cabcbc64484ca6c201746e526a11b4b43eb359"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-uEnv.patch file://0002-disable-boot-interrupt.patch file://uEnv.txt"
FILES_${PN} += "/boot/uEnv.txt"
do_install_append() {
install -m 0744 ${WORKDIR}/uEnv.txt ${D}/${base_prefex}/boot
}
This recipe does some patching of u-boot too, but for now I'm just interested in the parts that are trying to add uEnv.txt to the boot directory. I know this recipe is being processed. If I rename the uEnv.txt file, for example, it throws an error. So I know it's trying to install it. But when I examine the rootfs created by yocto, the file is missing.
Does anyone know what I'm doing wrong? Maybe the problem is with ${D}/${base_prefex}/boot and I'm just not putting it in the right place? I've tried putting it in other places, though, like ${D}${sysconfdir}/ without success.
Here are some idea that you can try:
u-boot already have a variable to work with Env files (Check poky/meta/recipes-bsp/u-boot/u-boot.inc)
It checks for UBOOT_ENV variable if it is present and it copies it to /boot:
do_install() {
...
if [ -n "${UBOOT_ENV}" ]
then
install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${D}/boot/${UBOOT_ENV_IMAGE}
ln -sf ${UBOOT_ENV_IMAGE} ${D}/boot/${UBOOT_ENV_BINARY}
fi
...
}
do_deploy() {
...
if [ -n "${UBOOT_ENV}" ]
then
install -m 644 ${WORKDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_IMAGE}
rm -f ${DEPLOYDIR}/${UBOOT_ENV_BINARY} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_BINARY}
ln -sf ${UBOOT_ENV_IMAGE} ${DEPLOYDIR}/${UBOOT_ENV_SYMLINK}
fi
...
}
I assume that your recipe is a bbappend for uboot because it has a patch.
So you can try the following:
SRCREV = "48cabcbc64484ca6c201746e526a11b4b43eb359"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://0001-uEnv.patch file://0002-disable-boot-interrupt.patch file://uEnv.txt"
UBOOT_ENV = "uEnv"
UBOOT_ENV_SUFFIX = "txt"
More more note to be considered, if your Uboot is trying to fetch the uEnv.txt file from rootfs/boot then it is okay, but if it trying to get it from the boot partition (if you have one) then you should add it to that partition with (In your machine conf or local conf):
BOOT_FILES_append = " uEnv.txt"

yocto recipe how to install file to rootfs

sorry I am a little new to syntax of yocto, this is how I have modified my recipe:
LICENSE = "LGPLv2.1"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = "file://myscript.sh"
FILES_${PN} += "${sysconfdir}/init.d/myscript.sh"
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/
}
The recipe is added to the build, because if I remove the LICENSE line the yocto image will not be baked.
The folder where the recipe is kept is named "customssh", inside this folder I have the recipe named customssh_0.1.bb and a subfolder named "files" where the myscript.sh is kept.
After I have baked the image, I run this command to see if the myscript.sh has been placed in the rootfs:
find . -name 'myscript*'
which will return where the file is held:
./meta-swi/common/recipes-core/customssh/files/myscript.sh
In the recipe, is this line correct?
install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/
If this is the root recipe and not a bbappend one use do_install instead of do_install_append
Make sure that ${D}${sysconfdir}/init.d is created before copying to it
do_install(){
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/myscript.sh ${D}${sysconfdir}/init.d/
}
Now, make sure to specify the file you installed so that the do_package will not fail
FILES_${PN} += "${sysconfdir}/init.d/myscript.sh"

Yocto recipe to install shared libraries dependency issues

I have a Yocto recipe that compiles dynamically linked shared libraries that should be added to the rootfs. Compiling and adding them to rootfs works fine, but QA packaging warnings are resulted.
S = "${WORKDIR}/git"
do_compile () {
make
}
do_install () {
install -m 0755 -d ${D}${libdir}
oe_libinstall -so libA ${D}${libdir}
oe_libinstall -so libB ${D}${libdir}
oe_libinstall -so libC ${D}${libdir}
}
INSANE_SKIP_${PN} = "ldflags"
# RDEPENDS_${PN} = "libB${SOLIBS}"
# RPROVIDES_${PN} = "libB${SOLIBS}"
# FILES_${PN} = "${libdir}/lib*${SOLIBS}"
# INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
# INHIBIT_PACKAGE_STRIP = "1"
The warning is the following:
WARNING: package do_package_qa: QA Issue: /usr/lib/libC.so.1.0.0 contained in package package requires libB.so, but no providers found in RDEPENDS_package? [file-rdeps]
The commented RDEPENDS_${PN} = "libB${SOLIBS}" doesn't do anything in any way I tried so far.
How can I solve this problem? I don't want to add INSANE_SKIP_${PN} += "file-rdeps", I want to resolve the dependency problem.
Just guessing but isn't your recipe installing lib{A,B,C}.so.1.0.0 and they actually need libX.so (objdump -x /usr/lib/libC.so.1.0.0, what's in NEEDED)? In which case, they probably should depend on libX.so.1.0.0 instead, so fix your Makefile/CMakeLists.
I've never seen nor used oe_libinstall before, could you just use install relative/path/to/libA.so.1.0.0 ${D}${libdir} instead? Maybe that's oe_libinstall doing this weird trick?
Also, you probably don't need your manually crafted do_compile, it's already what the basic do_compile does for you (calling make if there's a Makefile available).

FIle is not being copied in WORKDIR from Image recipe in Yocto

I am trying to install a simple file to /etc directory of target rootfs. I am building core-image-sato. "raxy_test" file(in below recipe) is not even being copied in WORKDIR also.
Am I doing anything wrong?
I am able to do same with normal recipe but not with image recipe.
What is the difference between normal and image recipe?
DESCRIPTION = "Image with Sato, a mobile environment and visual style for \
mobile devices. The image supports X11 with a Sato theme, Pimlico \
applications, and contains terminal, editor, and file manager."
IMAGE_FEATURES += "splash package-management x11-base x11-sato ssh-server-dropbear hwcodecs"
LICENSE = "MIT"
inherit core-image
TOOLCHAIN_HOST_TASK_append = " nativesdk-intltool nativesdk-glib-2.0"
TOOLCHAIN_HOST_TASK_remove_task-populate-sdk-ext = " nativesdk-intltool nativesdk-glib-2.0"
LICENSE="CLOSED"
LIC_FILES_CHKSUM=""
SRC_URI = "\
file://raxy_test \
"
do_install() {
install -d ${D}${sysconfdir}
install -m 0755 raxy_test ${D}${sysconfdir}
}
I expect "raxy_test" file to be present in WORKDIR as well as in /etc directory of target.
Any help will really be appreciated, Thanks...!!!
Multiple things:
You use a image recipe (core-image-sato) to add a file in your image. You should use a separate recipe for this modification;
The install is not correct (WORKDIR is not used);
You do not populate the packages (FILES_${PN} not present).
For the separate recipe, create a file (for example myrecipe.bb or whatever you want) in a recipes-* sub directory (you need to place it at the same folder level than other recipes !). I did not test it but I think this can be a base:
DESCRIPTION = "My recipe"
LICENSE="CLOSED"
PR = "r0"
PV = "0.1"
SRC_URI = " file://raxy_test "
# Create package specific skeleton
do_install() {
install -d ${D}${sysconfdir}
install -m 0755 ${WORKDIR}/raxy_test ${D}${sysconfdir}/raxy_test
}
# Populate packages
FILES_${PN} = "${sysconfdir}"
You can notice that some things have changed:
The install must include the ${WORKDIR} path:
install -m 0755 ${WORKDIR}/raxy_test ${D}${sysconfdir}
And we need to populate the package:
FILES_${PN} = "${sysconfdir}"
This will add the files in ${sysconfdir} into the package ${PN} (which is by default the recipe name).

Bitbake does not install my files in my rootfs

My aim is to create Bitbake recipe, that will install config file in /etc directory, and script, that will apply this config into /ect/init.d directory (and invoke update-rc-d).
I already saw another similar question (Bitbake not installing my file in the rootfs image). I did almost exactly what this guy did, but unfortunately it didn't work.
The problem is that Bitbake does not complain on anything, but just not adds these files to rootfs.
Here is my current recipe. I also put my script and config files to two directories: files, and alsa-config, which resides inside recipe directory.
SUMMARY = "Alsa Config"
DESCRIPTION = "Adds alsa configuration file, and startup script that applies it."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI += " \
file://my-alsa-config \
file://asound.state \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
S = "${WORKDIR}"
INITSCRIPT_NAME = "my-alsa-config"
INITSCRIPT_PARAMS = "defaults 99 01"
inherit autotools update-rc.d
do_install() {
install -m 0644 ${WORKDIR}/asound.state ${D}${sysconfdir}
}
FILES_${PN} += "${sysconfdir}/asound.state"
In my local.conf I added line:
CORE_IMAGE_EXTRA_INSTALL += "alsa-config "
Please, can anybody help?
Fortunately, I was able to solve the problem. Here is the solution:
SUMMARY = "Alsa Config"
DESCRIPTION = "Adds alsa configuration file, and startup script that applies it."
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI += " \
file://my-alsa-config \
file://asound.state \
"
PACKAGE_ARCH = "${MACHINE_ARCH}"
S = "${WORKDIR}"
INITSCRIPT_NAME = "my-alsa-config"
INITSCRIPT_PARAMS = "defaults 99 01"
inherit autotools update-rc.d
do_install() {
install -d ${D}${sysconfdir}/init.d/
install -m 0755 ${WORKDIR}/my-alsa-config ${D}${sysconfdir}/init.d/
install -m 0644 ${WORKDIR}/asound.state ${D}${sysconfdir}/
}
FILES_${PN} += "${sysconfdir}/asound.state \
${sysconfdir}/my-alsa-config"
A little bit of comments:
PACKAGE_ARCH has to be set properly. In my case, when I didn't have it, execute permissions for script file were not set for some reason.
do_install() has to create every directory, that is needed. Even if I know, that in my rootfs there will be /etc directory, I have to create it. And I'm not sure if it is necessary, but it's better to have slash at the end of install directory, just in case.
Init scripts that are to be installed to launch at startup has to be installed too;)
Scripts must have proper permissions set.