diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2022-02-01 13:31:56 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2022-02-01 13:31:56 +0200 |
commit | af3d4b7038382018d875a8eed01cda78046fc7eb (patch) | |
tree | 3fac5c38b704fb36460732bea59b316c237bfde6 /upgrade | |
parent | 75fc4018e036354feb8fb16b467e499b45731281 (diff) |
Script updates for new single configuration toolchain dev setup
Diffstat (limited to 'upgrade')
-rwxr-xr-x | upgrade | 138 |
1 files changed, 86 insertions, 52 deletions
@@ -1,7 +1,7 @@ #! /usr/bin/env bash -# Upgrade remote packages in a bdep-managed build2 toolchain build, -# essentially as if by executing: +# Upgrade remote packages in a bdep-managed build2 toolchain build (default +# configurations), essentially as if by executing: # # bdep sync -fur && b # @@ -11,27 +11,42 @@ # package, the tools (b, bppg, etc) become non-runnable (missing shared # libraries, etc). # -# Note also that this script expects the build system (build2) and the rest of -# the toolchain (bpkg, bdep, etc) to be built in separate build configuration -# (for example, tsan for build2 and asan for the rest). +# Finally, this script only upgrades the default configurations (including +# -libs, if present). To upgrade the rest you can use the normal way, for +# example: # -# Finally, this script only upgrades the default configurations. To upgrade -# the rest you can use the normal way, for example: +# bdep sync -fur @<cfg>|-a # -# bdep sync -fura -# -# If the -c option is specified, then the second configuration is upgraded -# and configured but is not updated. This can be done at a later stage by +# If the -c option is specified, the configuration is upgraded and configured +# but only the build system is updated. This can be done at a later stage by # running the build system in the configuration directory: # # BDEP_SYNC=0 b # -trap "exit 1" ERR +owd="$(pwd)" +trap "{ cd '$owd'; exit 1; }" ERR set -o errtrace # Trap in functions. function info () { echo "$*" 1>&2; } function error () { info "$*"; exit 1; } +# Run a command with tracing (similar to set -x). +# +# Note that this function will execute a command with arguments that contain +# spaces but it will not print them as quoted (and neither does set -x). +# +function run () +{ + echo "+ $@" 1>&2 + "$@" +} + +function run_no_sync () +{ + echo "+ BDEP_SYNC=0 $@" 1>&2 + BDEP_SYNC=0 "$@" +} + # Make sure the build2 tools are runnable. # b --version >/dev/null @@ -54,82 +69,101 @@ done # Get the configuration directories. # -bcfg="$(b info: build2/ | sed -n -re 's/^out_root: (.+)$/\1/p')" -pcfg="$(b info: bpkg/ | sed -n -re 's/^out_root: (.+)$/\1/p')" +tcfg="$(b info: build2/ | sed -n -re 's/^out_root: (.+)$/\1/p')" +lcfg="$(b info: libbutl/ | sed -n -re 's/^out_root: (.+)$/\1/p')" -if [ -z "$bcfg" -o -z "$pcfg" ]; then +if [ -z "$tcfg" -o -z "$lcfg" ]; then error "unable to determine build configuration directories" fi -bcfg="$(dirname "$bcfg")" -pcfg="$(dirname "$pcfg")" +tcfg="$(dirname "$tcfg")" +lcfg="$(dirname "$lcfg")" -if [ "$bcfg" = "$pcfg" ]; then - error "build2 and bpkg build configuration directories are the same" +if [ "$tcfg" = "$lcfg" ]; then + lcfg= fi # The plan is as follows: # -# 0. First, make backup copies of both configurations. If something goes wrong, +# 0. First, make backup copies of configurations. If something goes wrong, # it's likely the tools will be left in a non-runnable state. # -# 1. Next, install the build system on the side and then upgrade the build -# system configuration using that plus the existing bpkg/bdep. -# -# 2. Finally, upgrade the rest. Note that we only have one shot at this since -# we are running bpkg that is being upgraded. +# 1. Next, install the build tollchain on the side and then upgrade the +# configurations using that. # # Step 0. # -if test -e "$bcfg.bak"; then - error "$bcfg.bak already exist" +if test -e "$tcfg.bak"; then + error "$tcfg.bak already exist" fi -if test -e "$pcfg.bak"; then - error "$pcfg.bak already exist" +if [ -n "$lcfg" ]; then + if test -e "$lcfg.bak"; then + error "$lcfg.bak already exist" + fi fi -set -x +run cp -rp "$tcfg" "$tcfg.bak" -cp -rp "$bcfg" "$bcfg.bak" -cp -rp "$pcfg" "$pcfg.bak" +if [ -n "$lcfg" ]; then + run cp -rp "$lcfg" "$lcfg.bak" +fi # Step 1. # -BDEP_SYNC=0 b "$bcfg"/libbutl/libbutl/hxx{version} -BDEP_SYNC=0 b "$bcfg"/build2/libbuild2/hxx{version} +# @@ TMP: I don't see why we would need this. +# +#run_no_sync b "$tcfg"/libbutl/libbutl/hxx{version} +#run_no_sync b "$tcfg"/libbpkg/libbpkg/hxx{version} +#run_no_sync b "$tcfg"/build2/libbuild2/hxx{version} + +run rm -rf /tmp/build2-install -BDEP_SYNC=0 bpkg install -d "$bcfg" \ +run_no_sync bpkg install -d "$tcfg" \ config.install.root=/tmp/build2-install \ config.bin.rpath=/tmp/build2-install/lib \ - build2 + build2 bpkg bdep -/tmp/build2-install/bin/b --version >/dev/null +opath="$PATH" +run export PATH="/tmp/build2-install/bin:$PATH" -bpkg fetch -d "$bcfg" -BDEP_SYNC=0 bpkg build -d "$bcfg" --build /tmp/build2-install/bin/b --keep-out -ur +run which b bpkg bdep -b --version >/dev/null +run b --version >/dev/null +run bpkg --version >/dev/null +run bdep --version >/dev/null -b build2/ # Should be a noop. +run bpkg fetch -d "$tcfg" +run_no_sync bpkg build -d "$tcfg" --keep-out -ur $configure_only -rm -rf /tmp/build2-install - -# Step 2. +# In configure-only we update the build system manually. # -bpkg fetch -d "$pcfg" -BDEP_SYNC=0 bpkg build -d "$pcfg" --keep-out -ur $configure_only +if [ -n "$configure_only" ]; then + run_no_sync b build2/ +fi -if [ -z "$configure_only" ]; then +if [ -n "$lcfg" ]; then + run bpkg fetch -d "$lcfg" + run_no_sync bpkg build -d "$lcfg" --keep-out -ur $configure_only +fi - bpkg --version >/dev/null - bdep --version >/dev/null +run export PATH="$opath" - b bpkg/ bdep/ # Should be a noop. +run b --version >/dev/null +run b build2/ # Should be a noop. +if [ -z "$configure_only" ]; then + run bpkg --version >/dev/null + run bdep --version >/dev/null + run b bpkg/ bdep/ # Should be a noop. fi -rm -rf "$bcfg.bak" -rm -rf "$pcfg.bak" +run rm -rf /tmp/build2-install + +run rm -rf "$tcfg.bak" + +if [ -n "$lcfg" ]; then + run rm -rf "$lcfg.bak" +fi |