-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_packages.sh
executable file
·96 lines (81 loc) · 2.63 KB
/
build_packages.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
#!/bin/bash
set -e
HAS_DOCKER=""
errorExit() {
echo "*** $*" 1>&2
exit 1
}
usage () {
echo "Usage: $0 [option for $0...] [other options]"
echo "Options for $0:"
echo " -d, --docker-compile Compile in Docker container instead of native Maven build."
echo " -h, --help This help text."
echo "The option for $0, if present, must come fist, before other options."
echo "Other options:"
echo " -s, --skip-tests Skip tests, just compile code and build packages."
test -z "$1" || exit "$1"
}
for i in "$@"; do
case "$i" in
"--skip-tests"|"-s")
SKIP_TESTS=1
;;
esac
done
AP_ARGUMENTS=(-Ptomcat -Pdefault-plugins -Pdatabase -PUI)
SMP_ARGUMENTS=()
if [[ -n "$SKIP_TESTS" ]]; then
echo "Skipping tests"...
AP_ARGUMENTS+=(-DskipTests=true -DskipITs=true)
SMP_ARGUMENTS+=(-DskipTests=true -DskipITs=true)
fi
buildInDocker() {
test -n "$HAS_DOCKER" || errorExit "Error, docker is not installed/running."
echo "Building in docker..."
# Build Docker image for compiling the code
docker build -q -f docker/Dockerfile -t harmony-build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" docker/
# Compile AP
docker run -t --rm \
--user builder \
-v "$(pwd)/../harmony-access-point/":/mnt \
-v harmony-mvn-cache:/home/builder/.m2 \
harmony-build \
/mnt/mvnw -f pom.xml --no-transfer-progress clean install "${AP_ARGUMENTS[@]}"
# Compile SMP
docker run -t --rm \
-u builder \
-v "$(pwd)/../harmony-smp/":/mnt \
-v harmony-mvn-cache:/home/builder/.m2 \
harmony-build \
/mnt/mvnw -f pom.xml --no-transfer-progress clean install "${SMP_ARGUMENTS[@]}"
# Build Docker image for the build
docker build -q -f docker/Dockerfile -t harmony-build --build-arg UID="$(id -u)" --build-arg GID="$(id -g)" docker/
# Build packages using the image
local email
email="{EMAIL:-$(id -un)@local}"
docker run -it --rm \
-u builder \
-v "$(pwd)/..":/mnt \
-e DEBEMAIL="${DEBEMAIL:-$email}" \
harmony-build \
/bin/bash -c "cd /mnt/harmony-common/packaging/ && ./build-deb.sh"
}
buildLocally() {
echo "Building locally..."
# Compile code
cd ../harmony-access-point/
mvn clean -f pom.xml install "${AP_ARGUMENTS[@]}"
cd ../harmony-smp/
mvn clean -f pom.xml install "${SMP_ARGUMENTS[@]}"
# Build packages
cd ../harmony-common/packaging/
./build-deb.sh
}
if command -v docker &>/dev/null; then
HAS_DOCKER=true
fi
case "$1" in
--docker-compile|-d) shift; buildInDocker "$@";;
--help|-h) usage 0;;
*) buildLocally "$@";;
esac