From c6530389dc31c77360e1b34ef772d956d9c79ad8 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Mon, 4 May 2020 23:23:46 +0900 Subject: [PATCH] DEB build scripts: further improvement to detection of correct scm info when working on detached HEAD. Signed-off-by: Michele Calgaro --- debian/_buildscripts/local/build_module.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/debian/_buildscripts/local/build_module.sh b/debian/_buildscripts/local/build_module.sh index b037b7d09..f999da0eb 100755 --- a/debian/_buildscripts/local/build_module.sh +++ b/debian/_buildscripts/local/build_module.sh @@ -275,7 +275,10 @@ if [ "$bool_COPY_MOD_SRC" = "y" ]; then echo "# TDE SCM module information" > "$MOD_BUILD_PATH/.tdescminfo" echo "Name: $MOD_NAME" >> "$MOD_BUILD_PATH/.tdescminfo" cd "$MOD_GIT_PATH" - MOD_BRANCH=`git rev-parse --abbrev-ref HEAD | grep -v "no branch" | head -n1` + MOD_BRANCH=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` + if [[ -z "$MOD_BRANCH" ]]; then + MOD_BRANCH=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + fi COMMIT_HASH=`git rev-parse HEAD` echo "Revision: $MOD_BRANCH-$COMMIT_HASH" >> "$MOD_BUILD_PATH/.tdescminfo" git log -1 --pretty=format:"DateTime: %cd%n" --date=format:"%m/%d/%Y %H:%M" >> "$MOD_BUILD_PATH/.tdescminfo" @@ -310,7 +313,10 @@ if [ "$bool_EXTRADEP_MOD" != "y" -a "$bool_COPY_PKGING_FILES" = "y" ]; then # Default package name # Calculate package version cd $MOD_GIT_PATH - branch=`git rev-parse --abbrev-ref HEAD | egrep -v "no branch|detached" | head -n1` + branch=`git symbolic-ref -q HEAD | sed "s|^refs/heads/||"` + if [[ -z "$branch" ]]; then + branch=`git branch --contains HEAD | egrep -v "no branch|detached" | head -n1 | cut -c 3-` + fi target_tag=`git tag | grep -F "$TDE_RELEASE" | head -n1` tag=`git tag | \ sed "s|^\([^0-9]\)|\1.|" | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr -k 5,5nr | sed "s|^\([^0-9]\)\.|\1|" | \