-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild-all.sh
executable file
·77 lines (65 loc) · 1.9 KB
/
build-all.sh
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
#!/bin/bash
function cleanup() {
echo "Stopping container..."
docker stop "${CTID}" >/dev/null
echo "Removing container..."
docker rm "${CTID}" >/dev/null
}
function build() {
CTID="$1"
tool="$2"
shift; shift;
buildopts="$@"
echo "Building $tool $buildopts"
docker cp "${tool}/${tool}.spec" "$CTID:/root/"
for p in "${tool}"/*.patch; do
docker cp "$p" "${CTID}:/root/rpmbuild/SOURCES"
done || true
docker exec "$CTID" spectool -g -R "/root/${tool}.spec"
docker exec "$CTID" yum-builddep -y "/root/${tool}.spec"
docker exec "$CTID" rpmbuild -bb "/root/${tool}.spec" $buildopts
docker exec "$CTID" rm -rf /root/rpmbuild/BUILD
docker exec "$CTID" mkdir /root/rpmbuild/BUILD
}
if docker -v |grep -q podman; then
echo "using podman, test likely wont work"
PODMAN=1
fi
TAG=""
while [[ $# -gt 0 ]]; do
case $1 in
--image-tag)
TAG=$2
shift
;;
*)
echo "Unkown option: $1"
;;
esac
shift
done
if [ -z $TAG ]; then
echo "No tag specified, using quay.io/fbs/el7-bpf-specs:llvm_12_latest"
TAG="quay.io/fbs/el7-bpf-specs:llvm_12_latest"
fi
echo "Using $TAG as base"
CTID=$(docker create -t "$TAG")
if [ $? -ne 0 ]; then
>&2 echo "Failed to spawn docker CT"
exit 1
fi
set -e
docker start "$CTID"
docker exec -i "$CTID" rm -f '/etc/yum.repos.d/CentOS-SCLo-scl-rh.repo' '/etc/yum.repos.d/CentOS-SCLo-scl.repo'
docker exec -i "$CTID" yum install -y gcc
build "${CTID}" "bpftool"
build "${CTID}" "bcc"
docker exec -i "${CTID}" find /root/rpmbuild/RPMS/ -name '*bcc*.rpm' -exec yum install -y {} +
build "${CTID}" "bpftrace"
docker cp "${CTID}:/root/rpmbuild/RPMS" .
cleanup
find "RPMS" -name "*ebpftoolsbuilder*" -delete
echo "##############################################"
echo "Finished:"
echo "Builder Image: ${TAG}"
echo "RPMs can be found in: $(readlink -f RPMS)"