summaryrefslogtreecommitdiff
path: root/run-bootstrap-in-chroot
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 11:56:18 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 11:56:18 +0000
commit4d58ab616e0e28f85f99b24bfc016eb8240300a5 (patch)
tree74f6bdf621d827990acb13cb2cbb2338c846d4fe /run-bootstrap-in-chroot
parent66e66578571d0ffbd046ecfff1668e28e859ed1e (diff)
downloadmorph-4d58ab616e0e28f85f99b24bfc016eb8240300a5.tar.gz
Change snapshot handling to be more flexible
Also, do snapshot of the debootstrapped thing too.
Diffstat (limited to 'run-bootstrap-in-chroot')
-rwxr-xr-xrun-bootstrap-in-chroot65
1 files changed, 58 insertions, 7 deletions
diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot
index cdef9588..531ed957 100755
--- a/run-bootstrap-in-chroot
+++ b/run-bootstrap-in-chroot
@@ -7,8 +7,12 @@ export LC_ALL=C
if [ "x$1" = x ]
then
dir="squeeze-chroot"
+ snapshot=no
else
- dir="$1"
+ mkdir -p "$1"
+ dir="$1/squeeze-chroot"
+ snapshot=yes
+ snapshotdir="$1"
fi
mirror="http://192.168.1.185/debian"
@@ -17,11 +21,21 @@ umount "$dir/sys" || true
rm -rf "$dir"
mkdir "$dir"
-debootstrap \
---include=build-essential,\
-gawk,bison,python,autoconf,autopoint,automake,gettext,libtool,\
-help2man,texinfo,sudo,qemu-utils,parted,kpartx,mbr,extlinux \
-squeeze "$dir" "$mirror"
+if [ "$snapshot" = yes ] && [ -e "$snapshotdir/squeeze.tar" ]
+then
+ tar -C "$dir" -xf "$snapshotdir/squeeze.tar"
+else
+ debootstrap \
+ --include=build-essential,\
+ gawk,bison,python,autoconf,autopoint,automake,gettext,libtool,\
+ help2man,texinfo,sudo,qemu-utils,parted,kpartx,mbr,extlinux \
+ squeeze "$dir" "$mirror"
+
+ if [ "$snapshot" = yes ]
+ then
+ tar -caf "$snapshotdir/squeeze.tar" -C "$dir" .
+ fi
+fi
hostname > "$dir/etc/hostname"
cat <<EOF > "$dir/etc/hosts"
@@ -35,12 +49,49 @@ cp -r "$HOME/baserock/gits" "$dir/tree/baserock/gits"
sed 's,^.*/,http://192.168.1.185/lfs/,' wget-list > "$dir/wget-list"
mount -t proc proc "$dir/proc"
mount -t sysfs sysfs "$dir/sys"
-if chroot "$dir" bash -x baserock-bootstrap no
+
+if [ "$snapshot" = yes ] && [ -e "$snapshotdir/pass1-snapshot.tar" ]
+then
+ if tar -C "$dir" -xf "$snapshotdir/pass1-snapshot.tar"
+ then
+ exit=0
+ else
+ exit=$?
+ fi
+elif [ "$snapshot" = yes ]
+then
+ if chroot "$dir" bash -x baserock-bootstrap yes
+ then
+ if tar -C "$dir" -caf "$snapshotdir/pass1-snapshot.tar"
+ then
+ if chroot "$dir" bash -x baserock-bootstrap no
+ then
+ exit=0
+ else
+ exit=$?
+ fi
+ else
+ exit=$?
+ fi
+ else
+ exit=$?
+ fi
+else
+ if chroot "$dir" bash -x baserock-bootstrap no
+ then
+ exit=0
+ else
+ exit=$?
+ fi
+fi
+
+if [ "$exit" = 0 ] && chroot "$dir" bash -x baserock-bootstrap no
then
exit=0
else
exit=$?
fi
+
umount "$dir/sys"
umount "$dir/proc"
exit $exit