From: Christian Hofstaedtler Date: Mon, 29 Apr 2013 22:58:16 +0000 (+0200) Subject: rework automatic build versioning X-Git-Tag: auth-3.3-rc1~141^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2acb912d184b863a2fec4d12a1e736a81970c851;p=thirdparty%2Fpdns.git rework automatic build versioning Only release or preview builds now receive the designated version as their identifier. Others are now known as 'git-something', or, for debs/rpms '0.0-something' (or similar). A new jenkins-driver script is included that moves actually setting the versions out of the jenkins configuration. Extending this script to drive the complete build is left for the future. --- diff --git a/build-scripts/jenkins-driver b/build-scripts/jenkins-driver new file mode 100755 index 0000000000..c2cf41ef56 --- /dev/null +++ b/build-scripts/jenkins-driver @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if [ "${PDNS_TAG}" != 'HEAD' ] +then + git checkout $PDNS_TAG + export GIT_BRANCH=unknown + export GIT_COMMIT=$(git rev-parse $PDNS_TAG) +fi + +eval $(build-scripts/make-jenkins-version) + +build-scripts/set-version-auth $SOURCE_VERSION $DEB_VERSION $RPM_VERSION +build-scripts/set-version-recursor $SOURCE_VERSION $DEB_VERSION $RPM_VERSION diff --git a/build-scripts/make-jenkins-version b/build-scripts/make-jenkins-version index 6b01b03134..d55ae906e7 100755 --- a/build-scripts/make-jenkins-version +++ b/build-scripts/make-jenkins-version @@ -1,9 +1,69 @@ -#!/bin/sh -GIT_BRANCH=$(echo ${GIT_BRANCH} | sed 's!^origin/!!') +#!/usr/bin/env bash + +# input variables: +# GIT_BRANCH +# GIT_COMMIT +# BUILD_NUMBER +# BUILDING_PRODUCT (ex: "rec" or "auth") + +# eat origin/ off branch name +GIT_BRANCH=${GIT_BRANCH#origin/} +date=$(date +%Y%m%d) +git_id=$(git rev-parse --short $GIT_COMMIT) +source_branch="$(echo ${GIT_BRANCH} | tr ' /' -)" +deb_branch="$(echo ${GIT_BRANCH} | tr ' /-' .)" +rpm_branch="$(echo ${GIT_BRANCH} | tr ' /-' _)" +# dbg: date, build, gitid +source_dbg=${date}-${BUILD_NUMBER}-${git_id} +deb_dbg=${date}.${BUILD_NUMBER}.${git_id} +rpm_dbg=${date}_${BUILD_NUMBER}_${git_id} + +is_release_build=0 + if [ $GIT_BRANCH = master ] then - echo $(date +%Y%m%d).${BUILD_NUMBER}.$(git rev-parse --short $GIT_COMMIT) + source_version=git-${source_dbg} + deb_version=0.0.${deb_dbg} + rpm_version=0.0.${rpm_dbg} +elif [[ $GIT_BRANCH = rel/* ]] +then + # on release branch + product_version=${GIT_BRANCH#rel/} + product=${product_version%-*} # ex: "rec" or "auth" + version=${product_version#*-} # ex: "3.5.1" + if [ "$product" = "$BUILDING_PRODUCT" ] + then + expected_tag=${product}-${version} # ex: "rec-3.5.1" + git_tag=$(git describe --match "${expected_tag}*" 2>/dev/null) + if [ -z "$git_tag" ] + then + # snapshot build: + # prepend the target product version. + source_version=${version}-snapshot-${date}-${BUILD_NUMBER}-${git_id} + deb_version=${version}~snapshot${date}.${BUILD_NUMBER}.${git_id} + rpm_version=${version}snapshot${date}_${BUILD_NUMBER}_${git_id} + else + # rcX or release build: + # use the tag as the real version number. + source_version=${git_tag#${product}-} + deb_version=${source_version} + rpm_version="$(echo ${source_version} | sed -e 's/-//' )" + is_release_build=1 + fi + else + # building auth on recursor release branch, or v.v. + source_version=git-unknown-${source_dbg} + deb_version=0.0~unknown.${deb_dbg} + rpm_version=0.0unknown_${rpm_dbg} + fi else - branch="$(echo ${GIT_BRANCH} | tr ' /-' _)" - echo $(date +%Y%m%d).${branch}_${BUILD_NUMBER}.$(git rev-parse --short $GIT_COMMIT) + # must be a test branch + source_version=git-${source_branch}-${source_dbg} + deb_version=0.0~${deb_branch}.${deb_dbg} + rpm_version=0.0.${rpm_branch}_${rpm_dbg} fi + +echo SOURCE_VERSION=$source_version +echo DEB_VERSION=$deb_version +echo RPM_VERSION=$rpm_version +echo IS_RELEASE_BUILD=$is_release_build diff --git a/build-scripts/set-version-auth b/build-scripts/set-version-auth index 1ea0df6a4c..4786ce767a 100755 --- a/build-scripts/set-version-auth +++ b/build-scripts/set-version-auth @@ -1,7 +1,9 @@ #!/bin/bash VERSION=$1 -[ -z "$VERSION" ] && exit +DEB_VERSION=$2 +RPM_VERSION=$3 +[ -z "$VERSION" -o -z "$DEB_VERSION" -o -z "$RPM_VERSION" ] && exit 1 -ssed -r "s/Version: (.*)/Version: \\1.$VERSION/" -i pdns.spec -ssed -r "s/AC_INIT\\(\\[pdns\\],\\[(.*)\\]\\)/AC_INIT\([pdns],[\\1.$VERSION\])/" -i configure.ac -ssed -r "1 s/^pdns \\(([^)]*)-([0-9.])\\)/pdns \\(\\1.$VERSION-\\2\\)/" -i debian-pdns/changelog +ssed -r "s/Version: (.*)/Version: $RPM_VERSION/" -i pdns.spec +ssed -r "s/AC_INIT\\(\\[pdns\\],\\[(.*)\\]\\)/AC_INIT\([pdns],[$VERSION\])/" -i configure.ac +ssed -r "1 s/^pdns \\(([^)]*)-([0-9.])\\)/pdns \\($DEB_VERSION-\\2\\)/" -i debian-pdns/changelog diff --git a/build-scripts/set-version-recursor b/build-scripts/set-version-recursor index 2105cc6cb4..358754016d 100755 --- a/build-scripts/set-version-recursor +++ b/build-scripts/set-version-recursor @@ -1,6 +1,8 @@ -#!/bin/bash +#!/bin/bash VERSION=$1 -[ -z "$VERSION" ] && exit +DEB_VERSION=$2 +RPM_VERSION=$3 +[ -z "$VERSION" -o -z "$DEB_VERSION" -o -z "$RPM_VERSION" ] && exit 1 -ssed -r "s/^VERSION=(.*)/VERSION=\\1.$VERSION/" -i pdns/dist-recursor -ssed -r "s/Version: (.*)/Version: \\1.$VERSION/" -i pdns/pdns-recursor.spec +ssed -r "s/^VERSION=(.*)/VERSION=$VERSION/" -i pdns/dist-recursor +ssed -r "s/Version: (.*)/Version: $RPM_VERSION/" -i pdns/pdns-recursor.spec