summaryrefslogtreecommitdiff
path: root/round-robin.sh
diff options
context:
space:
mode:
authorDavid Spickett <david.spickett@linaro.org>2020-04-20 16:46:03 +0100
committerDavid Spickett <david.spickett@linaro.org>2020-04-22 13:51:18 +0100
commit7dac1306e35858ef6485a0abf6222f6e13a28ee0 (patch)
treed20710118c945284c8bd77ee53d1b158d9bcfdc0 /round-robin.sh
parent22593d90ca7ebcb06b4ff84389f176b1f9279eb3 (diff)
round-robin.sh: Fix shellcheck warnings
* Disable "referenced but not assigned" for a bunch of parameters. These are set by the wrappers around this script. * Quote a bunch of expansions * Use * to get a string from arrays * When finding files split by null terminator so it doesn't break for filenames with spaces. * Declare and assign separately so we don't hide return values. * Ignore unsafe rm in prepare_abe since we know we'll be in the abe folder. * Add sanity check that pwd isn't / for build_llvm, then ignore the warning from the rm. Change-Id: I0b54e55946d56eef0d48b10c3ccfa30059809d46
Diffstat (limited to 'round-robin.sh')
-rw-r--r--round-robin.sh65
1 files changed, 42 insertions, 23 deletions
diff --git a/round-robin.sh b/round-robin.sh
index 242c81b7..6764f348 100644
--- a/round-robin.sh
+++ b/round-robin.sh
@@ -51,10 +51,12 @@ declare -gA rr
# Predicate function to determine whether there is regression between
# 2 sets of results.
+# shellcheck disable=SC2154
rr[no_regression_p]=no_regression_p
# Hook to break up updated component (see print_updated_components) into
# smaller sets: print one set per line. By default, breakup into singletons.
+# shellcheck disable=SC2154
rr[breakup_updated_components]=breakup_updated_components
# Print round-robin components that are being updated in this build
@@ -110,6 +112,7 @@ reset_artifacts ()
# - ${rr[top_artifacts]}/console.log and $run_step_artifacts/console.log, which
# are being written to by run_step().
# - ${rr[top_artifacts]}/jenkins/*, which is cleaned by tcwg_kernel.yaml.
+ # shellcheck disable=SC2154
fresh_dir $run_step_top_artifacts \
$run_step_top_artifacts/console.log \
$run_step_artifacts/console.log \
@@ -122,6 +125,7 @@ reset_artifacts ()
# base-artifacts repo is big and changes all the time, so we
# fetch only the $baseline_branch, instead of all branches.
if [ x"${rr[update_baseline]}" = x"init" ]; then
+ # shellcheck disable=SC2154
rr[base-artifacts_rev]=empty
single_branch=empty
else
@@ -210,22 +214,25 @@ prepare_abe ()
cd abe
# Add ccache wrappers.
- rm -rf $(pwd)/bin
- mkdir $(pwd)/bin
+ # shellcheck disable=SC2115
+ rm -rf "$(pwd)/bin"
+ mkdir "$(pwd)/bin"
- cat > $(pwd)/bin/gcc <<EOF
+ cat > "$(pwd)/bin/gcc" <<EOF
#!/bin/sh
exec ccache /usr/bin/gcc "\$@"
EOF
- chmod +x $(pwd)/bin/gcc
+ chmod +x "$(pwd)/bin/gcc"
- cat > $(pwd)/bin/g++ <<EOF
+ cat > "$(pwd)/bin/g++" <<EOF
#!/bin/sh
exec ccache /usr/bin/g++ "\$@"
EOF
- chmod +x $(pwd)/bin/g++
+ chmod +x "$(pwd)/bin/g++"
- export PATH=$(pwd)/bin:$PATH
+ local PATH
+ PATH=$(pwd)/bin:$PATH
+ export PATH
./configure --with-git-reference-dir=/home/tcwg-buildslave/snapshots-ref
)
@@ -324,7 +331,7 @@ build_abe ()
done
if [ x"$project" = x"gcc" -a $# != 0 ]; then
- stage="$stage $@"
+ stage="$stage $*"
fi
action="--build $project"
@@ -346,8 +353,8 @@ build_abe ()
git_dir="$git_dir.git"
git_path="abe/snapshots/$git_dir"
rm -rf $git_path $git_path~master
- ln -s $(pwd)/$project $git_path
- ln -s $(pwd)/$project $git_path~master
+ ln -s "$(pwd)/$project" $git_path
+ ln -s "$(pwd)/$project" $git_path~master
custom_abe_src_opt="$project=http://git.l.o/$git_dir~master --disable update"
fi
@@ -363,7 +370,9 @@ build_abe ()
set +f; rm -rf builds/*/*/$git_dir*; set -f
fi
- export PATH=$(pwd)/bin:$PATH
+ local PATH
+ PATH=$(pwd)/bin:$PATH
+ export PATH
if [ x"$component" != x"stage2" ]; then
# TODO: Fix install_sysroot logic in ABE.
@@ -391,7 +400,7 @@ build_abe ()
if $check; then
mkdir -p ${rr[top_artifacts]}/sumfiles
- find builds/ -name "*.sum" | xargs -r cp -t ${rr[top_artifacts]}/sumfiles/
+ find builds/ -name "*.sum" -print0 | xargs -0 -r cp -t ${rr[top_artifacts]}/sumfiles/
fi
)
}
@@ -411,32 +420,41 @@ build_llvm ()
rsync -a --del llvm/clang/ llvm-src/tools/clang/
rsync -a --del llvm/lld/ llvm-src/tools/lld/
+ # Sanity check
+ if [[ $(pwd) == "/" ]]; then
+ echo "pwd is unexpectedly \"/\", exiting"
+ exit 1;
+ fi
+
# Setup ccache and ninja wrappers.
- rm -rf $(pwd)/bin
- mkdir $(pwd)/bin
+ # shellcheck disable=SC2115
+ rm -rf "$(pwd)/bin"
+ mkdir "$(pwd)/bin"
- cat > $(pwd)/bin/cc <<EOF
+ cat > "$(pwd)/bin/cc" <<EOF
#!/bin/sh
exec ccache /usr/bin/gcc "\$@"
EOF
- chmod +x $(pwd)/bin/cc
+ chmod +x "$(pwd)/bin/cc"
- cat > $(pwd)/bin/c++ <<EOF
+ cat > "$(pwd)/bin/c++" <<EOF
#!/bin/sh
exec ccache /usr/bin/g++ "\$@"
EOF
- chmod +x $(pwd)/bin/c++
+ chmod +x "$(pwd)/bin/c++"
if [ -f /usr/local/bin/ninja.bin ]; then
# Use ninja configuration from llvm buildbots to avoid running out of RAM.
- cat > $(pwd)/bin/ninja <<EOF
+ cat > "$(pwd)/bin/ninja" <<EOF
#!/bin/sh
exec /usr/local/bin/ninja.bin -m 30 -M 50 -D 5000 "\$@"
EOF
- chmod +x $(pwd)/bin/ninja
+ chmod +x "$(pwd)/bin/ninja"
fi
- export PATH=$(pwd)/bin:$PATH
+ local PATH
+ PATH=$(pwd)/bin:$PATH
+ export PATH
local binutils_incdir
# Freshen up build and install directories. We rely on ccache for fast rebuilds.
@@ -451,7 +469,7 @@ EOF
mkdir -p llvm-build
cd llvm-build
- cmake -G Ninja ../llvm-src -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True -DCMAKE_INSTALL_PREFIX=../llvm-install -DLLVM_TARGETS_TO_BUILD=$(print_llvm_target ${rr[target]}) -DLLVM_BINUTILS_INCDIR=$binutils_incdir
+ cmake -G Ninja ../llvm-src -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True -DCMAKE_INSTALL_PREFIX=../llvm-install "-DLLVM_TARGETS_TO_BUILD=$(print_llvm_target ${rr[target]})" -DLLVM_BINUTILS_INCDIR=$binutils_incdir
ccache -z
ninja
ninja install
@@ -538,7 +556,8 @@ check_regression ()
fi
# We've got a regression. Generate trigger-* files.
- local single_component=$(print_single_updated_component)
+ local single_component
+ single_component=$(print_single_updated_component)
local trigger_dest
if [ x"${rr[update_baseline]}" = x"update" ]; then