I want to apply a patch to a file in /etc in the rootfs. So I create a Yocto recipes
├── test_1.0.bb
└── files
└── sshd.patch
and I've started to create the file .bb that is like this:
DESCRIPTION = "Patch files"
SECTION = "Patch"
LICENSE = "MIT"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI = " \
file://sshd.patch \
"
I tried different "configuration" with do_install(), but they didn't work. (When I do "bitbake core-image-base" there are not problems, but then in the rootfs the patch is not applied)
*English is not my mother tongue; please excuse any errors on my part.
If you want to patch an existing recipe file, you need to create a openssh_%.bbappend
file instead of test_1.0.bb
and put every files to replace in SRC_URI
(ie file://sshd_config
) instead of sshd.patch
.
Then, as those files already exist, you don't need to modify do_install from original recipe. Otherwise you need to add
do_install_append(){
install -Dm 0644 ${S}/myfile ${D}${sysconfdir}/example/myfile
}
# and modify FILES_${PN} if file is added in unusual place
By the way, a recipe cannot override another recipe file without being in conflict, so another solution is to patch it at rootfs creation, with ROOTFS_POSTPROCESS_COMMAND. (That's why you cannot use test_0.1.bb
for that).
Otherwise, patch files are automatically applied so you don't need to modify do_patch nor do_install.
If you add a recipe, don't forget to add it to image with IMAGE_INSTALL_append = " test"
in local.conf
in your case.