From ee830c20f18fc724d98c5a0d898bd2c9e901a31f Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Tue, 16 Oct 2012 19:25:06 +0200 Subject: [PATCH] initial implementation for DEVINF-160 build storage kernel with andbd in jenkins --- extract_storage_kernel+modules.sh | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 extract_storage_kernel+modules.sh diff --git a/extract_storage_kernel+modules.sh b/extract_storage_kernel+modules.sh new file mode 100755 index 0000000..d65ab86 --- /dev/null +++ b/extract_storage_kernel+modules.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# copyright 2012 Holger Levsen +# GPL2 licenced + +set -e +set -x +export + +# +# Define default settings +# +#export DIST=squeeze +#export PB_SUITE=production-proposed-updates +export TARGET_DIR=/srv/storage-kernels +SCRIPTSDIR=$(dirname $0) +BUILD_SCRIPT=$(mktemp) +cat > $BUILD_SCRIPT <<-EOF +#/bin/bash +set -e +set -x +apt-get update +# grub is needed in the postinst... +apt-get install -y grub2 +apt-get -y install profitbricks-andbd-modules-storage profitbricks-linux-image-storage || true +mkdir $TARGET_DIR/$BUILD_NUMBER +cp -v /boot/vmlinu* $TARGET_DIR/$BUILD_NUMBER/ +cp -v /boot/config* $TARGET_DIR/$BUILD_NUMBER/ +cd /lib/modules/*storage/ +/bin/tar -cJvf $TARGET_DIR/$BUILD_NUMBER/modules.tar.xz . +EOF +chmod +x $BUILD_SCRIPT + +# +# build liveboot +# +sudo pbuilder --execute --bindmounts $TARGET_DIR -- $BUILD_SCRIPT +rm $BUILD_SCRIPT + + +# TODO: implement better garbage collection, allow to keep images +# +# cleanup $TARGET_DIR, keep MAX number of images +# +MAX=15 +cd $TARGET_DIR +COUNT=0 +for i in $(ls -atd1) ; do + if [ "$i" != "." ] ; then + let COUNT=COUNT+1 + if [ $COUNT -gt $MAX ] ; then + echo sudo rm -rfv ./$i + else + echo "keeping $i" + fi + fi + if [ $COUNT -gt 0 ] ; then + figlet "Warning:" + echo "Garbage collection disabled." + fi +done + +figlet "OK" + + -- 2.39.5