]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rework automatic build versioning 758/head
authorChristian Hofstaedtler <christian@hofstaedtler.name>
Mon, 29 Apr 2013 22:58:16 +0000 (00:58 +0200)
committerChristian Hofstaedtler <christian@hofstaedtler.name>
Tue, 30 Apr 2013 08:00:02 +0000 (10:00 +0200)
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.

build-scripts/jenkins-driver [new file with mode: 0755]
build-scripts/make-jenkins-version
build-scripts/set-version-auth
build-scripts/set-version-recursor

diff --git a/build-scripts/jenkins-driver b/build-scripts/jenkins-driver
new file mode 100755 (executable)
index 0000000..c2cf41e
--- /dev/null
@@ -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
index 6b01b031342044a9a56bec60f4e26460f8942a81..d55ae906e73915dd6fd30e13fac985d345eedb23 100755 (executable)
@@ -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
index 1ea0df6a4c1c04383ba5216e2567e6adf0e48fbb..4786ce767ad918279808d1bb7cd83258d221e5cb 100755 (executable)
@@ -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
index 2105cc6cb463b4de6ba584bd19cb98cae58e31fe..358754016d11e14f6244e4326fa2c0e884f66b34 100755 (executable)
@@ -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