Search code examples
yoctobitbakepetalinux

How can I get the directory of a bbappend file?


I've got a .bbappend file and a python task in it. How can I get the directory in which this recipe append file is placed? If I use THIS_DIR or FILE variables, I get the path of the original recipe not the .bbappend file.

Creepy Solution

I've created a symbolic link to the actual recipe in the same directory. This way, I'm able to obtain the directory without modifying the original recipe.


Solution

  • Use the immediate expansion operator := to get the actual directory of .bbappend file during recipe parsing.

    BBAPPEND_DIR := "${THISDIR}"
    
    python mytask() {
        bb.debug("Late expanded THISDIR: %s" % d.getVar("THISDIR"))
        bb.debug("BBAPPEND_DIR: %s" % d.getVar("BBAPPEND_DIR"))
    }
    

    Another workaround is to create a symbolic link to the original recipe inside the same directory as the .bbappend file.