def my_distro_version(d):
import subprocess
project_path = d.getVar('MY_LAYER_BASE', True)
cmd = "git describe --tags"
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True, cwd=project_path)
out, err = proc.communicate()
return out.decode("utf-8").rstrip()
MY_DISTRO_VERSION := "${@my_distro_version(d)}"
INHERIT += "my_distro_version"
DISTRO_VERSION := "${MY_DISTRO_VERSION}"
On Thu, Apr 28, 2022 at 01:25:03PM +0200, Ayoub Zaki wrote:
> Hi,
>
> thanks for the quick reply I tried your suggestion but I get:
>
> ERROR: Unable to parse Var <DISTRO_VERSION[:=]>
> Traceback (most recent call last):
> File "Var <DISTRO_VERSION[:=]>", line 1, in <module>
> bb.data_smart.ExpansionError: Failure expanding variable
> DISTRO_VERSION[:=], expression was ${@my_distro_version(d)} which triggered
> exception NameError: name 'my_distro_version' is not defined
Did you include the bbclass?
> I think in this case the INHERIT doesn't work !
Well I have in distro config:
require classes/distroversion.bbclass
which has a single python function
def get_distro_version(d, dirty=True, abbrev=None):
which basically calls "git describe --always --dirty --abbrev=8",
the last one was added when git versions started behaving differently
and breaking reproducibility.
And then distro config also has:
DISTRO_VERSION := "${@get_distro_version(d)}"
This works for me up to yocto 3.1 dunfell at least.
Cheers,
-Mikko