All of lore.kernel.org
 help / color / mirror / Atom feed
From: Touhtarian, Eric <etouhtarian@distech-controls.com>
To: buildroot@busybox.net
Subject: [Buildroot] TR: [PATCH 1/1] Set external version into os-release
Date: Thu, 1 Oct 2020 14:49:02 +0000	[thread overview]
Message-ID: <DM6PR01MB4137169BE8F2D5C93A2D89DA8A300@DM6PR01MB4137.prod.exchangelabs.com> (raw)
In-Reply-To: <20200917153243.8745-1-etouhtarian@distech-controls.com>

Signed-off-by: Eric Touhtarian <etouhtarian@distech-controls.com>
---
 Makefile                        | 16 ++++++++++++++--
 support/scripts/setlocalversion | 15 ++++++++++++---
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index b2afe5bcfb..e6693d2f45 100644
--- a/Makefile
+++ b/Makefile
@@ -111,9 +111,12 @@ CONFIG_CONFIG_IN = Config.in  CONFIG = support/kconfig  DATE := $(shell date +%Y%m%d)
 
+define setlocalversion
+$(shell $(TOPDIR)/support/scripts/setlocalversion $(1) $(2)) endef
 # Compute the full local version string so packages can use it as-is  # Need to export it, so it can be got from environment in children (eg. mconf) -export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
+export BR2_VERSION_FULL := $(BR2_VERSION)$(call setlocalversion)
 
 # List of targets and target patterns for which .config doesn't need to be read in  noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \ @@ -740,6 +743,14 @@ host-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK)
 .PHONY: staging-finalize
 staging-finalize: $(STAGING_DIR_SYMLINK)
 
+define set-external-info
+index=1; \
+$(foreach ext, $(BR2_EXTERNAL_DIRS), \
+	echo "EXTERNAL_$${index}_PATH=$(ext)"; \
+	echo "EXTERNAL_$${index}_VERSION=\"$(call setlocalversion,"--unmodify-version", $(ext))\""; \
+	index=$$(expr $$index + 1); )
+endef
+
 .PHONY: target-finalize
 target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
 	@$(call MESSAGE,"Finalizing target directory") @@ -779,7 +790,8 @@ endif
 		echo "VERSION=$(BR2_VERSION_FULL)"; \
 		echo "ID=buildroot"; \
 		echo "VERSION_ID=$(BR2_VERSION)"; \
-		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
+		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\""; \
+		$(call set-external-info) \
 	) >  $(TARGET_DIR)/usr/lib/os-release
 	ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
 
diff --git a/support/scripts/setlocalversion b/support/scripts/setlocalversion index b39b751f03..459b4765fa 100755
--- a/support/scripts/setlocalversion
+++ b/support/scripts/setlocalversion
@@ -10,10 +10,16 @@
 #
 
 usage() {
-	echo "Usage: $0 [srctree]" >&2
+	echo "Usage: $0 [--unmodify-version] [srctree]" >&2
 	exit 1
 }
 
+original_ver=false
+if test "$1" = "--unmodify-version"; then
+	original_ver=true
+	shift
+fi
+
 cd "${1:-.}" || usage
 
 # Check for git and a git repo.
@@ -26,8 +32,11 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 		# If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"),
 		# we pretty print it.
 		if atag="`git describe 2>/dev/null`"; then
-			echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
-
+			if $original_ver; then
+				printf $atag
+			else
+				echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
+			fi
 		# If we don't have a tag at all we print -g{commitish}.
 		else
 			printf '%s%s' -g $head
--
2.17.1

       reply	other threads:[~2020-10-01 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200917153243.8745-1-etouhtarian@distech-controls.com>
2020-10-01 14:49 ` Touhtarian, Eric [this message]
2020-10-01 20:50   ` [Buildroot] TR: [PATCH 1/1] Set external version into os-release Yann E. MORIN
2020-10-02 13:07     ` Touhtarian, Eric

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=DM6PR01MB4137169BE8F2D5C93A2D89DA8A300@DM6PR01MB4137.prod.exchangelabs.com \
    --to=etouhtarian@distech-controls.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.