All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Korsgaard <peter@korsgaard.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] Makefile: properly account for custom tags in BR2_VERSION_FULL
Date: Mon, 27 Jul 2020 18:49:18 +0200	[thread overview]
Message-ID: <877duovr75.fsf@dell.be.48ers.dk> (raw)
In-Reply-To: <20200720115958.2564971-1-thomas.petazzoni@bootlin.com> (Thomas Petazzoni's message of "Mon, 20 Jul 2020 13:59:57 +0200")

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:

 > BR2_VERSION_FULL is currently defined as follows:
 >   BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)

 > This BR2_VERSION_FULL value then gets used as the "VERSION" variable
 > in the /etc/os-release file.

 > The logic of "setlocalversion" is that if it is exactly on a tag, it
 > returns nothing.

 > If it is on a tag + a number of commits, then it returns only
 > -XYZ-gABC where XYZ is the number of commits since the last tag, and
 > ABC the git commit hash (these are extracted from git describe).

 > This output then gets concatenated to BR2_VERSION which gives
 > something like 2020.05 or 2020.05-00123-g5bc6a.

 > The issue is that when you're on a tag specific to your project, which
 > is not a Buildroot YYYY.MM tag, then the output of setlocalversion is
 > empty, and all you get as VERSION in os-release is $(BR2_VERSION)
 > which is not really nice. Worse, if you have another non-official
 > Buildroot tag between the last official Buildroot tag/version and
 > where you are, you will get $(BR2_VERSION)-XYZ-gABC, but XYZ will not
 > correspond to the number of commits since BR2_VERSION, but since the
 > last tag that "git describe" as found, which is clearly incorrect.

 > Here is an example: you're on master, "make print-version" (which
 > displays BR2_VERSION_FULL) will show:

 > $ make print-version
 > 2020.08-git-00758-gc351877a6e

 > So far so good. Now, you create a tag say 5 commits "before" master,
 > and show BR2_VERSION_FULL again:

 > $ git tag -a -m "dummy tag" dummy-tag HEAD~5
 > $ make print-version
 > 2020.08-git-00005-gc351877a6e

 > This makes you believe you are 5 commits above 2020.08, which is
 > absolutely wrong.

 > So this commit simplifies the logic of setlocalversion to simply
 > return what "git describe" provides, and not prepend $(BR2_VERSION) in
 > the main Makefile. Since official Buildroot tags match official
 > Buildroot version names, you get the same output when you're on an
 > official Buildroot tag, or some commits above a Buildroot tag. An in
 > other cases, you get a sensible output. The logic is also adjusted for
 > the Mercurial case.

 > In the above situation, with this commit applied, we get:

 > $ make print-version
 > dummy-tag-6-g6258cdddeb

 > (6 commits instead of 5 as we have this very commit applied, but at
 > least it's 6 commits on top of the dummy-tag)

 > Finally, if you're not using a version control system, setlocalversion
 > was already returning nothing, so in this case, the Makefile simply
 > sets BR2_VERSION_FULL to BR2_VERSION to preserve this behavior.

 > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Committed, thanks.

-- 
Bye, Peter Korsgaard

  reply	other threads:[~2020-07-27 16:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 11:59 [Buildroot] [PATCH] Makefile: properly account for custom tags in BR2_VERSION_FULL Thomas Petazzoni
2020-07-27 16:49 ` Peter Korsgaard [this message]
2020-08-13 18:06 ` Peter Korsgaard
2020-09-25 13:12 ` Andreas Naumann

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=877duovr75.fsf@dell.be.48ers.dk \
    --to=peter@korsgaard.com \
    --cc=buildroot@busybox.net \
    /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.