Browse Source

New script increase-version-number to raise version number for usage in a new snapshot number.

Build-Depend on shunit2 since an according test script
verifies that all supported version numbers work as
intended.

generate-svn-snapshot has been adapted to use
increase-version-number accordingly.
merge-requests/109/head
Michael Prokop 11 years ago
parent
commit
158ad0b938
  1. 6
      Makefile
  2. 3
      README.org
  3. 2
      debian/control
  4. 37
      generate-svn-snapshot
  5. 42
      increase-version-number
  6. 17
      tests/increase-version-number

6
Makefile

@ -1,9 +1,9 @@
PREFIX := /usr
PROGRAMS := build-and-provide-package generate-git-snapshot generate-local-repository generate-reprepro-codename generate-svn-snapshot
PROGRAMS := build-and-provide-package generate-git-snapshot generate-local-repository generate-reprepro-codename generate-svn-snapshot increase-version-number
build:
@echo nothing to do
tests/increase-version-number
install: $(scripts)
mkdir -p $(DESTDIR)/$(PREFIX)/bin/
@ -11,4 +11,4 @@ install: $(scripts)
install -m 0755 $$prog $(DESTDIR)/$(PREFIX)/bin; \
done
.PHONY: install
.PHONY: build install

3
README.org

@ -102,6 +102,9 @@ Under "/Post-build Actions/" select "/Archive the artifacts/" using:
+ *generate-svn-snapshot*: generates snapshot version of a Debian package using svn log, svn2cl and some dirty shell magic.
+ *increase-version-number*: takes a version number as commandline argument and raises the version number for usage as new snapshot
version. It does not append any special characters, so you can use it with your own suffix and build numbers.
* Known TODOs
+ Make configuration more flexible (key id, repository path,

2
debian/control

@ -2,7 +2,7 @@ Source: jenkins-debian-glue
Section: admin
Priority: extra
Maintainer: Michael Prokop <mika@debian.org>
Build-Depends: debhelper (>= 8.0.0)
Build-Depends: debhelper (>= 8.0.0), shunit2
Standards-Version: 3.9.2
Homepage: https://github.com/mika/jenkins-debian-glue
Vcs-Git: git://github.com/mika/jenkins-debian-glue.git

37
generate-svn-snapshot

@ -50,41 +50,8 @@ PACKAGE=$(dpkg-parsechangelog --count 1 | awk '/^Source: / {print $2}')
# get newest version number from changelog
PREVIOUS_VERSION=$(dpkg-parsechangelog --count 1 | awk '/^Version: / {print $2}')
## calculate new snapshot version (ugly but a start)
# remove Debian parts of version number (-1*, ~1*)
BASE_VERSION=$(echo ${PREVIOUS_VERSION} | sed 's/\(-.*\)\|\(~.*\)$//')
# if a Debian version is present, then use '-1' inside snapshot version
DEBIAN_VERSION=''
if echo $PREVIOUS_VERSION | grep -q -- '-' ; then
DEBIAN_VERSION='-1'
fi
# make sure single digit version numbers (2 -> 2.1) are handled
if ! echo "$PREVIOUS_VERSION" | grep -q -- '\.' ; then
FIRST_PART="$PREVIOUS_VERSION"
LAST_PART=""
else
# first part of version number (0.9.2 -> 0.9)
FIRST_PART=$(echo $BASE_VERSION | sed 's/\(\.[0-9]*\)$//')
# last digit(s) of version number (0.9.2 -> 2)
LAST_PART=$(echo $BASE_VERSION | sed 's/.*\.\([0-9]*\)$/\1/')
fi
# raise version number (2 -> 3)
if echo "$LAST_PART" | grep -q -- '^0' ; then
# digit starts with leading zero (as in 2008.01.02), so prepend it
RAISE_VERSION="0$((LAST_PART + 1))"
else
RAISE_VERSION=$((LAST_PART + 1))
fi
# concat first part and raised version number (0.9.3)
INCR_VERSION="${FIRST_PART}.${RAISE_VERSION}"
# final snapshot version
SNAPSHOT_VERSION="${INCR_VERSION}${DEBIAN_VERSION}~${BUILD_NUMBER}.svn${SINCE_REVISION}"
# calculate new snapshot version
SNAPSHOT_VERSION="$(increase-version-number "$PREVIOUS_VERSION")~${BUILD_NUMBER}.svn${SINCE_REVISION}"
## generate changelog
SVN_CHANGELOG=$(mktemp)

42
increase-version-number

@ -0,0 +1,42 @@
#!/bin/sh
set -u
if [ "$#" -lt 1 ] ; then
echo "Usage: $0 <version_number>" >&2
exit 1
fi
PREVIOUS_VERSION="$1"
# remove Debian parts of version number (-1*, ~1*)
BASE_VERSION=$(echo ${PREVIOUS_VERSION} | sed 's/\(-.*\)\|\(~.*\)$//')
# if a Debian version is present, then use '-1' inside snapshot version
DEBIAN_VERSION=''
if echo $PREVIOUS_VERSION | grep -q -- '-' ; then
DEBIAN_VERSION='-1'
fi
if ! echo "$PREVIOUS_VERSION" | grep -q -- '\.' ; then
FIRST_PART="$PREVIOUS_VERSION"
LAST_PART=""
else
# first part of version number (0.9.2 -> 0.9)
FIRST_PART=$(echo $BASE_VERSION | sed 's/\(\.[0-9]*\)$//')
# last digit(s) of version number (0.9.2 -> 2)
LAST_PART=$(echo $BASE_VERSION | sed 's/.*\.\([0-9]*\)$/\1/')
fi
# raise version number (2 -> 3)
if echo "$LAST_PART" | grep -q -- '^0' ; then
RAISE_VERSION="0$((LAST_PART + 1))"
else
RAISE_VERSION=$((LAST_PART + 1))
fi
# concat first part and raised version number (0.9.3)
INCR_VERSION="${FIRST_PART}.${RAISE_VERSION}"
echo "${INCR_VERSION}${DEBIAN_VERSION}"

17
tests/increase-version-number

@ -0,0 +1,17 @@
#!/bin/sh
SCRIPT=./increase-version-number
testEquality()
{
assertEquals "$($SCRIPT 0.23)" 0.24
assertEquals "$($SCRIPT 23)" 23.1
assertEquals "$($SCRIPT 0.23-1)" 0.24-1
assertEquals "$($SCRIPT 0.1.23-1)" 0.1.24-1
assertEquals "$($SCRIPT 0.1.23-3)" 0.1.24-1
assertEquals "$($SCRIPT 1:0.42-2)" 1:0.43-1
assertEquals "$($SCRIPT 2008.01.02)" 2008.01.03
assertEquals "$($SCRIPT 0.42~2)" 0.43
}
. /usr/share/shunit2/shunit2
Loading…
Cancel
Save