[yocto] Ad git revision to image name

Paul Eggleton paul.eggleton at linux.intel.com
Thu Apr 6 21:42:10 PDT 2017


Hi Tobias,

On Friday, 7 April 2017 4:09:45 AM NZST Grueninger, Tobias wrote:
> I would like to automatically add the git Revison checksum to the generated
> Yocto image name, e.g. 'core-image-git_bc123456.img'

Well, the immediate question would be which git revision is this? Your custom 
layer? Poky / OE-core? The kernel?

As for the mechanism, assuming you can get the revision at parse time, it's a 
bit crude but you could do something like this:

python() {
    repopath = '/path/to/git/repository'
    gitver = subprocess.check_output('git rev-parse HEAD', cwd=repopath)
    d.appendVar('IMAGE_BASENAME', '-git_%s' % gitver)
}

If parse time is too early you might try doing something at the start of 
do_rootfs, either a do_rootfs_prepend or a prefunc that does something similar 
to the above. In that case I'd be worried that we have other image tasks that 
look at IMAGE_BASENAME (via IMAGE_NAME) though.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the yocto mailing list