diff options
Diffstat (limited to 'run-bootstrap-in-chroot')
-rwxr-xr-x | run-bootstrap-in-chroot | 65 |
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 |