summaryrefslogtreecommitdiff
path: root/tcwg-generate-source-cache.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tcwg-generate-source-cache.sh')
-rwxr-xr-xtcwg-generate-source-cache.sh55
1 files changed, 20 insertions, 35 deletions
diff --git a/tcwg-generate-source-cache.sh b/tcwg-generate-source-cache.sh
index dc5aca04..e73c3c85 100755
--- a/tcwg-generate-source-cache.sh
+++ b/tcwg-generate-source-cache.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-set -e
+set -eu
scripts=$(dirname $0)
# shellcheck source=jenkins-helpers.sh
@@ -21,25 +21,15 @@ EOF
exit 1
}
-snapshots_dir=""
-abe_branch=tested
-generate_abe=true
-generate_misc=true
-update_abe_git=true
-verbose=false
-
-getopt -l abe-branch:,dir-abe:,generate-abe:,generate-misc:,update-abe-git:,verbose: -Q -- "$@"
-while test $# -gt 0; do
- case $1 in
- --abe-branch) abe_branch="$2"; shift ;;
- --dir-abe) snapshots_dir="$2"; shift ;;
- --generate-abe) generate_abe="$2"; shift ;;
- --generate-misc) generate_misc="$2"; shift ;;
- --update-abe-git) update_abe_git="$2"; shift ;;
- --verbose) verbose="$2"; shift ;;
- esac
- shift
-done
+convert_args_to_variables "$@"
+obligatory_variables cache_dir
+declare -g cache_dir
+
+abe_branch="${abe_branch-tested}"
+generate_abe="${generate_abe-true}"
+generate_misc="${generate_misc-true}"
+update_abe_git="${update_abe_git-true}"
+verbose="${verbose-false}"
if $verbose; then
verbose="set -x"
@@ -49,12 +39,7 @@ fi
$verbose
-if [ x"$snapshots_dir" = x"" ]; then
- echo "ERROR: no --dir-abe DIR option"
- usage
-fi
-
-# Checkout GNU tools into $snapshots_dir using ABE
+# Checkout GNU tools into $cache_dir using ABE
generate_abe_snapshots ()
{
set -e
@@ -67,7 +52,7 @@ generate_abe_snapshots ()
run_with_timeout_and_retry 10m 3 git clone --branch ${abe_branch} --depth 1 https://git-us.linaro.org/toolchain/abe $abe_temp
cd $abe_temp
- ./configure --with-local-snapshots=$snapshots_dir
+ ./configure --with-local-snapshots=$cache_dir
if [ -e $HOME/.aberc ]; then
echo "ERROR: $HOME/.aberc detected and it might override ABE's behavior"
@@ -99,8 +84,8 @@ generate_misc_files ()
# Distribute Foundation Model to the builders so that containers
# running there can access Foundation Model via a bind-mount for
# bare-metal testing.
- tar xf /home/tcwg-buildslave/public_html/infrastructure/FM000-KT-00035-r9p5-41rel0.tgz -C $snapshots_dir
- chmod -R ugo+rx $snapshots_dir/Foundation_Platformpkg
+ tar xf /home/tcwg-buildslave/public_html/infrastructure/FM000-KT-00035-r9p5-41rel0.tgz -C $cache_dir
+ chmod -R ugo+rx $cache_dir/Foundation_Platformpkg
# Clone the Linux kernel and LLVM monorepo.
# Subsequent calls will update it.
@@ -111,7 +96,7 @@ generate_misc_files ()
)
for repo in "${repos[@]}"; do
dir=$(basename $repo)
- dir=$snapshots_dir/$dir
+ dir=$cache_dir/$dir
if [ ! -d $dir/.git ]; then
rm -rf $dir
run_with_timeout_and_retry 1h 3 git clone --no-checkout $repo $dir
@@ -139,12 +124,12 @@ update_git_repos () {
}
if $generate_abe; then
- mkdir -p $snapshots_dir
+ mkdir -p $cache_dir
# Remove *.asc files to fix cached incorrect md5sum files
- rm -f $snapshots_dir/*.asc
+ rm -f $cache_dir/*.asc
- update_git_repos $snapshots_dir
+ update_git_repos $cache_dir
generate_abe_snapshots
fi
@@ -153,8 +138,8 @@ if $generate_misc; then
fi
if $update_abe_git; then
- update_git_repos $snapshots_dir
+ update_git_repos $cache_dir
fi
echo "Snapshots status:"
-du -hs $snapshots_dir/*
+du -hs $cache_dir/*