All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ayoub Zaki <ayoub.zaki@googlemail.com>
To: Mikko.Rapeli@bmw.de
Cc: yocto@lists.yoctoproject.org
Subject: Re: [yocto] Custom DISTRO_VERSION with git describe
Date: Thu, 28 Apr 2022 13:38:35 +0200	[thread overview]
Message-ID: <CA+-BmJY1jCPuv=iUnvKghVZ48MosAEfbn5Nx5DopW6H8BmvjXg@mail.gmail.com> (raw)
In-Reply-To: <Ymp7VsxfuQeCSgKx@korppu>

[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]

I'm also suing dunfell branch, I did a small modification in
my_distro_version.bbclass:

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)}"



Then in meta-mylayer/conf/distro/my_distro.conf I used:

> INHERIT += "my_distro_version"
> DISTRO_VERSION := "${MY_DISTRO_VERSION}"


It seems to be working now :-)


Thank you for the support :-)


cheers,


On Thu, Apr 28, 2022 at 1:32 PM <Mikko.Rapeli@bmw.de> wrote:

> 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

[-- Attachment #2: Type: text/html, Size: 2798 bytes --]

  reply	other threads:[~2022-04-28 11:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28 11:04 Custom DISTRO_VERSION with git describe Ayoub Zaki
2022-04-28 11:15 ` [yocto] " Mikko.Rapeli
2022-04-28 11:25   ` Ayoub Zaki
2022-04-28 11:32     ` Mikko.Rapeli
2022-04-28 11:38       ` Ayoub Zaki [this message]
2022-04-28 11:52         ` Mikko.Rapeli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+-BmJY1jCPuv=iUnvKghVZ48MosAEfbn5Nx5DopW6H8BmvjXg@mail.gmail.com' \
    --to=ayoub.zaki@googlemail.com \
    --cc=Mikko.Rapeli@bmw.de \
    --cc=yocto@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.