Change in osmo-ci[master]: OBS: refactor git_version_gen related logic

osmith gerrit-no-reply at lists.osmocom.org
Wed Apr 28 16:11:34 UTC 2021


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/23953 )


Change subject: OBS: refactor git_version_gen related logic
......................................................................

OBS: refactor git_version_gen related logic

Move git_version_gen calls into an own function and add some of the
description from I76e3713f0b01a6110091ff90e8e53aa79533c374 where this
code was added.

Don't call it inside get_commit_version anymore, but call it before.
Don't try to cat the resulting .tarball-version there if it doesn't
exist.

Related: SYS#5370
Change-Id: I9a1b6ae4b4311abb77dc6390733c5e330e3d489e
---
M scripts/common-obs.sh
M scripts/osmocom-latest-packages.sh
M scripts/osmocom-nightly-packages.sh
3 files changed, 21 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/53/23953/1

diff --git a/scripts/common-obs.sh b/scripts/common-obs.sh
index 156dfba..a585e46 100644
--- a/scripts/common-obs.sh
+++ b/scripts/common-obs.sh
@@ -243,3 +243,12 @@
 	git commit -m "auto-commit: apply $patch" debian/
 	cd ..
 }
+
+# Run git-version-gen inside Osmocom repositories, so the .tarball-version
+# becomes part of the source repository. Usually this would be done with
+# "make dist", but we use git-buildpackage instead.
+osmo_obs_git_version_gen() {
+	if [ -x ./git-version-gen ]; then
+		./git-version-gen . > .tarball-version 2>/dev/null
+	fi
+}
diff --git a/scripts/osmocom-latest-packages.sh b/scripts/osmocom-latest-packages.sh
index c530f27..a0bac45 100755
--- a/scripts/osmocom-latest-packages.sh
+++ b/scripts/osmocom-latest-packages.sh
@@ -122,9 +122,7 @@
     debian_branch="$FEED"
   fi
 
-  if [ -x ./git-version-gen ]; then
-    ./git-version-gen . > .tarball-version 2>/dev/null
-  fi
+  osmo_obs_git_version_gen
 
   osmo_obs_add_depend_deb "./debian/control" "$project" "osmocom-$FEED"
 
diff --git a/scripts/osmocom-nightly-packages.sh b/scripts/osmocom-nightly-packages.sh
index ea69b94..07b0c81 100755
--- a/scripts/osmocom-nightly-packages.sh
+++ b/scripts/osmocom-nightly-packages.sh
@@ -53,15 +53,18 @@
   echo "${VER}"
 }
 
+# Return a version based on the latest tag and commit (e.g. "1.5.1.93.47cc")
+# or fall back to the last debian version with current date appended
+# (e.g. "2.2.6.202104270126"). Run osmo_obs_git_version_gen before.
+# $PWD must be inside a git repository.
 get_commit_version() {
-  # return a version based on the commit
-  local version
+  local version=""
 
-  # determine git version *and generate the .tarball-version file*
-  test -x ./git-version-gen && ./git-version-gen . > .tarball-version 2>/dev/null
-  version=$(cat .tarball-version)
-  # debian doesn't allow '-' in version.
-  version=$(echo "$version" | sed  's/-/./g' )
+  if [ -e ".tarball-version" ]; then
+    version=$(cat .tarball-version)
+    # debian doesn't allow '-' in version.
+    version=$(echo "$version" | sed  's/-/./g' )
+  fi
 
   # deb version
   deb_version=$(head -1 debian/changelog | cut -d ' ' -f 2 | sed 's,(,,'  | sed 's,),,')
@@ -139,6 +142,7 @@
   cd "$repodir"
 
   if [ "$changelog" = "commit" ] ; then
+    osmo_obs_git_version_gen
     # Add date to increase version even if commit did not change (OS#5135)
     VER="$(get_commit_version).$DT"
     osmo_obs_add_depend_deb "./debian/control" "$name" "osmocom-$FEED" "$dependver"

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/23953
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ci
Gerrit-Branch: master
Gerrit-Change-Id: I9a1b6ae4b4311abb77dc6390733c5e330e3d489e
Gerrit-Change-Number: 23953
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210428/797cab6d/attachment.htm>


More information about the gerrit-log mailing list