[yocto] Setting a custom hostname using git revisions?

Stephano Cetola stephano.cetola at linux.intel.com
Wed Apr 4 09:13:36 PDT 2018


On 4/4/18 8:48 AM, Giordon Stark wrote:
> Hi all,
> 
> I looked at the bitbake manual, but if I have a custom layer that's
> checked out at a specific revision, how can I access the variable
> containing the revision to embed it into the hostname variable?
> 
> I would want to append the hostname variable in:
> recipes-core/base-files/base-files_%.bbappend which is currently set to
> "${MACHINE}".
> 
> Instead, I would like something along the lines of
> "${MACHINE}-${LAYER_REV}".
> 
> Thanks,
> 
> Giordon
> -- 
> Giordon Stark
> 
> 

This is pretty tricky. I'd use a python function inside your recipe.

You can get the layers like this:

layers = (bb.data.getVar("BBLAYERS", d, 1) or "").split()

Then if you have a look at the metadata_scm.bbclass, you can use some of
the functions in there:

base_get_metadata_git_branch
base_get_metadata_git_revision

Add some logic and you should be able to pull the revision information
you care about out of that data.

Cheers,
Stephano





More information about the yocto mailing list