From f17af5f196ff39f5e9ffadaf05d5d640f14949fc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 31 Mar 2017 07:54:52 +0200 Subject: Bootstrap toolchain --- bootstrap | 3 ++- buildos | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- doc/manual.cli | 26 ++++++++++++++++---------- 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 () # # function tc_bootstrap () # { - 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 () # 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" <} (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//} (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 -- cgit v1.1