I'm attempting to replace a file from another layer with a .bbappend file. My goal is to overwrite a specific configuration file with a customized one during the unpack stage.
In my .bbappend I'm attempting to append the do_unpack to copy a file from the same directory as the .bbappend file into the working directory ${WORKDIR} The problem is: When inside do_unpack_append, ${THISDIR} is returning the directory of the original .bb recipe, rather than the directory of .bbappend
Here's an example:
- The original recipe resides in: meta-origLayer/recipe.bb
- My *.bbappend resides in: meta-newLayer/recipe.bbappend
recipe.bbappend:
`FILESEXTRAPATHS_prepend := "${THISDIR}:"`
do_unpack_append(){
bb.build.exec_func('replace_file', d)
}
replace_file(){
cp -f ${THISDIR}/fileToBeReplaced ${WORKDIR}/fileToBeReplaced
echo ${THISDIR} > ${WORKDIR}/shouldContain_meta-newLayer
}
There are two issues with recipe.bbappend:
- I would expect the file shouldContain_meta-newLayer to contain
meta-newLayer, but instead it containsmeta-origLayer.
I'd primarily like to understand why${THISDIR}behaves differently when placed insidedo_unpack_append()from when it is used for prependingFILESEXTRAPATHS - When running bitbake, the recipe fails, producing the following error:
cp: cannot stat '/fileToBeReplaced': No such file or directory
- This error occurs because fileToBeReplaced resides in a subdirectory of
meta-origLayer(i.e. meta-origLayer/machine1/fileToBeReplaced) and the .bbappend expects to find the file in /fileToBeReplaced
My Question. . .
I have assumed ${THISDIR} would behave consistently within the same .bbappend, but it doesn't appear to. What is the best way to reference meta-newLayer/fileToBeReplaced from within do_unpack_append()?
${THISDIR}is only stable during parse time. You need to immediately-assign it to another variable outside tasks, likeTHISDIRSAVED := "${THISDIR}". The "correct" (?) way is to add your file toSRC_URI(use_append/_prepend, possibly including your machine, target-os or distribution, whatever is most appropriate, like_append_supercomputer = " work-on-1petabyte.patch"). That way, your file's checkum can be analyzed and added to the tasks, so if the input file changes, yocto knows when to reexecutedo_unpack. In do_unpack, you could then replace whatever file you want. - Johannes Schaub - litbSRC_URI_appendand the saved copy of${THISDIR}being the second. I was thinking that since the parent recipe already included SRC_URI forfileToBeReplacedI didn't need to add it again in the *.bbappend (as you point out, a rebuild isn't properly triggered ifSRC_URIisn't present in the bbappend). Thanks! - bamos