#!/bin/bash set -e usage () { cat < ABE branch to use; default "tested" --generate-abe true/false Generate ABE snapshots; default "true" --generate-llvm true/false Generate LLVM reference repos; 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" --update-llvm-git true/false Update LLVM git repos; default "true" --verbose true/false Be verbose; default "false" EOF exit 1 } snapshots_dir="" llvm_reference="" abe_branch=tested generate_abe=true generate_llvm=true generate_misc=true update_abe_git=true update_llvm_git=true verbose=false OPTS="`getopt -l abe-branch:,dir-abe:,dir-llvm:,generate-abe:,generate-llvm:,generate-misc:,update-abe-git:,update-llvm-git:,verbose: -- "$@"`" while test $# -gt 0; do case $1 in --abe-branch) abe_branch="$2"; shift ;; --dir-abe) snapshots_dir="$2"; shift ;; --dir-llvm) llvm_reference="$2"; shift ;; --generate-abe) generate_abe="$2"; shift ;; --generate-llvm) generate_llvm="$2"; shift ;; --generate-misc) generate_misc="$2"; shift ;; --update-abe-git) update_abe_git="$2"; shift ;; --update-llvm-git) update_llvm_git="$2"; shift ;; --verbose) verbose="$2"; shift ;; esac shift done if $verbose; then verbose="set -x" else verbose="set +x" fi $verbose if [ x"$snapshots_dir" = x"" ]; then echo "ERROR: no --dir-abe DIR option" usage fi if [ x"$llvm_reference" = x"" ]; then echo "ERROR: no --dir-llvm DIR option" usage fi # Checkout GNU tools into $snapshots_dir using ABE generate_abe_snapshots () { set -e $verbose local abe_temp="$(dirname "$0")/abe" rm -rf $abe_temp 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 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 LLVM tools into $llvm_reference randomise_llvm_bobblybits () { set -e $verbose # Using the llvm scripts would be over-complicated for such a simple task # We also don't need all repos (like clang-tools-extra, zorg or www) local gitroot=https://git.linaro.org/toolchain/llvm local repos="llvm clang compiler-rt lld libcxx libcxxabi libunwind lldb test-suite lnt openmp" for repo in $repos; do if [ -d "$llvm_reference/$repo" ]; then continue; fi git clone --no-checkout "$gitroot/$repo" "$llvm_reference/$repo" done } # 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/public_html/infrastructure/FM000-KT-00035-r9p5-41rel0.tgz -C $snapshots_dir chmod -R ugo+rx $snapshots_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 ) for repo in "${repos[@]}"; do dir=$(basename $repo) dir=$snapshots_dir/$dir if [ ! -d $dir/.git ]; then rm -rf $dir git clone --no-checkout $repo $dir fi done } update_git_repos () { set -e $verbose local dir="$1" for repo_git in "$dir"/*/.git; do ( local repo repo=$(dirname "$repo_git") cd "$repo" # Update and prune local clone git remote update -p find -maxdepth 1 ! -name .git ! -name . -print0 \ | xargs -0 rm -rf ) done } if $generate_abe; then mkdir -p $snapshots_dir # Remove *.asc files to fix cached incorrect md5sum files rm -f $snapshots_dir/*.asc update_git_repos $snapshots_dir generate_abe_snapshots fi if $generate_llvm; then mkdir -p $llvm_reference update_git_repos $llvm_reference randomise_llvm_bobblybits fi if $generate_misc; then generate_misc_files fi if $update_abe_git; then update_git_repos $snapshots_dir fi if $update_llvm_git; then update_git_repos $llvm_reference fi echo "Snapshots status:" du -hs $snapshots_dir/* echo "LLVM reference status:" du -hs $llvm_reference/*