aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuildos66
1 files changed, 33 insertions, 33 deletions
diff --git a/buildos b/buildos
index 0547c97..893ccc6 100755
--- a/buildos
+++ b/buildos
@@ -100,7 +100,7 @@ function restart ()
# Return the value of one of the toolchain_* variables for this toolchain.
#
-function tc_value () # <toolchain-prefix> <variable>
+function toolchain_value () # <toolchain-prefix> <variable>
{
local n="${1}${2}"
echo "${!n}"
@@ -109,7 +109,7 @@ function tc_value () # <toolchain-prefix> <variable>
toolchain_names=()
for tn in "${!toolchains[@]}"; do
tp="${toolchains["$tn"]}"
- tu="$(tc_value "$tp" toolchain_url)"
+ tu="$(toolchain_value "$tp" toolchain_url)"
if [ -z "$tu" ]; then
continue
@@ -132,7 +132,7 @@ for tn in "${!toolchains[@]}"; do
# If buildos.toolchain_trust was not specified, set it to "no" so that
# we don't prompt if the repository happens to be signed.
#
- if [ -z "$(tc_value "$tp" toolchain_trust)" ]; then
+ if [ -z "$(toolchain_value "$tp" toolchain_trust)" ]; then
declare "${tp}toolchain_trust=no"
fi
done
@@ -173,8 +173,8 @@ function print ()
for tn in "${toolchain_names[@]}"; do
tp="${toolchains["$tn"]}"
- tu="$(tc_value "$tp" toolchain_url)"
- tt="$(tc_value "$tp" toolchain_trust)"
+ tu="$(toolchain_value "$tp" toolchain_url)"
+ tt="$(toolchain_value "$tp" toolchain_trust)"
echo "$tn.toolchain_url: $tu"
echo "$tn.toolchain_trust: $tt"
@@ -410,22 +410,22 @@ fi
# Calculate the file checksum using the shaNNNsum utility.
#
-function tc_checksum () # <toolchain-prefix> <file>
+function toolchain_checksum () # <toolchain-prefix> <file>
{
- "$(tc_value "$1" toolchain_csum)sum" -b "$2" | \
+ "$(toolchain_value "$1" toolchain_csum)sum" -b "$2" | \
sed -n -re 's/^([^ ]+) .+$/\1/p'
}
# Fetch a file from the sums file into $toolchain_root, verify its checksum,
# and make a predictable name (without version) symlink.
#
-function tc_fetch () # <toolchain-prefix> <line>
+function toolchain_fetch () # <toolchain-prefix> <line>
{
local s p f u l tp tu tr tv
tp="$1"
- tu="$(tc_value "$tp" toolchain_url)"
- tr="$(tc_value "$tp" toolchain_root)"
+ tu="$(toolchain_value "$tp" toolchain_url)"
+ tr="$(toolchain_value "$tp" toolchain_root)"
s="$(sed -n -re 's/^([^ ]+) .+$/\1/p' <<<"$2")" # Checksum.
p="$(sed -n -re 's/^[^ ]+ \*([^ ]+)$/\1/p' <<<"$2")" # File path (relative).
@@ -439,7 +439,7 @@ function tc_fetch () # <toolchain-prefix> <line>
# Extract the version.
#
- tv="$(tc_value "$tp" toolchain_ver)"
+ tv="$(toolchain_value "$tp" toolchain_ver)"
if [ -z "$tv" ]; then
tv="$(sed -n -re 's/build2-toolchain-(.+)\.tar.*/\1/p' <<<"$f")"
@@ -478,7 +478,7 @@ function tc_fetch () # <toolchain-prefix> <line>
info "verifying checksum for $f"
local cs
- cs="$(tc_checksum "$tp" "$tr/$f")"
+ cs="$(toolchain_checksum "$tp" "$tr/$f")"
if [ "$cs" != "$s" ]; then
info "checksum mismatch for $u"
@@ -494,12 +494,12 @@ function tc_fetch () # <toolchain-prefix> <line>
# Bootstrap the toolchain.
#
-function tc_bootstrap () # <toolchain-name>
+function toolchain_bootstrap () # <toolchain-name>
{
local tn="$1"
local tp="${toolchains["$tn"]}"
- local tr="$(tc_value "$tp" toolchain_root)"
- local tf="$(tc_value "$tp" toolchain_file)"
+ local tr="$(toolchain_value "$tp" toolchain_root)"
+ local tf="$(toolchain_value "$tp" toolchain_file)"
# Fetch files according to the sums file. Skip empty lines and those that
# start with '#'.
@@ -509,13 +509,13 @@ function tc_bootstrap () # <toolchain-name>
readarray -t ls < <(sed -e '/^\s*#/d;/^\s*$/d' "$tr/$tf")
for l in "${ls[@]}"; do
- if ! tc_fetch "$tp" "$l"; then
+ if ! toolchain_fetch "$tp" "$l"; then
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)"
+ local tv="$(toolchain_value "$tp" toolchain_ver)" # Should be set by fetch().
+ local tt="$(toolchain_value "$tp" toolchain_trust)"
# Bootstrap in /tmp/toolchain/$tn/, install to /build/toolchain/$tn/.
#
@@ -561,7 +561,7 @@ function tc_bootstrap () # <toolchain-name>
# Check if we need to build/start or rebuild/restart the bbot agent. Return
# 0 if nothing to do, 1 for upgrades, 2 for first build, and 3 for failure.
#
-function bb_check () # <toolchain-name>
+function bbot_check () # <toolchain-name>
{
local tn="$1"
@@ -608,9 +608,9 @@ function bb_check () # <toolchain-name>
}
# Build and start bbot agent using the bpkg configuration created by
-# tc_bootstrap().
+# toolchain_bootstrap().
#
-function bb_start () # <toolchain-name>
+function bbot_start () # <toolchain-name>
{
local tn="$1"
@@ -731,10 +731,10 @@ while true; do
#
for tn in "${toolchain_names[@]}"; do
tp="${toolchains["$tn"]}"
- tu="$(tc_value "$tp" toolchain_url)"
+ tu="$(toolchain_value "$tp" toolchain_url)"
- tr="$(tc_value "$tp" toolchain_root)"
- tf="$(tc_value "$tp" toolchain_file)"
+ tr="$(toolchain_value "$tp" toolchain_root)"
+ tf="$(toolchain_value "$tp" toolchain_file)"
p="$tr/$tf"
mkdir -p "$tr"
@@ -754,8 +754,8 @@ while true; do
#
if [ "$f" != "$p" ]; then
- ts="$(tc_value "$tp" toolchain_file_csum)"
- cs="$(tc_checksum "$tp" "$f")"
+ ts="$(toolchain_value "$tp" toolchain_file_csum)"
+ cs="$(toolchain_checksum "$tp" "$f")"
if [ "$ts" != "$cs" ]; then
email "rebooting because of new $tn toolchain" <<EOF
@@ -768,18 +768,18 @@ EOF
else
# This is the first run, bootstrap the toolchain.
#
- declare "${tp}toolchain_file_csum=$(tc_checksum "$tp" "$f")"
+ declare "${tp}toolchain_file_csum=$(toolchain_checksum "$tp" "$f")"
# If we fail, we simply wait for a new toolchain to be uploaded (or
# some manual intervention).
#
- # Note that because of the pipe tc_bootstrap() will run in subshell
- # and any variables it sets (like toolchain_ver) won't be visible to
- # us.
+ # Note that because of the pipe toolchain_bootstrap() will run in
+ # subshell and any variables it sets (like toolchain_ver) won't be
+ # visible to us.
#
info "bootstrapping $tn toolchain..."
- tc_bootstrap "$tn" 2>&1 | tee "$tr/bootstrap-$count.log" 1>&2
+ toolchain_bootstrap "$tn" 2>&1 | tee "$tr/bootstrap-$count.log" 1>&2
if [ "${PIPESTATUS[0]}" -eq 0 ]; then
v="$(cat $tr/version)"
@@ -817,7 +817,7 @@ EOF
fi
s=
- bb_check "$tn" 2>&1 | tee "$tr/bbot-$count.log" 1>&2
+ bbot_check "$tn" 2>&1 | tee "$tr/bbot-$count.log" 1>&2
case "${PIPESTATUS[0]}" in
0)
@@ -832,7 +832,7 @@ EOF
# Note: appending to the same log.
#
- bb_start "$tn" 2>&1 | tee -a "$tr/bbot-$count.log" 1>&2
+ bbot_start "$tn" 2>&1 | tee -a "$tr/bbot-$count.log" 1>&2
if [ "${PIPESTATUS[0]}" -eq 0 ]; then
s="${s}started bbot-agent@$tn"