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

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Thu Apr 29 14:08:41 UTC 2021


osmith has submitted this change. ( 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, 20 insertions(+), 10 deletions(-)

Approvals:
  osmith: Verified
  laforge: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



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 301c6c6..5ba5a7b 100755
--- a/scripts/osmocom-latest-packages.sh
+++ b/scripts/osmocom-latest-packages.sh
@@ -125,9 +125,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 4fe0104..cee1382 100755
--- a/scripts/osmocom-nightly-packages.sh
+++ b/scripts/osmocom-nightly-packages.sh
@@ -53,15 +53,17 @@
   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 (e.g. "2.2.6").
+# 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,),,')
@@ -141,6 +143,7 @@
   cd "$repodir"
 
   if [ "$changelog" != "no_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: 4
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210429/7ea9f519/attachment.htm>


More information about the gerrit-log mailing list