2014-10-14 16:02:12 +00:00
|
|
|
#!/bin/bash -x
|
2014-04-24 13:42:18 +00:00
|
|
|
# vim: set ts=4 sw=4 sts=4 et :
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-16 16:03:05 +00:00
|
|
|
# Source external scripts
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-16 16:03:05 +00:00
|
|
|
. $SCRIPTSDIR/vars.sh
|
2014-10-14 21:04:42 +00:00
|
|
|
. ./umount_kill.sh >/dev/null
|
2014-10-14 16:02:12 +00:00
|
|
|
|
2014-10-16 16:03:05 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Configurations
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ "$VERBOSE" -ge 2 -o "$DEBUG" == "1" ]; then
|
|
|
|
set -x
|
|
|
|
else
|
|
|
|
set -e
|
|
|
|
fi
|
2014-10-16 20:05:28 +00:00
|
|
|
INSTALLDIR="$(readlink -m mnt)"
|
|
|
|
umount_kill "$INSTALLDIR" || :
|
|
|
|
|
2014-10-14 16:02:12 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Execute any custom pre configuration scripts
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
customStep "$0" "pre"
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Force overwrite of an existing image for now if debootstrap did not seem to complete...
|
|
|
|
# ------------------------------------------------------------------------------
|
2014-10-16 16:03:05 +00:00
|
|
|
debug "Determine if $IMG should be reused or deleted..."
|
2014-10-14 16:02:12 +00:00
|
|
|
if [ -f "$IMG" ]; then
|
|
|
|
# Assume a failed debootstrap installation if .prepare_debootstrap does not exist
|
2014-10-19 05:18:58 +00:00
|
|
|
mount -o loop "$IMG" "$INSTALLDIR" || exit 1
|
2014-10-14 16:02:12 +00:00
|
|
|
if ! [ -f "$INSTALLDIR/tmp/.prepared_debootstrap" ]; then
|
2014-10-19 05:18:58 +00:00
|
|
|
warn "Last build failed. Deleting $IMG"
|
2014-10-14 16:02:12 +00:00
|
|
|
rm -f "$IMG"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Umount image; don't fail if its already umounted
|
2014-10-14 21:04:42 +00:00
|
|
|
umount_kill "$INSTALLDIR" || :
|
2014-10-14 16:02:12 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# Execute any custom post configuration scripts
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
customStep "$0" "post"
|
2014-04-24 13:42:18 +00:00
|
|
|
|