[yocto] Setting a custom hostname using git revisions?

Stephano Cetola stephano.cetola at linux.intel.com
Wed Apr 4 14:58:41 PDT 2018


On 4/4/18 9:13 AM, Stephano Cetola wrote:
> 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
> 
> 
A rather elaborate example of how to get the revision number can be seen
here:

https://github.com/openembedded/openembedded-core/blob/master/meta/classes/image-buildinfo.bbclass

--S



More information about the yocto mailing list