From a323d1a41c3d9ce2259e3298203bcb07fc68bdf1 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Tue, 27 Apr 2021 16:56:13 +0200 Subject: OBS: latest: add commit to version for 2021q1 feed Move get_commit_version to common-obs.sh and call it in osmocom-latest-packages.sh, if the feed is not "latest". This way, the packages don't have the latest tag as version anymore, and the version changes if commits get pushed to the feed's branch. Related: SYS#5370 Change-Id: I4a4fa3b8f66652ef36a7fe62047a88a69c473f19 --- scripts/common-obs.sh | 29 +++++++++++++++++++++++++++++ scripts/osmocom-latest-packages.sh | 10 ++++++++-- scripts/osmocom-nightly-packages.sh | 31 +------------------------------ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/scripts/common-obs.sh b/scripts/common-obs.sh index a585e46..e7148bc 100644 --- a/scripts/common-obs.sh +++ b/scripts/common-obs.sh @@ -252,3 +252,32 @@ osmo_obs_git_version_gen() { ./git-version-gen . > .tarball-version 2>/dev/null fi } + +# 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. +osmo_obs_get_commit_version() { + local version="" + + 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,),,') + if [ -z "$version" ] || [ "$version" = "UNKNOWN" ]; then + version="$deb_version" + else + # add epoch from debian/changelog + case $deb_version in + *:*) + epoch=$(echo "$deb_version" | cut -d : -f 1) + version=$epoch:$version + ;; + esac + fi + + echo -n "$version" +} diff --git a/scripts/osmocom-latest-packages.sh b/scripts/osmocom-latest-packages.sh index 5ba5a7b..d942e9d 100755 --- a/scripts/osmocom-latest-packages.sh +++ b/scripts/osmocom-latest-packages.sh @@ -119,14 +119,20 @@ build() { echo "====> Building $project" cd "$TOP/$project" + osmo_obs_git_version_gen + if [ "$FEED" = "latest" ]; then debian_branch=$(get_last_tag "$project") else debian_branch="$FEED" + # Set new debian changelog version with commit appended. This version will + # become part of resulting filenames, and will change if commits have been + # added to the feed's branch. + VER="$(osmo_obs_get_commit_version)" + dch -b -v "$VER" -m "Snapshot build" + git commit -m "$VER snapshot" debian/ fi - osmo_obs_git_version_gen - osmo_obs_add_depend_deb "./debian/control" "$project" "osmocom-$FEED" if [ "$project" = "open5gs" ]; then diff --git a/scripts/osmocom-nightly-packages.sh b/scripts/osmocom-nightly-packages.sh index cee1382..ef2d7ef 100755 --- a/scripts/osmocom-nightly-packages.sh +++ b/scripts/osmocom-nightly-packages.sh @@ -53,35 +53,6 @@ get_last_tag() { 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() { - local version="" - - 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,),,') - if [ -z "$version" ] || [ "$version" = "UNKNOWN" ]; then - version="$deb_version" - else - # add epoch from debian/changelog - case $deb_version in - *:*) - epoch=$(echo "$deb_version" | cut -d : -f 1) - version=$epoch:$version - ;; - esac - fi - - echo -n "$version" -} - ### common checkout() { local name=$1 @@ -145,7 +116,7 @@ build() { 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" + VER="$(osmo_obs_get_commit_version).$DT" osmo_obs_add_depend_deb "./debian/control" "$name" "osmocom-$FEED" "$dependver" dch -b -v "$VER" -m "Snapshot build" git commit -m "$VER snapshot" debian/ -- cgit v1.2.3