Re: Custom DISTRO_VERSION with git describe

Mikko Rapeli


On Thu, Apr 28, 2022 at 01:04:22PM +0200, Ayoub Zaki via wrote:

I would like to have a custom DISTRO_VERSION based on "git describe" of my

1) In my layer meta-mylayer/conf/layer.conf, I defined the following:

# Set variable to get the location of the layer

2) I created a my_distro_version.bbclass with following:

def my_distro_version(d):
import subprocess
project_path = d.getVar('MY_LAYER_BASE', True)
cmd = "git describe --tags"
I would also add --always and --dirty to be sure non-tagged clones
of repo work and builds with local modifications get marked as such.

proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
out, err = proc.communicate()
return out.decode("utf-8").rstrip()

3) Then I inherited it my meta-mylayer/conf/distro/my_distro.conf :

INHERIT += "my_distro_version"
DISTRO_VERSION = "${@my_distro_version(d)}"
DISTRO_VERSION := "${@my_distro_version(d)}"

That should do it :)



Join to automatically receive all group messages.