Browse Source

generate-git-snapshot: use plain dch if handling UNRELEASED version

We can't use git-dch's auto mode if we've to deal with
a distribution being set to UNRELEASED because that fails
with:

| + git-dch --auto -S --multimaint-merge --ignore-branch --new-version=1.16.9~1343298526.109
| Changelog last touched at '6293f12440f48c1e245033801f151e4c99114db7'
| Continuing from commit '6293f12440f48c1e245033801f151e4c99114db7'
| No changes detected from 6293f12440 to HEAD.
| dch: fatal error at line 984:
| New version specified (1.16.9~1343298526.109) is less than
| the current version number (1.16.9)!  Use -b to force.
|  dch --no-auto-nmu  --distribution=UNRELEASED --newversion=1.16.9~1343298526.109 --multimaint-merge -- "UNRELEASED" returned 25
| Couldn't run ' dch --no-auto-nmu  --distribution=UNRELEASED --newversion=1.16.9~1343298526.109 --multimaint-merge -- "UNRELEASED"'

So instead run dch with custom command line to get a
version number being smaller than the one that will be
released later on.
tags/v0.1.1
Michael Prokop 9 years ago
parent
commit
644aef6e84
1 changed files with 23 additions and 13 deletions
  1. +23
    -13
      scripts/generate-git-snapshot

+ 23
- 13
scripts/generate-git-snapshot View File

@@ -27,27 +27,29 @@ if [ -n "${JENKINS_DEBIAN_GLUE_VERSION:-}" ] ; then
echo "*** Running jenkins-debian-glue version $JENKINS_DEBIAN_GLUE_VERSION ***"
fi

# we want to get a version string like
# $ORIG_VERSION+0~$TIMESTAMP.$BUILD_NUMBER~1.$GIT_ID
# so the version is always increasing over time, no matter what
TIMESTAMP="$(date +%s)" # seconds since 1970-01-01 00:00:00 UTC, reversible via `date -d @$TIMESTAMP`
BUILD_VERSION="${TIMESTAMP}.${BUILD_NUMBER}" # git-dch appends something like ~1.gbp5f433e then

echo "*** source package build phase ***"
rm -f ./* || true

cd source

# version number
# retrieve and adjust information
ORIG_VERSION=$(dpkg-parsechangelog --count 1 | awk '/Version/ {print $2}')

# we do NOT raise the version number, if we detect an unreleased version
INCREASED_VERSION=$(increase-version-number $ORIG_VERSION)
DISTRIBUTION=$(dpkg-parsechangelog --count 1 | awk '/^Distribution/ {print $2}')
if [ "$DISTRIBUTION" = "UNRELEASED" ] ; then

# we want to get a version string like
# $ORIG_VERSION+0~$TIMESTAMP.$BUILD_NUMBER~1.$GIT_ID
# so the version is always increasing over time, no matter what
TIMESTAMP="$(date +%s)" # seconds since 1970-01-01 00:00:00 UTC, reversible via `date -d @$TIMESTAMP`
BUILD_VERSION="${TIMESTAMP}.${BUILD_NUMBER}" # git-dch appends something like ~1.gbp5f433e then

# we do NOT raise the version number, if we detect an unreleased version,
# otherwise the released version would be older than our snapshot builds
APPLY_VERSION_WORKAROUND=false
if [ "$DISTRIBUTION" = "UNRELEASED" ] && dpkg --compare-versions "$ORIG_VERSION" lt "$INCREASED_VERSION" ; then
echo "*** Not increasing version number as distribution is set to UNRELEASED ***"
INCREASED_VERSION="$ORIG_VERSION"
else
INCREASED_VERSION=$(increase-version-number $ORIG_VERSION)
APPLY_VERSION_WORKAROUND=true
fi

VERSION_STRING="${INCREASED_VERSION}~${BUILD_VERSION}"
@@ -57,6 +59,8 @@ if [ -n "${distribution:-}" ] ; then
VERSION_STRING="${VERSION_STRING}+${distribution}"
fi

echo "*** Version string set to $VERSION_STRING ***"

# support overriding git-dch options
if [ -n "${DCH_OPTS:-}" ] ; then
echo "Found environment variable DCH_OPTS, set to ${DCH_OPTS}"
@@ -87,7 +91,13 @@ create_local_branch() {
}

git_dch_auto() {
git-dch --auto $DCH_OPTS $DCH_EXTRA_OPTS
if $APPLY_VERSION_WORKAROUND ; then
echo "Applying version workaround workaround"
dch -b --distribution=UNRELEASED --newversion=$VERSION_STRING -- \
"SNAPSHOT autobuild for unreleased $ORIG_VERSION via jenkins-debian-glue."
else
git-dch --auto $DCH_OPTS $DCH_EXTRA_OPTS
fi
}

identify_latest_change() {


Loading…
Cancel
Save