From 9c07b93acf232dc4e351ba071fac44886e9e8b3d Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Wed, 24 Jul 2013 17:27:00 +0200 Subject: [PATCH] create debian/changelog correctly, handle master branch differently. create proper debianized version of SNAPSHOTs --- debian_wrap_maven_results.sh | 64 +++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/debian_wrap_maven_results.sh b/debian_wrap_maven_results.sh index 3b48a9c..6e7d71a 100755 --- a/debian_wrap_maven_results.sh +++ b/debian_wrap_maven_results.sh @@ -1,8 +1,8 @@ #!/bin/bash DISTRIBUTION=$1 -VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[") +VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[") VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \ - "production-proposed-updates" "pre-staging" "staging" "experimental") + "production-proposed-updates" "pre-staging" "staging") SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration") function containsElement () { @@ -33,34 +33,39 @@ function cleanup { function validateInput { + APPEND_TO_VERSION = "" + + if [[ -z "${VERSION}" ]] ; then + echo "ERROR: Cannot get version from maven using 'mvn -B -N help:evaluate -Dexpression=project.version'" + mvn -B -N help:evaluate -Dexpression=project.version + exit 1 + fi + if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then if [ "$GIT_BRANCH_NAME" = "integration" ] ; then - DISTRIBUTION="unstable" + DISTRIBUTION="dev-integration" else - DISTRIBUTION="experimental" + # set proper DISTRIBUTION for feature branches + DISTRIBUTION= $(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-') fi - fi - - if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then + APPEND_TO_VERSION = "experimental" + elif ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS" exit 1 + if [ "$DISTRIBUTION" = "unstable" ] || [ "$DISTRIBUTION" = "pre-staging" ] ; + APPEND_TO_VERSION = "develop" + fi fi - if [ "$DISTRIBUTION" = "experimental" ] ; then - # set proper DISTRIBUTION for feature branches - DISTRIBUTION= $(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-') - fi - - if [[ -z "${VERSION}" ]] ; then - echo "Need to specify version" - exit 1 + if [ ! -z "$APPEND_TO_VERSION" ] ; then + # remove -SNAPSHOT + VERSION=$(echo $VERSION | sed -s "s#-SNAPSHOT##g") + BUILD_START=$(date +%Y%m%d%H%M%S) + VERSION="${VERSION}~${APPEND_TO_VERSION}${BUILD_START}+{BUILD_NUMBER}+g${GIT_COMMIT:0:7}" + echo "==================================" + echo $VERSION + echo "==================================" fi - - # TODO: we need to do better - VERSION=$(echo $VERSION | sed -s "s#SNAP#0SNAP#g") - echo "==================================" - echo $VERSION - echo "==================================" } ############# @@ -71,12 +76,17 @@ validateInput set -e # fail on error set -x # echo commands executed -# change version in changelog -git-dch -a --ignore-branch --no-full --no-meta --id-length=7 -# replace first version (enclosed in brackets) with real version -sed -i "0,/(.*)/s//($VERSION)/" debian/changelog -# replace first UNRELEASED with $DISTRIBUTION -sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog +if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then + git-dch -a --ignore-branch --no-full --no-meta --id-length=7 -N $VERSION + sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog +else + # change version in changelog + git-dch -a --ignore-branch --no-full --no-meta --id-length=7 + # replace first version (enclosed in brackets) with real version + sed -i "0,/(.*)/s//($VERSION)/" debian/changelog + # replace first UNRELEASED with $DISTRIBUTION + sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog +fi # build debian package (just binary, no source package) dpkg-buildpackage -us -uc -b -- 2.39.5