]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
extract_storage: change build number naming scheme for feature branch
authorDongsu Park <dongsu.park@profitbricks.com>
Thu, 18 Apr 2013 11:38:58 +0000 (13:38 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Mon, 22 Apr 2013 10:32:46 +0000 (12:32 +0200)
This is only a temporary solution to resolve build number conflicts
on Gentoo systems. Without the change, it's nearly impossible to manage
different ebuilds for both master/develop branches and feature branches.
For the example above, new ebuilds for feature branch (build no. 150)
should be recognized as a newer version than the last develop kernel.
In reality, however, the develop kernel has its build number 395, and
the feature build number 150 will be recognized as its previous version.

To avoid such confusion, change build number naming scheme,
from a simple number to a more precise string according to a format

  $(last_develop_buildno).$(feature_buildno)

, where $(last_develop_buildno) is the most recent build number
in the develop branch, and $(feature_buildno) is the current feature
branch's build number. For example, if the last build number of develop
branch is 395, and that of feature branch is 150, then the output string
will be "395.150".

extract_storage_kernel+modules.sh

index 9399531faf2099dfb00a49444f8f3b0781c90e6a..a2e51642ee5028c5ca910d25f7e069112fb0a247 100755 (executable)
@@ -14,12 +14,29 @@ export DIST=squeeze
 export PB_SUITE=$DISTRIBUTION
 export TARGET_BASE=/srv/storage-kernels
 
+function get_last_target_build_no() {
+       TARGET_NAME=$1
+
+       if [ -n "$TARGET_NAME" ]; then
+               retval=$(find $TARGET_BASE/$TARGET_NAME -maxdepth 1 -type d \
+                       | grep -v "^.$" | sort -n | tail -n 1 \
+                       | sed -e "s|^\.\/||g" | sed -e "s|.*\/\([^\.]*\)$|\1|g")
+               [ -z "$retval" ] && retval="0"
+       else
+               retval="0"
+       fi
+
+       echo $retval
+}
+
 if [ "$DISTRIBUTION" = "production-proposed-updates" ] ; then
        export TARGET_NAME=master
 elif [ "$DISTRIBUTION" = "pre-staging" ] ; then
        export TARGET_NAME=develop
 elif [[ "$DISTRIBUTION" = dev-feature* ]] ; then
        export TARGET_NAME=$DISTRIBUTION
+       LAST_DEVELOP_BUILD_NO=$(get_last_target_build_no develop)
+       BUILD_NUMBER="$LAST_DEVELOP_BUILD_NO.$(printf %03d $BUILD_NUMBER)"
        FEATURE_APTCMD="
        echo \"deb http://alexandria.pb.local/dev-repository $DISTRIBUTION main contrib non-free\" \
        > /etc/apt/sources.list.d/profitbricks-linux-image-storage-$DISTRIBUTION.list