Skip to content
Snippets Groups Projects
Commit 180534e5 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

Added the new getDebianBuildVersion script and use it inside...

Added the new getDebianBuildVersion script and use it inside make_debian_package.sh.in to obtain the version
IMPORTANT: Projects importing this commit must edit the (newly created) DebianPackaging.config file!
parent 2fb926a1
No related branches found
No related tags found
No related merge requests found
########################################################################################
# Project-specific configuration for the Debian packaging scripts #
# #
# Please modify this file for your needs by copying a line, uncommenting it and then #
# modifying the uncommented copy. Keep the commented original copy to avoid conflicts! #
########################################################################################
# URI of the git repository containing the build version numbers
#DEBIAN_BUILD_VERSIONS_REPO=git@github.com:ChimeraTK/DebianBuildVersions.git
########################################################################################
# NO USER CONFIGURATION BELOW THIS POINT! DO NOT MODIFY OUTSIDE THE project-template #
########################################################################################
ERROR_MESSAGE="DebianPackaging.config is not properly updated for this package!"
if [ -z "$DEBIAN_BUILD_VERSIONS_REPO" ]; then
echo ${ERROR_MESSAGE}
exit 1
fi
unset ERROR_MESSAGE
#!/bin/bash
# obtain configuration
source "$(dirname \"$0\")/DebianPackaging.config"
# check minimum number of command line parameters
if [ $# -lt 3 ]; then
echo "Usage:"
echo "./getDebianBuildVersion <PACKAGE_NAME> <PACKAGE_VERSION> <DEBIAN_CODENAME> [<DEPENDENCY1_NAME_WITH_VERSION>] [<DEPENDENCY2_NAME_WITH_VERSION>] [...]"
echo ""
echo "Example:"
echo "./getDebianBuildVersion DeviceAccess-DoocsBackend 0.1 xenial DeviceAccess-0.14 DOOCS-18.10.5 DoocsServerTestHelper-0.1"
echo ""
echo "Important note:"
echo "If you change the order of dependencies passed to this script, the build version will be unnecessarily increased!"
exit 1
fi
# parse mandatory command line parameters
PACKAGE_NAME="$1"
PACKAGE_VERSION="$2"
DEBIAN_CODENAME="$3"
shift ; shift ; shift
# build sub-directory name for dependency versions (will start and end with a /)
DEPENDENCY_STRING="/"
while (( "$#" )); do
DEPENDENCY_STRING="${DEPENDENCY_STRING}${1}/"
shift
done
# output information extracted from command line:
echo "PACKAGE_NAME=${PACKAGE_NAME}" >&2
echo "PACKAGE_VERSION=${PACKAGE_VERSION}" >&2
echo "DEBIAN_CODENAME=${DEBIAN_CODENAME}" >&2
echo "DEPENDENCY_STRING=${DEPENDENCY_STRING}" >&2
# create temporary directory for checking out the DebianBuildVersions repository and modifying it
WDIR=`mktemp --tmpdir -d DebianBuildVersions.XXXXXXXX`
echo Temporary directory to work in: $WDIR >&2
echo Git repository containing the build versions: $DEBIAN_BUILD_VERSIONS_REPO >&2
# check out the DebianBuildVersions repository
cd $WDIR || exit 1
git clone "$DEBIAN_BUILD_VERSIONS_REPO" . >&2 || exit 1
# go to the directory for the specific package version and debian codename (create it if not yet existing)
mkdir -p "${PACKAGE_NAME}/${PACKAGE_VERSION}/${DEBIAN_CODENAME}"
cd "${PACKAGE_NAME}/${PACKAGE_VERSION}/${DEBIAN_CODENAME}"
# if LATEST_BUILD file is not there, this is the first build of this package version on this debian codename
if [ ! -f "LATEST_BUILD" ]; then
echo "The package ${PACKAGE_NAME} in version ${PACKAGE_VERSION} has never been build on ${DEBIAN_CODENAME} before." >&2
# start with build number 1 and create the necessary control structure
BUILD_NUMBER=1
echo ".${DEPENDENCY_STRING}BUILD_NUMBER" > LATEST_BUILD
mkdir -p ".${DEPENDENCY_STRING}"
echo ${BUILD_NUMBER} > ".${DEPENDENCY_STRING}BUILD_NUMBER"
else
# if the file BUILD_NUMBER exists in the dependency sub-directory, this is a patch build and we re-use the build number
if [ -f ".${DEPENDENCY_STRING}BUILD_NUMBER" ]; then
echo "The package ${PACKAGE_NAME} in version ${PACKAGE_VERSION} has been build on ${DEBIAN_CODENAME} before against the SAME dependency versions." >&2
BUILD_NUMBER=`cat ".${DEPENDENCY_STRING}BUILD_NUMBER"`
else
# no build number has been assigned yet, so we have to increase the build number from the latest build
echo "The package ${PACKAGE_NAME} in version ${PACKAGE_VERSION} has been build on ${DEBIAN_CODENAME} before against DIFFERENT dependency versions." >&2
BUILD_NUMBER=$(( `cat $(cat LATEST_BUILD)` + 1 ))
echo ".${DEPENDENCY_STRING}BUILD_NUMBER" > LATEST_BUILD
mkdir -p ".${DEPENDENCY_STRING}"
echo ${BUILD_NUMBER} > ".${DEPENDENCY_STRING}BUILD_NUMBER"
fi
fi
# commit the changes to the repository
git add -A . >&2 || exit 1
git commit -m "Update by getDebianBuildVersion: ${PACKAGE_NAME}/${PACKAGE_VERSION}/${DEBIAN_CODENAME}${DEPENDENCY_STRING} -> ${BUILD_NUMBER}" >&2
git push >&2 || exit 1
# output the build number to stderr in human readable form and to stdout in plain form for further script processing
echo Build number: ${BUILD_NUMBER} >&2
echo ${BUILD_NUMBER}
rm -rf $WDIR
......@@ -15,12 +15,9 @@
#######################################################################################################################
# This cmake.in file requires the following variables to be set:
# PACKAGE_BUILDVERSION_ENVIRONMENT_VARIABLE_NAME Environment variable which contains the build version.
# Must not contain any hyphens.
# PACKAGE_BASE_NAME This is the debian package name, not the project name (e.g. libraries must start with lib,
# all lover case, no underscore)
# all lower case, no underscore)
# PACKAGE_FULL_LIBRARY_VERSION The full version, incl. build version and patch version
# PACKAGE_GIT_URI The URI where to check out the source code
# PACKAGE_TAG_VERSION The tag for which the package is build
# PACKAGE_MESSAGE The message for the debian package log
......@@ -59,11 +56,14 @@ cd ${BUILD_DIR_NAME}
#The package versions for doocs / Ubuntu contain the codename of the distribution. Get it from the system.
CODENAME=`lsb_release -c | sed "{s/Codename:\s*//}"`
#Obtain build version
BUILD_VERSION=`"$(dirname \"$0\")/getDebianBuildVersion"` || exit 1
#Before building the package we will update the changelog. This is easier from a shell script
#because debchange does the right format and the current date, user name and email automatically for us.
#Use the NAME and EMAIL environment variables to get correct values if needed (usually the email is
# user@host instead of first.last@institute, for instance killenb@mskpcx18571.desy.de instead of martin.killenberg@desy.de).
debchange --create --package @PACKAGE_BASE_NAME@ -v @PACKAGE_FULL_LIBRARY_VERSION@-${@PACKAGE_BUILDVERSION_ENVIRONMENT_VARIABLE_NAME@} --distribution ${CODENAME} @PACKAGE_MESSAGE@
debchange --create --package @PACKAGE_BASE_NAME@ -v @PACKAGE_FULL_LIBRARY_VERSION@-${BUILD_VERSION} --distribution ${CODENAME} @PACKAGE_MESSAGE@
#Now everything is prepared and we can actually build the package.
#If you have a gpg signature you can remove the -us and -uc flags and sign the package.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment