From f17af5f196ff39f5e9ffadaf05d5d640f14949fc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 31 Mar 2017 07:54:52 +0200 Subject: Bootstrap toolchain --- buildos | 52 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 49 insertions(+), 3 deletions(-) (limited to 'buildos') 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" <