aboutsummaryrefslogtreecommitdiff
path: root/buildos
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-01 14:39:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-01 14:39:10 +0200
commitcea95db3790bb98085288a4234c9dd9272c4e1ad (patch)
tree2a90a24df6c29511642c8a9858eacb56f151c1c6 /buildos
parentb304f7b1c52550fef0d0a116e0155f247c16141c (diff)
Add bootstrap protocol version to build machine directory names
Diffstat (limited to 'buildos')
-rwxr-xr-xbuildos48
1 files changed, 38 insertions, 10 deletions
diff --git a/buildos b/buildos
index ec2be0b..d3f1652 100755
--- a/buildos
+++ b/buildos
@@ -343,16 +343,35 @@ for v in /build/machines/*; do
cd "$m"
- # If there is no current machine symlink, then delete the whole thing.
+ # Collect current machine symlink's bootstrap protocol numbers. If there
+ # are no current machine symlinks, then we delete the whole thing.
#
- d=
- if [ ! -L "$m" ]; then
- d="true"
- fi
+ ps=()
+ for s in "$m"-*; do
+ if [[ "$s" =~ ^"$m"-[0-9]+$ ]]; then
+
+ if [ ! -L "$s" ]; then
+ diag+=("$v/$m/$s: error: not a symlink")
+ fail="true"
+ fi
+
+ # Treat it as if it were a symlink even if its not. Failed that we
+ # may try to delete the whole thing.
+ #
+ ps+=("$(sed -n -re 's/^.+-([0-9]+)$/\1/p' <<<"$s")")
+ fi
+ done
# Examine each machine subvolume.
#
for s in "$m"-*; do
+
+ # <name>-<P> (current machine symlink)
+ #
+ if [[ "$s" =~ ^"$m"-[0-9]+$ ]]; then
+ continue
+ fi
+
if [ ! -d "$s" ]; then
diag+=("$v/$m/$s: error: invalid machine subvolume")
fail="true"
@@ -362,14 +381,23 @@ for v in /build/machines/*; do
# Unless we are deleting the whole thing, keep initial and bootstrapped
# (for known toolchains) subvolumes.
#
- if [ -z "$d" ]; then
- # <name>-<N>
+ if [ "${#ps[@]}" -gt 0 ]; then
+
+ # <name>-<P>.<R> (initial image)
#
- if [[ "$s" =~ ^"$m"-[0-9]+$ ]]; then
+ f=
+ for p in "${ps[@]}"; do
+ if [[ "$s" =~ ^"$m"-"$p"\.[0-9]+$ ]]; then
+ f="true"
+ break
+ fi
+ done
+
+ if [ -n "$f" ]; then
continue
fi
- # <name>-<toolchain>
+ # <name>-<toolchain> (bootstrapped image)
#
f=
for tn in "${!toolchains[@]}"; do
@@ -406,7 +434,7 @@ for v in /build/machines/*; do
# Delete the machine directory (which we expect to be now empty).
#
- if [ -n "$d" ]; then
+ if [ "${#ps[@]}" -eq 0 ]; then
if ! rmdir "$m"; then
diag+=("$v/$m: error: unable to delete machine directory")
fail="true"