FIle is not being copied in WORKDIR from Image recipe in Yocto - 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).

Related

Why does Yocto not add files to my rootfs

Hi everyone, I want to add u-boot environment files to my /etc directory. bitbake-layers show-recipes shows my current u-boot, which is:
u-boot-ti-staging: 1. meta-ti 1:2021.01+git999 2. meta-ti 1:2020.01+gitAUTOINC+2781231a33I've created a seperate layer with a higher priority and with the folder recipes-bsp/u-boot in it.The folder u-boot has a sub-directory "files" with 2 files in it.This is how my u-boot-ti-staging%.bbappend looks like:
```FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI:append = " \file://env.cfg \file://fw_env.config \"
FILES_${PN} += " \${sysconfdir}/fw_env.config \${sysconfdir}/env.cfg \"
do_install:append() {install -m 755 ${WORKDIR}/fw_env.config ${D}${sysconfdir}install -m 755 ${WORKDIR}/env.cfg ${D}${sysconfdir}}```Unfortunately the files do not show up in my rootfs under the /etc directory

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 bitbake .bbappend not installing file

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.

Bitbake not installing files from recipe to rootfs

I'm currently using yocto to build the system imx6sxsabresd (IMX6 Solo X). I have successfully built the image however I want to add a script to init.d to turn on a led. I'm appending to the linux-imx recipes within the meta-fsl-bsp-release layer.
This is my linux-imx.bbappend file:
FILESEXTRAPATHS_prepend := "${THISDIR}/linux-imx:"
SRC_URI += "file://0001-added-pad-for-heartbeat-led.patch \
file://heartbeat.sh \
file://heartbeat "
PACKAGECONFIG_append = " heartbeat"
inherit update-rc.d
INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_PARAMS = "start"
INITSCRIPT_NAME = "heartbeat.sh"
do_install_append()
{
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/heartbeat.sh ${D}${sysconfdir}/init.d/heartbeat.sh
install -d ${D}/home/root
install -m 0755 ${WORKDIR}/heartbeat ${D}/home/root/heartbeat
}
FILES_${PN} += "${sysconfdir}/init.d/heartbeat.sh /home/root/heartbeat"
PACKAGES = "${PN}"
I'm able to create the sdcard image succesfully with the patch I've included in this bbappend file, however, the files heartbeat.sh and heartbeat are not copying to the final rootfs added to the output sdcard file. This is very odd because I'm able to see these files in their paths copied to ../tmp/work/imx6sxsabresd-poky-linux-gnueabi/linux-imx/4.14.98-r0/image/
As the comments suggests appending to the kernel recipe is the wrong way to go about this. You should instead add your own recipe and reference that recipe from the image definition (append to IMAGE_INSTALL).
Your recipe could look something like:
SUMMARY = "LED heartbeat init script"
inherit update-rc.d
SRC_URI += "\
file://heartbeat.sh \
"
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/heartbeat.sh ${D}${sysconfdir}/init.d/
}
FILES_${PN} = "${sysconfdir}/init.d/heartbeat.sh"
INITSCRIPT_NAME = "heartbeat.sh"
INITSCRIPT_PARAMS = "start 90 5 . stop 20 0 1 6 ."

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.