blob: 8dad0db7d5be75fa11a6b0eafadb1ac4efe7b130 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
#!/bin/bash
set -eu
scripts=$(dirname $0)
# shellcheck source=jenkins-helpers.sh
. $scripts/jenkins-helpers.sh
usage ()
{
cat <<EOF
Usage: $0 --dir-abe ABE/SNAPSHOTS [--OPT true/false]
This script generates source caches.
"--OPT true/false" options specify what to do:
--abe-branch <branch> 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/*
|