#
export DIST=squeeze
export PB_SUITE=$DISTRIBUTION
-export TARGET_DIR=/srv/storage-kernels
+export TARGET_BASE=/srv/storage-kernels
+
+if [ "$DISTRIBUTION" = "production-proposed-updates" ] ; then
+ export $TARGET_DIR=$TARGET_BASE/master/$BUILD_NUMBER
+elif [ "$DISTRIBUTION" = "pre-staging" ] ; then
+ export $TARGET_DIR=$TARGET_BASE/develop/$BUILD_NUMBER
+else
+ echo "DISTRIBUTION must be 'production-proposed-updates' or 'pre-staging', exiting."
+ figlet "FAIL"
+ exit 1
+fi
+
SCRIPTSDIR=$(dirname $0)
BUILD_SCRIPT=$(mktemp)
cat > $BUILD_SCRIPT <<-EOF
# 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/
+mkdir -p $TARGET_DIR
+cp -v /boot/vmlinu* $TARGET_DIR/
+cp -v /boot/config* $TARGET_DIR/
cd /lib/modules/*storage/
-/bin/tar -cJvf $TARGET_DIR/$BUILD_NUMBER/modules.tar.xz .
+/bin/tar -cJvf $TARGET_DIR/modules.tar.xz .
EOF
chmod +x $BUILD_SCRIPT
#
# build liveboot
#
-sudo pbuilder --execute --bindmounts $TARGET_DIR -- $BUILD_SCRIPT
+sudo pbuilder --execute --bindmounts $TARGET_BASE -- $BUILD_SCRIPT
rm $BUILD_SCRIPT
# 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
+cd $TARGET_BASE
+for suite in production-proposed-updates pre-staging ; do
+ cd $suite
+ 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
+ cd ..
done
figlet "OK"