diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-31 07:54:52 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-03-31 08:05:59 +0200 |
commit | f17af5f196ff39f5e9ffadaf05d5d640f14949fc (patch) | |
tree | 60aa2d1d04fb6ff884526bed8e05aa65d54ea522 /buildos | |
parent | cf54735b4afe2da40a40d330096619bd2b53686b (diff) |
Bootstrap toolchain
Diffstat (limited to 'buildos')
-rwxr-xr-x | buildos | 52 |
1 files changed, 49 insertions, 3 deletions
@@ -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 |