All of lore.kernel.org
 help / color / mirror / Atom feed
From: <Mikko.Rapeli@bmw.de>
To: <ayoub.zaki@googlemail.com>
Cc: <yocto@lists.yoctoproject.org>
Subject: Re: [yocto] Custom DISTRO_VERSION with git describe
Date: Thu, 28 Apr 2022 11:15:00 +0000	[thread overview]
Message-ID: <Ymp3MwKCqW2DbWe2@korppu> (raw)
In-Reply-To: <CA+-BmJZxufzfqd=VR6MH+ZB3osYwpSyHvW=SvNNpag3gs+Wz8w@mail.gmail.com>

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

  reply	other threads:[~2022-04-28 11:15 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 ` Mikko.Rapeli [this message]
2022-04-28 11:25   ` [yocto] " Ayoub Zaki
2022-04-28 11:32     ` Mikko.Rapeli
2022-04-28 11:38       ` Ayoub Zaki
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=Ymp3MwKCqW2DbWe2@korppu \
    --to=mikko.rapeli@bmw.de \
    --cc=ayoub.zaki@googlemail.com \
    --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.