-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain-builder-entrypoint.sh
executable file
·152 lines (132 loc) · 2.65 KB
/
main-builder-entrypoint.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
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
#!/bin/bash
set -euo pipefail
usage()
{
cat >&2 <<EOF
Usage:
docker run --rm \\
-v /var/run/docker.sock:/var/run/docker.sock \\
IMAGE -P [-b BUILDER_IMAGE_PREFIX/] [-- BUILDER_OPTIONS...]
docker run --rm \\
-v /var/run/docker.sock:/var/run/docker.sock \\
-v WORKSPACE:/workspace \\
-v SYSDIG:/sysdig \\
-v KERNELS:/kernels \\
IMAGE -B [-b BUILDER_IMAGE_PREFIX/] [-- BUILDER_OPTIONS...]
docker run --rm IMAGE -C -- DISTRIBUTION
docker run --rm \\
-v KERNELS:/kernels \\
IMAGE -A [-- ARTIFACTORY_DOWNLOADER_OPTIONS...]
Required volumes:
- /var/run/docker.sock for spawning build containers
- WORKSPACE
the main workspace, will be used to unpack kernel packages
and run the actual build
- SYSDIG
the directory containing Sysdig sources in the version
you wish to build
- KERNELS
the directory containing kernel packages (image, headers etc.)
Options:
-B
Build the probes
-P
Prepare the probe builder images ahead of time
-b BUILDER_IMAGE_PREFIX/
Use BUILDER_IMAGE_PREFIX/ as the prefix for all builder images.
It should match the prefix used with the -P option below
(in an earlier invocation)
-A
Download kernel packages from an Artifactory instance
-C
Run the kernel crawler to list available kernel packages
for a particular distribution. Run without extra parameters
to see the supported distributions.
-d
Enable debug (pass --debug to the probe builder)
EOF
exit 1
}
check_docker_socket()
{
if ! docker info &>/dev/null
then
echo "Docker socket not available" >&2
echo >&2
usage
fi
}
build_probes()
{
check_docker_socket
cd /workspace
probe_builder ${DEBUG_PREFIX} build -s /sysdig -b "$BUILDER_IMAGE_PREFIX" "$@" /kernels/*
}
prebuild_builders()
{
check_docker_socket
probe_builder ${DEBUG_PREFIX} prebuild -b "$BUILDER_IMAGE_PREFIX" "$@"
}
download_from_artifactory()
{
cd /kernels
artifactory_download "$@"
}
crawl()
{
probe_builder ${DEBUG_PREFIX} crawl "$@"
}
BUILDER_IMAGE_PREFIX=
DEBUG_PREFIX=
while getopts ":Ab:BCdP" opt
do
case "$opt" in
A)
OP=download_from_artifactory
;;
b)
BUILDER_IMAGE_PREFIX=$OPTARG
;;
B)
OP=build
;;
C)
OP=crawl
;;
d)
DEBUG_PREFIX="--debug"
;;
P)
OP=prebuild
;;
\?)
echo "Invalid option $OPTARG" >&2
echo "Did you mean to pass it to the probe builder? Add -- before" >&2
echo >&2
usage
;;
:)
echo "Option $OPTARG requires an argument" >&2
echo >&2
usage
;;
esac
done
shift $((OPTIND - 1))
case "${OP:-}" in
download_from_artifactory)
download_from_artifactory "$@"
;;
build)
build_probes "$@"
;;
crawl)
crawl "$@"
;;
prebuild)
prebuild_builders "$@"
;;
*)
usage
;;
esac