]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
initial implementation for DEVINF-160 build storage kernel with andbd in jenkins
authorHolger Levsen <holger@layer-acht.org>
Tue, 16 Oct 2012 17:25:06 +0000 (19:25 +0200)
committerHolger Levsen <holger@layer-acht.org>
Tue, 16 Oct 2012 17:25:06 +0000 (19:25 +0200)
extract_storage_kernel+modules.sh [new file with mode: 0755]

diff --git a/extract_storage_kernel+modules.sh b/extract_storage_kernel+modules.sh
new file mode 100755 (executable)
index 0000000..d65ab86
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# copyright 2012 Holger Levsen <holger@layer-acht.org>
+# 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"
+
+