From aca19fc0f5c9774d5c0fd3d4f4b92c018b865a85 Mon Sep 17 00:00:00 2001 From: Dongsu Park Date: Wed, 24 Apr 2013 11:19:38 +0200 Subject: [PATCH] extract_storage: change way of obtaining the last develop build number 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 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/extract_storage_kernel+modules.sh b/extract_storage_kernel+modules.sh index 43bcaa3..fdd6434 100755 --- a/extract_storage_kernel+modules.sh +++ b/extract_storage_kernel+modules.sh @@ -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-) -- 2.39.5