From patchwork Mon Sep 28 11:32:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas De Schampheleire X-Patchwork-Id: 1372554 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=emu+bSeT; dkim-atps=neutral Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C0L3B3k9gz9sPB for ; Mon, 28 Sep 2020 21:32:21 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E51401FCB5; Mon, 28 Sep 2020 11:32:18 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LOc+WYH7EIOS; Mon, 28 Sep 2020 11:32:17 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 12EB220027; Mon, 28 Sep 2020 11:32:17 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id E700D1BF3C1 for ; Mon, 28 Sep 2020 11:32:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id DE9EE861AB for ; Mon, 28 Sep 2020 11:32:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gcLSVpDqpA1v for ; Mon, 28 Sep 2020 11:32:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id 6DB1786156 for ; Mon, 28 Sep 2020 11:32:14 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id a12so879907eds.13 for ; Mon, 28 Sep 2020 04:32:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5nQZW87jVJqF9+BVZeXen8ZGE5oVNi+mt19a7V9kwoA=; b=emu+bSeT9A+OgWg1TspooKt2wPsCavPmSjWbUiOsSdNFrjXFuJ1xsA74FaC7E0c3Uj 7qDh7SqpY5jxztNjhXBPm9Q1ps+ZMQZuAm8RIVV2A6Z4rbCRGd/VKvpT6SRkRKTJ1GtP NkwEDRs2KdSROu2XSzQFUprHv4hdF8KOV5x5jv1ZM3SwU/lZAOINSI7KPANOnk1wI1Me 1rCbK52SWJBcEohdCLtMY/vPN5HvLsm9hjaswPsvosvQUqKp37cicRKq+YQIf2MpvkIg xvVJdOABPS0JuYZbYwGE6PE/QAsoeNcyr4egFdQAeuhrddInaOzJ97PTzWgaCc2fyDma O5Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5nQZW87jVJqF9+BVZeXen8ZGE5oVNi+mt19a7V9kwoA=; b=YQbCiAqd21CaQfz6eLVN7pOIe0D4EwIAiG0X0CdehinZnuDYylID/I1vDN357KbH5U VqVGQ5uXhNb6vP+twWlbC5UFsKlwznfH7EOQ+Vw73VWI4VdkiDrtsAEUa/tpkaW/a/Ty 8ebrUUAgi3NxsgX/CKjrUZ0udEIjF59qPG+RKbwDacTtvFVnjGOJ3NjTOWKtWP6M/ray j9qQd5JPORrXSrKWHxPYprWfyNUlDxiQAKURxTB2YBCaQVPeUaEAKvGL//AHzWyH+COX TL3ffjMyAXHMXJlbemRPzQ3YT39KBa26lRSb46pSSi5gV6totfYgoOHVZkw7avrsvgjN Z4xQ== X-Gm-Message-State: AOAM530fbo7lNKP71FmB/+H7X5t1R5J7SIvSVwir+Bb6R7tgfGf2UOOc PEOyoysIiS5z20XvHnj7AL/i9PYALu3wng== X-Google-Smtp-Source: ABdhPJx3dmFl+p/FhIEA+mx+dkXqGm5cBcpAkQny4wUsQRB6OgEBgT3BjjqZG+ZuZstrjgmlKq7+RQ== X-Received: by 2002:a05:6402:1515:: with SMTP id f21mr1203092edw.175.1601292732527; Mon, 28 Sep 2020 04:32:12 -0700 (PDT) Received: from localhost (ptr-5gw9txf6g5tndjqqqz.18120a2.ip6.access.telenet.be. [2a02:1810:510:3800:1b15:18e4:57d1:eb]) by smtp.gmail.com with ESMTPSA id z18sm871437ejw.94.2020.09.28.04.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 04:32:11 -0700 (PDT) From: Thomas De Schampheleire To: buildroot@buildroot.org Date: Mon, 28 Sep 2020 13:32:10 +0200 Message-Id: <20200928113210.3153-1-patrickdepinguin@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Buildroot] [PATCH master+LTS] support/scripts/setlocalversion: fix/improve Mercurial output X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas De Schampheleire , Thomas Petazzoni Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Thomas De Schampheleire Commit 9e4ffdc8cfdf4c73f4fa8c66259a5aadaee4ae88 modified the output of 'setlocalversion' so that the Buildroot version tag is included in the output, the version part was added in Makefile. Due to differences in behavior of the used git and Mercurial commands, this caused different output for the Mercurial case, in BR2_VERSION_FULL and thus /etc/os-release and 'make print-version'. Assuming the official Buildroot releases are tagged and no project-specific tags are present, the output after commit 9e4ffdc8cfdf4c73f4fa8c66259a5aadaee4ae88 is: -hg whereas it is expected to be something like: 2020.02.6-hg Change the Mercurial case in setlocalversion to behave similar to git, looking up the latest tag if the current revision is not itself tagged. The number of commits after the latest tag is not added, unlike in git, as this value is not commonly present in Mercurial output, and its added value can be disputed in this context. Even one commit could bring a huge change to the sources, so in order to interpret the number one has to look at the repository anyhow, in which case the commit ID can just be used. Signed-off-by: Thomas De Schampheleire --- support/scripts/setlocalversion | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/support/scripts/setlocalversion b/support/scripts/setlocalversion index e04c955d9e..49971b0fad 100755 --- a/support/scripts/setlocalversion +++ b/support/scripts/setlocalversion @@ -48,14 +48,28 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then fi # Check for mercurial and a mercurial repo. +# In the git case, 'git describe' will show the latest tag, and unless we are +# exactly on that tag, the number of commits since then, and last commit id. +# Mimic something similar in the Mercurial case. if hgid=`HGRCPATH= hg id --id --tags 2>/dev/null`; then tag=`printf '%s' "$hgid" | cut -d' ' -f2 --only-delimited` # Do we have an untagged version? if [ -z "$tag" -o "$tag" = tip ]; then + # current revision is not tagged, determine latest tag + latesttag=`HGRCPATH= hg log -r. -T '{latesttag}' 2>/dev/null` + # In case there is more than one tag on the latest tagged commit, + # 'latesttag' will separate them by colon (:). We'll retain this. + # In case there is no tag at all, 'null' will be returned. + if [ "$latesttag" != "null" ]; then + printf "${latesttag}" + fi + + # add the commit id id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` printf '%s%s' -hg "$id" else + # current revision is tagged, just print the tag printf ${tag} fi