I have a bb file that will install a file into rootfs:
DESCRIPTION = "Add file to rootfs"
LICENSE = "test"
CONF_FILE = "${TOPDIR}/../meta/meta-test/recipes-test/test_file"
do_install() {
install -d ${D}/home/root
install -m 755 ${CONF_FILE} ${D}/home/root
}
FILES_${PN} += "/home/root"
It works fine and I can see my file in /home/root
Then I modify the file and build again.
But I find that the file isn't changed.
How can I have Yocto to check this file and build-in every time when it's changed?
Thanks to Nayfe.
It's been solved after adding SRC_URI
DESCRIPTION = "Add file to rootfs"
LICENSE = "test"
CONF_FILE = "${TOPDIR}/../meta/meta-test/recipes-test/test_file"
SRC_URI = ${CONF_FILE}
do_install() {
install -d ${D}/home/root
install -m 755 ${CONF_FILE} ${D}/home/root
}
FILES_${PN} += "/home/root"
Related
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"
After updating dotnet-runtime in our Yocto based Linux distribution to version 2.1.12, I saw that the resulting image had increased significantly in size. On closer inspection i found that the image contained both the new 2.1.12 version and the older 2.1.11 version of the dotnet-runtime library. How can I ensure that older version are not included in the image? Do I have to change more that just the SRC_URI and checksum?
Here is the content of dotnet-runtime.bb
DESCRIPTION = ".NET Core Runtime, SDK & CLI tools"
HOMEPAGE = "https://www.microsoft.com/net/core"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=42b611e7375c06a28601953626ab16cb"
COMPATIBLE_HOST ?= "x86_64.*-linux"
RDEPENDS_${PN} = "glibc zlib libunwind icu libcurl openssl krb5 libgssglue"
INSANE_SKIP_${PN} += "already-stripped staticdev file-rdeps libdir"
INHIBIT_PACKAGE_STRIP = "1"
INHIBIT_SYSROOT_STRIP = "1"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SRC_URI = "https://download.visualstudio.microsoft.com/download/pr/c1b620fe-7d8e-4685-b6ae-82b444dbc7a7/3d5610f0607da49ee014c61c6cd4e9af/aspne
tcore-runtime-2.1.12-linux-x64.tar.gz"
SRC_URI[sha256sum] = "cdb8816a437de168b25500b14ea32169abe610675ced08ca31f77f9542c2149a"
S = "${WORKDIR}"
do_install() {
install -d ${D}${bindir}
install -d ${D}${datadir}/dotnet
install -d ${D}${datadir}/dotnet/host/
install -d ${D}${datadir}/dotnet/shared/
install -m 0755 ${S}/dotnet ${D}${datadir}/dotnet
install -m 0644 ${S}/LICENSE.txt ${D}${datadir}/dotnet
install -m 0644 ${S}/ThirdPartyNotices.txt ${D}${datadir}/dotnet
cp -r --no-preserve=ownership ${S}/host/ ${D}${datadir}/dotnet/
cp -r --no-preserve=ownership ${S}/shared/ ${D}${datadir}/dotnet/
# Symlinks
cd ${D}${bindir}
ln -s ../../${datadir}/dotnet/dotnet dotnet || true
}
FILES_${PN} = "\
${bindir}/dotnet \
${datadir}/dotnet/ \
"
You might need to clean the cache of the recipe.
Just run:
$ bitbake -c clean {recipe name}
Then build your image again.
Hope it helps.
Adding the version number to the bitbake file, dotnet-runtime_2.1.12.bb instead of dotnet-runtime.bb, solved the issue.
Info about recipe naming http://www.embeddedlinux.org.cn/OEManual/recipes_versioning.html
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 ."
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).
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.