[PATCH] erofs-utils: use $EROFS_UTILS_VERSION, if set, as the version

Ahelenia Ziemiańska nabijaczleweli at nabijaczleweli.xyz
Fri Aug 16 13:05:41 AEST 2024


This lets downstreams embed the unpolluted downstream version;
when building the Debian package (from gbp) the resulting binary yields
  $ mkfs.erofs
  <E> erofs: missing argument: FILE
  mkfs.erofs 1.8.1-fead89d91-dirty
  Try 'mkfs.erofs --help' for more information.

Now, d/rules can
  export EROFS_UTILS_VERSION := $(shell IFS="$$IFS()" read -r _ v _ < debian/changelog; echo "$$v")
yielding
  $ mkfs.erofs
  <E> erofs: missing argument: FILE
  mkfs.erofs 1.8.1-1
  Try 'mkfs.erofs --help' for more information.

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli at nabijaczleweli.xyz>
---
 scripts/get-version-number | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/get-version-number b/scripts/get-version-number
index 26f0b5a..d216b7a 100755
--- a/scripts/get-version-number
+++ b/scripts/get-version-number
@@ -9,7 +9,7 @@ scm_version()
 		# If we are at a tagged commit, we ignore it.
 		if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then
 			# Add -g and 8 hex chars.
-			printf '%s%s' -g "$(echo $head | cut -c1-8)"
+			printf -- '-g%.8s' "$head"
 		fi
 		# Check for uncommitted changes.
 		# This script must avoid any write attempt to the source tree,
@@ -30,4 +30,8 @@ scm_version()
 	fi
 }
 
-echo $(sed -n '1p' VERSION | tr -d '\n')$(scm_version)
+if [ -n "$EROFS_UTILS_VERSION" ]; then
+	echo "$EROFS_UTILS_VERSION"
+else
+	echo $(head -n1 VERSION)$(scm_version)
+fi
-- 
2.39.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20240816/200acb8e/attachment.sig>


More information about the Linux-erofs mailing list