From cea95db3790bb98085288a4234c9dd9272c4e1ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sat, 1 Apr 2017 14:39:10 +0200 Subject: Add bootstrap protocol version to build machine directory names --- buildos | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) (limited to 'buildos') 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 + + # -

(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 - # - + if [ "${#ps[@]}" -gt 0 ]; then + + # -

. (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 - # - + # - (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" -- cgit v1.1