#!/bin/bash set -eu scripts=$(dirname $0) # shellcheck source=jenkins-helpers.sh . $scripts/jenkins-helpers.sh usage () { cat < ABE branch to use; default "tested" --generate-abe true/false Generate ABE snapshots; default "true" --generate-misc true/false Generate misc repo and file caches; default "true" --update-abe-git true/false Update ABE git repos; default "true" --verbose true/false Be verbose; default "false" EOF exit 1 } convert_args_to_variables "$@" obligatory_variables cache_dir declare -g cache_dir abe_branch="${abe_branch-tested}" generate_abe="${generate_abe-true}" generate_bmk="${generate_bmk-false}" generate_misc="${generate_misc-true}" update_abe_git="${update_abe_git-true}" verbose="${verbose-false}" if $verbose; then verbose="set -x" else verbose="set +x" fi $verbose # Checkout GNU tools into $cache_dir using ABE generate_abe_snapshots () { set -e $verbose local abe_temp abe_temp="$(dirname "$0")/abe" rm -rf $abe_temp 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=$cache_dir if [ -e $HOME/.aberc ]; then echo "ERROR: $HOME/.aberc detected and it might override ABE's behavior" exit 1 fi targets=( aarch64-linux-gnu aarch64-none-elf arm-linux-gnueabihf arm-none-eabi i686-linux-gnu x86_64-linux-gnu ) for t in "${targets[@]}"; do for c in gcc5 gcc6 gcc7; do ./abe.sh --target $t --extraconfigdir config/$c --retrieve all done done } # Checkout git repos generate_git_cache () { set -e $verbose for repo in "$@"; do dir=$(basename $repo) 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 fi done } # Checkout bmk repos generate_bmk_cache () { set -e $verbose # Clone the Linux kernel and LLVM monorepo. # Subsequent calls will update it. repos=( ssh://dev-private-git.linaro.org/restricted-benchmarks/CPU2000.git ssh://dev-private-git.linaro.org/restricted-benchmarks/CPU2006.git ssh://dev-private-git.linaro.org/restricted-benchmarks/CPU2017.git ) generate_git_cache "${repos[@]}" } # Checkout other repos that we might need generate_misc_files () { set -e $verbose # 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 $cache_dir chmod -R ugo+rx $cache_dir/Foundation_Platformpkg # Clone the Linux kernel and LLVM monorepo. # Subsequent calls will update it. repos=( https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git https://github.com/llvm/llvm-project.git https://git.linaro.org/toolchain/jenkins-scripts.git ) generate_git_cache "${repos[@]}" } update_git_repos () { set -e $verbose local dir="$1" while IFS= read -r -d '' repo_git do ( local repo repo=$(dirname "$repo_git") cd "$repo" # Update and prune local clone run_with_timeout_and_retry 1h 3 git remote update -p find -maxdepth 1 ! -name .git ! -name . -print0 \ | xargs -0 rm -rf ) done < <(find "$dir" -name .git -type d -print0) } if $generate_abe; then mkdir -p $cache_dir # Remove *.asc files to fix cached incorrect md5sum files rm -f $cache_dir/*.asc update_git_repos $cache_dir generate_abe_snapshots fi if $generate_bmk; then generate_bmk_cache fi if $generate_misc; then generate_misc_files fi if $update_abe_git; then update_git_repos $cache_dir fi echo "Snapshots status:" du -hs $cache_dir/*