Reputation: 556
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:
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:
meta-newLayer
, but instead it contains meta-origLayer
.${THISDIR}
behaves differently when placed inside do_unpack_append()
from when it is used for prepending FILESEXTRAPATHS
cp: cannot stat '/fileToBeReplaced': No such file or directory
meta-origLayer
(i.e. meta-origLayer/machine1/fileToBeReplaced) and the .bbappend expects to find the file in /fileToBeReplacedI 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()
?
Upvotes: 4
Views: 5314
Reputation: 556
This *.bbappend correctly overwrites fileToBeReplaced
in the working directory during the unpack task:
FILESEXTRAPATHS_prepend := "${THISDIR}:"
SRC_URI_append += " file://fileToBeReplaced "
SAVED_DIR := "${THISDIR}"
do_unpack_append(){
bb.build.exec_func('replace_file', d)
}
replace_file(){
cp -f ${SAVED_DIR}/fileToBeReplaced ${WORKDIR}/fileToBeReplaced
}
Thanks for the explanation between bbappend parsing and execution johannes-schaub-ltb
Upvotes: 3