]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
extract_storage: change way of obtaining the last develop build number
authorDongsu Park <dongsu.park@profitbricks.com>
Wed, 24 Apr 2013 09:19:38 +0000 (11:19 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Wed, 24 Apr 2013 12:54:47 +0000 (14:54 +0200)
This commit includes the following bug fixes.

1. get_last_target_build_no() changes its way of obtaining the last
  build number of a given target, e.g. develop. So far the function
  has tried to get the most recent subdirectory under
  /srv/storage-kernels/develop, for example 412. However, that was
  slightly buggy, because it returned a wrong value if no subdirectory
  exists. As the subdirectories get cleaned up at the end of this script,
  such case can happen actually quite often. Therefore the solution is
  to parse tarball's filenames to get the last build number.

2. It changed how to install debian package from feature branches.
  Sometimes it's not possible to install a debian package with an
  option "-t $DISTRIBUTION", especially when $DISTRIBUTION is the one
  for feature branch. So let's add a version number to apt-get install
  command, to be more specific. i.e. "package_name=version_number"

3. A small bugfix in case of experimental distribution.
  Distribution name for sources.list should be $TARGET_NAME instead of
  $DISTRIBUTION, because $DISTRIBUTION does not indicates the name of
  an individual feature branch, since the recent change by Mathias.

4. A small bugfix. If $PB_SUITE is an empty string, set TARGET_NAME to
  master by default. Otherwise the entire script could sometimes work
  in a wrong way.

extract_storage_kernel+modules.sh

index 43bcaa33ba8cf3684ee085a0642f35bfca84b327..fdd6434be74a786b99dbee2507aab227d186fd2c 100755 (executable)
@@ -14,13 +14,17 @@ export DIST=squeeze
 export PB_SUITE=$DISTRIBUTION
 export TARGET_BASE=/srv/storage-kernels
 
+# get the last build number of the given target,
+# parsing tarball's file name under /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")
+               retval=$(find $TARGET_BASE/$TARGET_NAME -maxdepth 1 -type f \
+                       -name 'linux-storage*tar.xz' | grep -v "^.$" \
+                       | sed -e "s|$TARGET_BASE/$TARGET_NAME||g" \
+                       | sed -e "s|.*\/linux-storage_[0-9a-zA-Z\.]*\.\([^\.]*\).tar.xz$|\1|g" \
+                       | sort -n | tail -n 1)
                [ -z "$retval" ] && retval="0"
        else
                retval="0"
@@ -40,12 +44,16 @@ case $DISTRIBUTION in
        export TARGET_NAME=develop
         ;;
   experimental)
-       export TARGET_NAME=$PB_SUITE
+       [ -n "$PB_SUITE" ] && export TARGET_NAME=$PB_SUITE || export TARGET_NAME="master"
        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
+       echo \"deb http://alexandria.pb.local/dev-repository $TARGET_NAME main contrib non-free\" \
+       > /etc/apt/sources.list.d/profitbricks-linux-image-storage-$TARGET_NAME.list
+       "
+       FEATURE_VERSCMD="
+       export FEATURE_VERSION=\`apt-cache showpkg profitbricks-linux-image-storage -a \
+       | grep $TARGET_NAME | grep \) | sed -e \"s|\([^\.]*\)\ .*$|\1|g\"\`
        "
         ;;
   *)
@@ -69,7 +77,9 @@ $FEATURE_APTCMD
 apt-get update
 # grub is needed in the postinst...
 apt-get install -y grub2 
-apt-get -t $DISTRIBUTION -y install profitbricks-linux-image-storage || true
+$FEATURE_VERSCMD
+[ -n "###FEATURE_VERSION" ] && export FEATURE_VERSION="=###FEATURE_VERSION"
+apt-get -t $DISTRIBUTION -y install profitbricks-linux-image-storage###FEATURE_VERSION || true
 apt-get -y install profitbricks-andbd-modules-storage || true
 mkdir -p $TARGET_DIR
 export KERNEL_VERSION=###(ls /boot/vmlinu* | cut -d "-" -f2-)