diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-01 14:39:10 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-01 14:39:10 +0200 |
commit | cea95db3790bb98085288a4234c9dd9272c4e1ad (patch) | |
tree | 2a90a24df6c29511642c8a9858eacb56f151c1c6 | |
parent | b304f7b1c52550fef0d0a116e0155f247c16141c (diff) |
Add bootstrap protocol version to build machine directory names
-rwxr-xr-x | buildos | 48 | ||||
-rw-r--r-- | doc/manual.cli | 56 |
2 files changed, 67 insertions, 37 deletions
@@ -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" diff --git a/doc/manual.cli b/doc/manual.cli index e5f9b55..6648eec 100644 --- a/doc/manual.cli +++ b/doc/manual.cli @@ -351,7 +351,7 @@ accessed via TFTP using predictable names). \h1#machines|Build Machines| -At the top level, a machine storage volume (\l{#config-storage-machines +At the top level, a machine storage volume (see \l{#config-storage-machines Machines}) contains machine directories, for example: \ @@ -361,30 +361,32 @@ Machines}) contains machine directories, for example: \ The layout inside a machine directory is as follows, where \c{<name>} is -the machine name and \c{toolchain} is the toolchain name: +the machine name and \c{<toolchain>} is the toolchain name: \ <name>/ -├── <name> -> <name>-2 -├── <name>-1/ -├── <name>-2/ +├── <name>-1 -> <name>-1.1 +├── <name>-1.0/ +├── <name>-1.1/ ├── <name>-<toolchain>/ └── <name>-<toolchain>-<xxx>/ \ -The \c{<name>-<N>} entries are read-only \c{btrfs} subvolumes that contain -the initial (that is, \i{pre-bootstrap}) machine images. The numeric \c{<N>} -part indicate the machine revision. +The \c{<name>-<P>.<R>} entries are read-only \c{btrfs} subvolumes that contain +the initial (that is, \i{pre-bootstrap}) machine images. The numeric \c{<P>} +part indicates the \i{bootstrap protocol version}. The numeric \c{<R>} part +indicates the machine revision. -The \c{<name>} entry is a symbolic link to the \c{<name>-<N>} that is +The \c{<name>-<P>} entry is a symbolic link to \c{<name>-<P>.<N>} that is currently in effect. The \c{<name>-<toolchain>} entry is the bootstrapped machine image for -\c{<toolchain>}. It is created by cloning \c{<name>} and then bootstrapping +\c{<toolchain>}. It is created by cloning \c{<name>-<P>} with a bootstrap +protocol version that matches this toolchain's \c{bbot} and then bootstrapping the \c{build2} toolchain inside. The \c{<name>-<toolchain>-<xxx>} entries are the temporary snapshots of -\c{<name>-<toolchain>} created for building packages. +\c{<name>-<toolchain>} created by \c{bbot} for building packages. A machine can be added, upgraded, or deleted on a live Build OS instance. This needs to be done in a particular order to avoid inconsistencies and race @@ -392,7 +394,7 @@ conditions. \h#machines-add|Adding a Machine| -Let's assume you have a read-only \c{btrfs} \c{linux-gcc_6-1} subvolume on a +Let's assume you have a read-only \c{btrfs} \c{linux-gcc_6-1.0} subvolume on a development host (we will call it \c{devel}) that contains the initial version of our virtual machine. We would like to add it to the build host (running Build OS, we will call it \c{build}) into the default machine volume @@ -406,26 +408,26 @@ build$ mkdir /build/machines/default/linux-gcc_6 # Send the machine subvolume to build host. # -devel$ sudo btrfs send linux-gcc_6-1 | \ +devel$ sudo btrfs send linux-gcc_6-1.0 | \ ssh build@build sudo btrfs receive /build/machines/default/linux-gcc_6/ build$ cd /build/machines/default/linux-gcc_6 # Make user build the owner of the machine subvolume. # -build$ sudo btrfs property set -ts linux-gcc_6-1 ro false -build$ sudo chown build:build linux-gcc_6-1 -build$ btrfs property set -ts linux-gcc_6-1 ro true +build$ sudo btrfs property set -ts linux-gcc_6-1.0 ro false +build$ sudo chown build:build linux-gcc_6-1.0 +build$ btrfs property set -ts linux-gcc_6-1.0 ro true # Make the subvolume the current machine. # -build$ ln -s linux-gcc_6-1 linux-gcc_6 +build$ ln -s linux-gcc_6-1.0 linux-gcc_6-1 \ \h#machines-upgade|Upgrading a Machine| Continuing with the example started in the previous section, let's assume we -have created \c{linux-gcc_6-2} as a snapshot of \c{linux-gcc_6-1} and have +have created \c{linux-gcc_6-1.1} as a snapshot of \c{linux-gcc_6-1.0} and have made some modification to the virtual machine (all on the development host). We now would like to switch to this new revision of our machine on the build host. To achieve this in an atomic way we perform the following steps: @@ -433,26 +435,26 @@ build host. To achieve this in an atomic way we perform the following steps: \ # Send the new machine subvolume to build host incrementally. # -devel$ sudo btrfs send -p linux-gcc_6-1 linux-gcc_6-2 | \ +devel$ sudo btrfs send -p linux-gcc_6-1.0 linux-gcc_6-1.1 | \ ssh build@build sudo btrfs receive /build/machines/default/linux-gcc_6/ build$ cd /build/machines/default/linux-gcc_6 # Make user build the owner of the new machine subvolume. # -build$ sudo btrfs property set -ts linux-gcc_6-2 ro false -build$ sudo chown build:build linux-gcc_6-2 -build$ btrfs property set -ts linux-gcc_6-2 ro true +build$ sudo btrfs property set -ts linux-gcc_6-1.1 ro false +build$ sudo chown build:build linux-gcc_6-1.1 +build$ btrfs property set -ts linux-gcc_6-1.1 ro true # Switch the current machine atomically. # -build$ ln -s linux-gcc_6-2 new-linux-gcc_6 -build$ mv -T new-linux-gcc_6 linux-gcc_6 +build$ ln -s linux-gcc_6-1.1 new-linux-gcc_6-1 +build$ mv -T new-linux-gcc_6-1 linux-gcc_6-1 # Remove the old machine subvolume (optional). # -build$ btrfs property set -ts linux-gcc_6-1 ro false -build$ btrfs subvolume delete linux-gcc_6-1 +build$ btrfs property set -ts linux-gcc_6-1.0 ro false +build$ btrfs subvolume delete linux-gcc_6-1.0 \ \h#machines-delete|Deleting a Machine| @@ -467,7 +469,7 @@ build$ cd /build/machines/default/linux-gcc_6 # Delete the current machine symlink. # -build$ rm linux-gcc_6 +build$ rm linux-gcc_6-1 # Wait for all the linux-gcc_6-<toolchain>-<xxx> subvolumes # to disappear. |