-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (76 loc) · 2.07 KB
/
build.sh
File metadata and controls
executable file
·83 lines (76 loc) · 2.07 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
#!/bin/bash
usage () {
echo "Usage: ./build [-r <registry> -i -b -p] [-h]"
echo
echo " OPTIONAL: "
echo " -r <registry> define a docker registry to push to"
echo " -i compile with added instrumentation from afl-gcc"
echo " -b actually do a build"
echo " -p push to registry (-r must also be specified for -p to work)"
echo
echo " -h help"
echo
exit 1
}
while getopts "r:ibph" opt; do
case "$opt" in
r)
if [ ! $REGISTRY ]; then
case "$OPTARG" in
*/) REGISTRY=$OPTARG ;;
*) REGISTRY=$OPTARG/ ;;
esac
else
echo "ERROR: can't define multiple registries!"
usage
fi
;;
i)
INSTRUMENT=true
;;
b)
BUILD=true
;;
p)
PUSH=true
;;
h)
usage
;;
esac
done
BASE_NAME="eos-fuzz-base"
FUZZ_NAME="eos-fuzz"
if [ ! -z "$REGISTRY" ]; then
echo "docker registry: ${REGISTRY}"
BASE_NAME=${REGISTRY}${BASE_NAME}
FUZZ_NAME=${REGISTRY}${FUZZ_NAME}
else
if [[ "$PUSH" = "true" ]]; then
echo "Error: yeah nah, you didn't define a registry to push to"
usage
fi
fi
if [[ "$BUILD" = "true" ]]; then
if [[ "$INSTRUMENT" = "true" ]]; then
echo "building container with afl-gcc-compiled eos & xrootd"
BASE_NAME=${BASE_NAME}:afl
FUZZ_NAME=${FUZZ_NAME}:afl
sed s:AFL_COMPILE::g Dockerbase.tmp > Dockerbase
sed s:AFL_COMPILE::g Dockerfile.tmp > Dockerfile
else
echo "building container with default eos & xrootd"
BASE_NAME=${BASE_NAME}:default
FUZZ_NAME=${FUZZ_NAME}:default
sed s:AFL_COMPILE:\#:g Dockerbase.tmp > Dockerbase
sed s:AFL_COMPILE:\#:g Dockerfile.tmp > Dockerfile
fi
sed -i "s|FUZZ_BASE_IMAGE|${BASE_NAME}|g" Dockerfile
docker build -f Dockerbase -t ${BASE_NAME} . && \
docker build -f Dockerfile -t ${FUZZ_NAME} . && \
rm Dockerbase Dockerfile
fi
if [[ "$PUSH" = "true" ]]; then
echo "pushing image ${FUZZ_NAME}"
docker push ${FUZZ_NAME}
fi