Hi, On Thu, Apr 28, 2022 at 01:04:22PM +0200, Ayoub Zaki via lists.yoctoproject.org wrote: > hello, > > > I would like to have a custom DISTRO_VERSION based on "git describe" of my > layer: > > > 1) In my layer meta-mylayer/conf/layer.conf, I defined the following: > > # Set variable to get the location of the layer > > MY_LAYER_BASE := '${LAYERDIR}' > > > > 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, > > cwd=project_path) > > 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 :) Cheers, -Mikko
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#56931): https://lists.yoctoproject.org/g/yocto/message/56931 Mute This Topic: https://lists.yoctoproject.org/mt/90750240/21656 Group Owner: yocto+ow...@lists.yoctoproject.org Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-