#!/bin/bash
DISTRIBUTION=$1
-VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[") # TODO: check for valid version?
+VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[")
SCRIPTNAME=${0##*/}
VALID_DISTROS=("unstable" "wheezy" "squeeze")
function cleanup {
echo cleaning up ...
-
# revert changelog changes
git checkout -- debian/changelog
-
# remove files created by debian build
git clean -fd debian
-
echo cleaup done
}
-function failIfFailed
-{
- echo executing: \'$@\' ...
- $@
- RET_CODE=$?
- if [[ "${RET_CODE}" != "0" ]]
- then
- echo command \'$@\' failed
- cleanup
- exit 4
-
- fi
- echo done
-}
-
-function usage
-{
- echo 'Usage:' ${SCRIPTNAME} '<DISTRIBUTION>'
- exit $1
-}
-
function validateInput
{
- if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ;
- then
+ if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then
echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS"
- usage 1
+ exit 1
+ fi
+
+ if [ "$DISTRIBUTION" = "experimental" ] ; then
+ # TODO
+ echo TODO set DISTRIBUTION correctly
fi
if [[ -z "${VERSION}" ]]
then
echo "Need to specify version"
- usage 2
+ exit 1
fi
-
+ # TODO: we need to do better
+ VERSION=$(echo $VERSION | sed -s "s#SNAP#0SNAP#g")
+ echo "=================================="
+ echo $VERSION
+ echo "=================================="
}
-function goUp
-{
- cd ..
-}
-
-goUp
-
+#############
+# MAIN
+#############
+cd $WORKSPACE
validateInput
+set -e # fail on error
+set -x # echo commands executed
# change version in changelog
-# TODO: fix comment
-failIfFailed dch -D${DISTRIBUTION} -v ${VERSION} "dummy comment"
+git-dch -a --ignore-branch --new-version=${VERSION}
+# we now what we're doing and we don't want an editor.….
+echo | EDITOR=true dch -D ${DISTRIBUTION} -r --no-force-save-on-release -b
+#build debian package (just binary, no sources)
+dpkg-buildpackage -us -uc -b
-#build debian package
-failIfFailed dpkg-buildpackage -us -uc
+# push back to git repo
+if [ "$GIT_BRANCH_NAME" = "master" ] ; then
+ # TODO: git commit
+ # TODO: git tag
+ # TODO: git push
+fi
# upload to reprepro
# TODO: implement
+# show the changelog
+dpkg-parsechangelog
+
+set +x
cleanup
+#TODO: remove this debug output
+export