aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbootstrap3
-rwxr-xr-xbuildos52
-rw-r--r--doc/manual.cli26
3 files changed, 67 insertions, 14 deletions
diff --git a/bootstrap b/bootstrap
index 792d7ba..ada94c8 100755
--- a/bootstrap
+++ b/bootstrap
@@ -353,7 +353,7 @@ if [ "$stage" -le "4" ]; then
# Quite a few files/directories are only accessible by root (e.g., /root) so
# we run under sudo.
#
- root_dirs="dev etc mnt root usr var"
+ root_dirs="build dev etc mnt root usr var"
root_links="bin sbin lib lib32 lib64"
info "generating buildos-rootfs.cpio.gz..."
@@ -425,6 +425,7 @@ fi
#
sudo kvm \
-m 8G \
+ -cpu host -smp "sockets=1,cores=4,threads=2" \
-device "e1000,netdev=net0,mac=$macaddr" \
-netdev "tap,id=net0,script=./qemu-ifup" \
-device "virtio-scsi-pci,id=scsi" \
diff --git a/buildos b/buildos
index 780dfca..7aa9a0e 100755
--- a/buildos
+++ b/buildos
@@ -12,7 +12,8 @@
# @@ What will systemd do if we fail? Perhaps configure it to restart
# us? Or not since we may hose the logs.
#
-trap "exit 1" ERR
+owd="$(pwd)"
+trap "{ cd '$owd'; exit 1; }" ERR
set -o errtrace # Trap in functions.
# Note: diagnostics goes to stdout.
@@ -192,11 +193,12 @@ function tc_fetch () # <toolchain-prefix> <line>
#
function tc_bootstrap () # <toolchain-name>
{
- local tp="${toolchains["$1"]}"
+ local tn="$1"
+ local tp="${toolchains["$tn"]}"
local tr="$(tc_value "$tp" toolchain_root)"
local tf="$(tc_value "$tp" toolchain_file)"
- # Fetch files according to the sums file. Skip empty line and those that
+ # Fetch files according to the sums file. Skip empty lines and those that
# start with '#'.
#
local l ls=()
@@ -208,6 +210,49 @@ function tc_bootstrap () # <toolchain-name>
return 1 # Diagnostics has already been issued.
fi
done
+
+ local tv="$(tc_value "$tp" toolchain_ver)" # Should be set by tc_fetch().
+ local tt="$(tc_value "$tp" toolchain_trust)"
+
+ # Bootstrap in /tmp/toolchains/$tn/, install to /build/toolchains/$tn/.
+ #
+ local wd="/tmp/toolchains/$tn"
+ local id="/build/toolchains/$tn"
+
+ mkdir -p "$wd"
+ mkdir -p "$id"
+
+ local r=1
+
+ cd "$wd"
+ while true; do # The "breakout loop".
+
+ # Extract the toolchain.
+ #
+ if ! tar -xf "$tr/build2-toolchain.tar.xz"; then
+ info "unable to extract $tr/build2-toolchain.tar.xz"
+ break
+ fi
+
+ cd "build2-toolchain-$tv"
+
+ # Bootstrap, stage, and install using the provided build.sh script.
+ #
+ if ! ./build.sh --install-dir "$id" --trust "$tt" g++; then
+ info "failed to build $(pwd)"
+ break
+ fi
+
+ r=0
+ break
+ done
+ cd "$owd"
+
+ # Clean up.
+ #
+ rm -r "$wd"
+
+ return "$r"
}
# Print monitor configuration as email body.
@@ -346,6 +391,7 @@ EOF
s="failed to bootstrap $tn toolchain, waiting for new version"
fi
+ info "$s"
email "$s" <<EOF
$tn.bootstrap_log: tftp://$hname/toolchains/$tn/bootstrap.log
EOF
diff --git a/doc/manual.cli b/doc/manual.cli
index b168675..ec29fcd 100644
--- a/doc/manual.cli
+++ b/doc/manual.cli
@@ -51,12 +51,12 @@ OS and building of the latest \c{build2} toolchain and \c{bbot}.
@@ TODO: init steps.
The monitor service (and \c{bbot} that it starts) are executed as the
-\c{build} user/group. The home directory of this user is \c{/build}. It has
+\c{build} user/group. The home directory of this user is \c{/build/}. It has
the following subdirectories:
\ul|
-\li|\n\c{/build/tftp}\n
+\li|\n\c{/build/tftp/}\n
A size-limited \c{tmpfs} filesystem that is used to communicate with build
machines as well as for build host log access.
@@ -66,7 +66,13 @@ the following subdirectories:
temporarily write-accessible to build machines by running custom instances
of the TFTP server on other ports.|
-\li|\n\c{/build/machines}\n
+\li|\n\c{/build/toolchains/}\n
+
+ Contains \c{build2} toolchain installations after bootstrap. Each toolchain
+ is installed into a subdirectory names as the toolchain name. See
+ \l{#config-toolchains Toolchains} for details.|
+
+\li|\n\c{/build/machines/}\n
Contains virtual machines and containers. See \l{#config-storage-machines
Machines} for details.||
@@ -87,7 +93,7 @@ kernel command line parameters.
The \c{buildos.buildid_url} value should point to the \c{buildos-buildid} file
that comes along the kernel image and initrd. The \c{buildos.toolchain_url}
value is the location of the toolchain checksums file as described in
-\l{#config-toolchain Toolchain}. See \l{#boot-net Network Boot} for the usage
+\l{#config-toolchains Toolchains}. See \l{#boot-net Network Boot} for the usage
example.
\h#boot-net|Network Boot|
@@ -291,7 +297,7 @@ quotes):
buildos.ssh_key=\"ssh-rsa AAA...OA0DB user@host\"
\
-\h#config-toolchain|Toolchain|
+\h#config-toolchains|Toolchains|
The first step performed by the Build OS monitor is to bootstrap the
\c{build2} toolchain. The location of the toolchain packages is specified with
@@ -305,7 +311,7 @@ default toolchain repository location embedded into the build scripts in the
It is also possible to use multiple toolchains on a single Build OS instance.
In this case a toolchain name can be appended after \c{buildos.toolchain_*},
-for example, \c{buildos.toolchain_url.stage} (values without the toolchain
+for example, \c{buildos.toolchain_url.<name>} (values without the toolchain
name use the toolchain name \c{default}).
Each line in the checksums file is the output of the \c{shaNNNsum(1)} utility,
@@ -323,10 +329,10 @@ e723[...]c305 *0.4.0/build2-mingw-0.4.0-x86_64-windows.tar.xz
\
Based on the checksums file the monitor downloads each file into
-\c{/build/tftp/} (the file path is taken as relative to \c{toolchain_url}),
-verifies their checksums, and creates \i{predictable name} symlinks (names
-without the version). Continuing with the above example, the contents of
-\c{/build/tftp/} would be:
+\c{/build/tftp/toolchains/<name>/} (the file path is taken as relative to
+\c{toolchain_url}), verifies their checksums, and creates \i{predictable name}
+symlinks (names without the version). Continuing with the above example, the
+contents of \c{/build/tftp/toolchains/default/} would be:
\
build2-toolchain-0.4.0.tar.xz