diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-04-12 10:38:02 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2017-04-13 15:46:45 +0000 |
commit | 81342374afdaccfe06c29bbb5ad198cf30c82c72 (patch) | |
tree | 0f65560ccbe5add75f91d94451b7f3cb3b01dd1a /tcwg-generate-source-cache.sh | |
parent | 54913cab06b842fb07cad72a61145f2abb9ffa4f (diff) |
tcwg-update-snapshots_ref.sh: Split into two scripts
... tcwg-generate-source-cache.sh and tcwg-rsync-dir.sh
Change-Id: Ic435d331dd5c035fa41e057a8d26c8a8e565dc8c
Diffstat (limited to 'tcwg-generate-source-cache.sh')
-rwxr-xr-x | tcwg-generate-source-cache.sh | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/tcwg-generate-source-cache.sh b/tcwg-generate-source-cache.sh new file mode 100755 index 00000000..38a859ec --- /dev/null +++ b/tcwg-generate-source-cache.sh @@ -0,0 +1,101 @@ +#!/bin/bash + +set -e + +usage () +{ + cat <<EOF +Usage: $0 [-r] [-v] [-h] [machine1 machine2 ...] + This scripts generates and rsync's reference snapshots to machines + + -r: Only rsync snapshots-ref to machines + -v: Be verbose + -h: Print help +EOF +} + +generate=true +snapshots_dir=$HOME/snapshots-ref +verbose="set +x" + +while getopts "hrv" OPTION; do + case $OPTION in + h) + usage + exit 0 + ;; + r) + generate=false + ;; + v) verbose="set -x" ;; + esac +done + +$verbose + +shift $((OPTIND-1)) + +# Checkout into $snapshots_dir using ABE +generate_snapshots () +{ + local abe_temp="$(dirname "$0")/abe" + + rm -rf $abe_temp + git clone --branch stable --depth 1 https://git-us.linaro.org/toolchain/abe $abe_temp + + cd $abe_temp + ./configure --with-local-snapshots=${snapshots_dir}-new + + 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 --checkout all + done + done +} + +update_git_repos () { + for repo in `ls ${snapshots_dir}-new/ | grep "\.git\$"`; do + ( + cd ${snapshots_dir}-new/$repo + # Update and prune local clone + git remote update -p + # Cleanup stale branches + git branch | grep -v \* | xargs -r git branch -D + ) + done +} + +if $generate; then + mkdir -p ${snapshots_dir}-new + + # Remove *.asc files to fix cached incorrect md5sum files + rm -f ${snapshots_dir}-new/*.asc + + update_git_repos + generate_snapshots + + # Remove checked-out branch directories + rm -rf ${snapshots_dir}-new/*~* + + # Remove md5sums to force ABE to fetch canonical version via http://. + rm -f ${snapshots_dir}-new/md5sums +fi + +update_git_repos + +echo "Snapshots status:" +du -hs $snapshots_dir-new/* |