set -e
-if [ "$1" == "" ] ; then
+if [ -z "${BUILD_NUMBER}" ]
+then
+ echo "\$BUILD_NUMBER is empty, not using Jenkins? Please export manually!"
+ exit 1
+fi
+
+#
+# Define default profile if none is given
+#
+if [ "$1" == "" ]
+then
LIVE_TYPE="staging"
else
LIVE_TYPE=$1
fi
+#
+# Define default settings
+#
RSYNC_BASE=/srv/mirror/live-build
BUILD_DATE=$(date +%Y%m%d%H%M)
BUILD_ID="${LIVE_TYPE}-${BUILD_DATE}-${BUILD_NUMBER}" # BUILD_ID is used without lb_build.sh...
BUILD_TARGET=$RSYNC_BASE/$BUILD_ID
+#
+# Overwrite settings depending on profile used
+# - i.e. not enough space in PBB to contain all images
+#
case $LIVE_TYPE in
default|staging)
RSYNC_SRC="$RSYNC_BASE/"
;;
esac
+#
+# Export variables for upcoming sudo-calls
+#
export LIVE_TYPE TARGET_RSYNC BUILD_DATE BUILD_ID BUILD_TARGET TARGET_BASE
+#
+# Build
+#
figlet "building $LIVE_TYPE with build_id $BUILD_ID"
cd pserver.flexible
ls -larth tftpboot/debian-live/amd64/
ls -larth binary/live/
+figlet "build OK"
+
+#
+# Deploy
+#
mkdir -p $BUILD_TARGET
echo "Finally copying results..."
cp -v tftpboot/debian-live/amd64/initrd.img-3* tftpboot/debian-live/amd64/vmlinuz-3* $BUILD_TARGET/
cp -v binary/live/filesystem.squashfs $BUILD_TARGET/
-figlet "success"
+figlet "deploy OK"
+
+#
+# Mirror
+#
echo
sort binary/live/filesystem.packages
echo
echo "Now rsyncing results to $RSYNC_BASE ..."
rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete $RSYNC_SRC/ rsync://$RSYNC_DST
-figlet "rsync success"
+figlet "mirror OK"
#
# cleanup /srv/mirror, keep MAX number of images
fi
done
+figlet "cleanup OK"