-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
executable file
·227 lines (187 loc) · 5.8 KB
/
run
File metadata and controls
executable file
·227 lines (187 loc) · 5.8 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
set -eu
prep-mock-config() {
local tmpfs_build=$1
rm -rf mock-config
mkdir -p mock-config
cp -a mock-config-base/epel-7-with-local-deps.cfg mock-config/epel-7-with-local-deps.cfg
sed -i mock-config/epel-7-with-local-deps.cfg -e 's/x86_64/'$(uname -p)'/g'
if [[ $tmpfs_build == "1" ]] ; then
echo Enabling tmpfs build
echo """
config_opts['plugin_conf']['tmpfs_enable'] = True
config_opts['plugin_conf']['tmpfs_opts'] = {}
config_opts['plugin_conf']['tmpfs_opts']['required_ram_mb'] = 128000
config_opts['plugin_conf']['tmpfs_opts']['max_fs_size'] = '40g'
config_opts['plugin_conf']['tmpfs_opts']['mode'] = '0755'
config_opts['plugin_conf']['tmpfs_opts']['keep_mounted'] = True
""" >> mock-config/epel-7-with-local-deps.cfg
fi
}
root-setup() {
local tmpfs_build=0
while [[ $# != 0 ]] ; do
if [[ "$1" == "--tmpfs-build" ]] || [[ "$1" == "-t" ]] ; then
local tmpfs_build=1
shift
continue
fi
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] ; then
echo "--tmpfs-build -t"
exit 0
fi
break
done
sudo yum install -y epel-release sudo
sudo yum install -y fedpkg createrepo wget
prep-mock-config $tmpfs_build
if [[ -e templates/epel-7.tpl ]] ; then
local include=templates/epel-7.tpl
elif [[ -e /etc/mock/epel-7-$(uname -i).cfg ]] ; then
local include="/etc/mock/epel-7-$(uname -i).cfg"
else
echo "Cannot define a valid Mock configuration"
exit -1
fi
echo 'include("'${include}'")' > mock-config/epel-7-with-local-deps-include.cfg
sudo bash -c 'cat mock-config/epel-7-with-local-deps-include.cfg > /etc/mock/epel-7-with-local-deps.cfg'
rm -f mock-config/epel-7-with-local-deps-include.cfg
sudo bash -c 'cat mock-config/epel-7-with-local-deps.cfg >> /etc/mock/epel-7-with-local-deps.cfg'
rm -rf mock-config/
if [[ ! -x /opt/repo/epel-7-with-local-deps ]] ; then
sudo mkdir -p /opt/repo/epel-7-with-local-deps
sudo chown $(id -u).$(id -g) /opt/repo/epel-7-with-local-deps
fi
createrepo /opt/repo/epel-7-with-local-deps
mock --init --root epel-7-with-local-deps
}
build-base-image() {
echo "Updating base Docker image"
#
# Image hashes taken from:
#
# https://hub.docker.com/_/centos?tab=tags&page=1&ordering=last_updated
#
case $(uname -p) in
x86_64)
BASE_IMAGE=c2f1d5a9c0a81350fa0ad7e1eee99e379d75fe53823d44b5469eb2eb6092c941
;;
aarch64)
BASE_IMAGE=43964203bf5d7fe38c6fca6166ac89e4c095e2b0c0a28f6c7c678a1348ddc7fa
;;
*)
echo "Architecture not supported"
;;
esac
echo """
# CentOS 7
FROM centos@sha256:${BASE_IMAGE}
RUN rm -f /root/*.cfg
RUN mkdir /workspace
RUN yum install -y epel-release sudo
RUN yum install -y fedpkg createrepo wget
""" > Dockerfile
mkdir -p empty/
docker build -f Dockerfile -t llvm-rpm:base empty/
rmdir empty
rm -f Dockerfile
}
spin-up-instance() {
docker rm -f llvm-rpm-run 2>/dev/null || true
mkdir -p ${PWD}/repo
docker run --rm -dit --name llvm-rpm-run --privileged -w /workspace -v /tmp:/tmp \
-v ${PWD}/repo:/opt/repo/epel-7-with-local-deps -v ${PWD}:/workspace llvm-rpm:base bash
}
pkgbuild() {
echo "Building $1"
local dest=/opt/repo/epel-7-with-local-deps
local name=$1
cd pkgs/${name}
shift
while [[ $# != 0 ]] ; do
if [[ "$1" == "--name" ]] ; then
shift
local name=$1
shift
continue
fi
break
done
rm -rf *.src.rpm
rm -rf results_${name}*
fedpkg --name ${name} --release el7 mockbuild --root epel-7-with-local-deps "$@"
rm -rf ${dest}/results_${name}
mv results_${name} ${dest}
createrepo ${dest}
cd ../..
}
under-container() {
local skip_build_image=0
local skip_spin_up_instance=0
local setupparams=""
while [[ $# != 0 ]] ; do
if [[ "$1" == "--skip-build-base-image" ]] || [[ "$1" == "-s" ]] ; then
local skip_build_image=1
shift
continue
fi
if [[ "$1" == "--skip-spin-up-image" ]] || [[ "$1" == "-r" ]] ; then
local skip_spin_up_instance=1
shift
continue
fi
if [[ "$1" == "--tmpfs-build" ]] || [[ "$1" == "-t" ]] ; then
setupparams="${setupparams} -t"
shift
continue
fi
if [[ "$1" == "--help" ]] || [[ "$1" == "-h" ]] ; then
echo "--skip-build-base-image -s"
echo "--skip-spin-up-image -r"
echo "--tmpfs-build -t"
exit 0
fi
break
done
if [[ "${skip_build_image}" == "0" ]] ; then
build-base-image
fi
if [[ "${skip_spin_up_instance}" == "0" ]] ; then
spin-up-instance
docker exec -it llvm-rpm-run ./run root-setup ${setupparams}
fi
docker exec -it llvm-rpm-run ./run "$@"
}
stage0() {
pkgbuild cmake --without test --with bootstrap
}
stage1() {
local commit=$(grep 'global gitcommit' \
pkgs/llvm-monolith/llvm.spec | awk -F" " '{print $3}')
if [[ ! -e pkgs/llvm-monolith/${commit}.tar.gz ]] ; then
wget https://github.com/llvm/llvm-project/archive/${commit}.tar.gz -O \
pkgs/llvm-monolith/${commit}.tar.gz.tmp
mv pkgs/llvm-monolith/${commit}.tar.gz.tmp pkgs/llvm-monolith/${commit}.tar.gz
fi
pkgbuild llvm-monolith --name llvm-11.1.0 --with bootstrap
}
stage2() {
pkgbuild llvm --with stage1 --without check
pkgbuild python-lit --without check
pkgbuild clang --with python3 --with stage1 --with static_link --without check
pkgbuild compiler-rt --with bootstrap --with stage1
pkgbuild libcxx --with bootstrap --with stage1
pkgbuild libcxxabi --with stage1
pkgbuild lld --with stage1 --without check
}
stage3() {
pkgbuild libcxx
pkgbuild lld --with stage2 --without check
}
build-all() {
stage0
stage1
stage2
stage3
}
"$@"