summaryrefslogtreecommitdiff
path: root/run-bootstrap-in-chroot
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 18:22:48 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-01-20 18:22:48 +0000
commitbb39a30a18f9901acb62b2257bb1d7cfae83e144 (patch)
treee5451aab1c721dbf77421d2e3616aa7a8d3cd150 /run-bootstrap-in-chroot
parenteaf17d0b078d4c46d096d34842a493d039fe5167 (diff)
downloadmorph-bb39a30a18f9901acb62b2257bb1d7cfae83e144.tar.gz
Fix snapshotting logic and git repo updating
Diffstat (limited to 'run-bootstrap-in-chroot')
-rwxr-xr-xrun-bootstrap-in-chroot67
1 files changed, 25 insertions, 42 deletions
diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot
index eca64799..0dcbaa9c 100755
--- a/run-bootstrap-in-chroot
+++ b/run-bootstrap-in-chroot
@@ -55,60 +55,43 @@ cat <<EOF > "$dir/etc/hosts"
127.0.1.1 $(hostname)
EOF
-cp baserock-bootstrap "$dir/."
-mkdir -p "$dir/tree/baserock"
-cp -r "$HOME/baserock/gits" "$dir/tree/baserock/gits"
-sed 's,^.*/,http://192.168.1.185/lfs/,' wget-list > "$dir/wget-list"
-
+# Unpack existing snapshot, or run pass1 of bootstrap and then make snapshot.
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 mount_virtual "$dir" && chroot "$dir" bash -x baserock-bootstrap yes &&
- unmount_virtual "$dir"
- then
- if tar -C "$dir" -caf "$snapshotdir/pass1-snapshot.tar" .
- then
- if mount_virtual "$dir" &&
- chroot "$dir" bash -x baserock-bootstrap no &&
- unmount_virtual "$dir"
- then
- exit=0
- else
- exit=$?
- fi
- else
- exit=$?
- fi
- else
- exit=$?
- fi
+ tar -C "$dir" -xf "$snapshotdir/pass1-snapshot.tar"
else
if mount_virtual "$dir" &&
- chroot "$dir" bash -x baserock-bootstrap no &&
+ chroot "$dir" bash -x baserock-bootstrap yes &&
unmount_virtual "$dir"
then
- exit=0
+ :
else
- exit=$?
+ unmount_virtual "$dir"
+ exit 1
+ fi
+
+ if [ "$snapshot" = yes ]
+ then
+ tar -C "$dir" -caf "$snapshotdir/pass1-snapshot.tar" .
fi
fi
-if [ "$exit" = 0 ] &&
- mount_virtual "$dir" &&
- chroot "$dir" bash -x baserock-bootstrap no &&
+# Update the git repos.
+mkdir -p "$dir/tree/baserock"
+rm -rf "$dir/tree/baserock/gits"
+cp -rl "$HOME/baserock/gits" "$dir/tree/baserock/gits"
+
+# Run pass2 of bootstrap. This actually runs pass1 too, but quickly, since
+# it's already built.
+cp baserock-bootstrap "$dir/."
+sed 's,^.*/,http://192.168.1.185/lfs/,' wget-list > "$dir/wget-list"
+if mount_virtual "$dir" &&
+ chroot "$dir" bash -x baserock-bootstrap yes &&
unmount_virtual "$dir"
then
- exit=0
+ :
else
- exit=$?
+ unmount_virtual "$dir"
+ exit 1
fi
-unmount_virtual "$dir"
-exit $exit