[yocto] Ordering of anonymous Python functions and task signature calculations

Khem Raj raj.khem at gmail.com
Tue Jan 24 10:19:51 PST 2017


On Tue, Jan 24, 2017 at 9:55 AM, Matt Hoosier <matt.hoosier at gmail.com> wrote:
> In order to support a use-case that embeds information about the Git
> revision of Yocto itself that was used to make a build, I would like to run
> some arbitrary Python code and dump the results (Git SHA1's, tag names, etc)
> into a Bitbake variable.
>
> The idea is that the variable would get consumed in a do_install() task to
> populate some cookie-crumb file in the package payload.
>
> Something like:
>
>   DEPENDS = "git-native"
>
>   python () {
>     # This pseudocode isn't strictly functional for invoking Git, but you
> get the idea
>     d.setVar('GIT_INFO', subprocess.Popen(['git', 'rev-list',
> ...]).communicate().stdout)
>   }
>
>   do_install () {
>     install -d ${D}/etc
>     echo "${GIT_INFO}" > ${D}/etc/git-info.txt
>   }
>
> This all works on a fresh run, but Bitbake appears not to be evaluating the
> anonymous Python function on each execution. This leads it to have
> out-of-date information about the Git working copy when global state changes
> but happens not to impact the particular recipe holding this logic.
>
> Is there any trick available to cause the Python function to execute (and
> hence update the value of ${GIT_INFO} each Bitbake execution so that the
> up-to-the-moment contents of it filter into the calculation of the signature
> for do_install()? Or am I just trying a wrong-headed approach and doing
> something illegitimate?
>

May be you can do it as a post processing step at image build time.

> -Matt
>
> --
> _______________________________________________
> yocto mailing list
> yocto at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/yocto
>



More information about the yocto mailing list