-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathbuild-dist.sh
executable file
·84 lines (73 loc) · 1.99 KB
/
build-dist.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
#! /bin/bash
set -e
BUILD_REV=$(git rev-parse --short HEAD)
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
GIT_TAG=$(git describe --tags --abbrev=0 --exact-match 2> /dev/null || echo "")
echo "===> Git revision: ${BUILD_REV}"
echo "===> Git branch: ${GIT_BRANCH}"
echo "===> Git tag: ${GIT_TAG}"
skip_windows="no"
# Custom command.
command=""
for a in $@; do
case "$a" in
--skip-windows)
skip_windows="yes"
;;
--linux)
skip_windows="yes"
;;
--*)
echo "error: bad argument: $a"
exit 1
;;
*)
command="$@"
break
;;
esac
shift
done
cross_run() {
target="$1"
shift
if [ "${target}" = "" ]; then
echo "error: target must be set for cross_run"
exit 1
fi
dockerfile="./docker/builder/Dockerfile.cross"
tag=${BUILDER_TAG:-"evebox/builder:cross"}
env
if [ -z "${GITHUB_REPOSITORY}" -a -t ]; then
it="-it"
else
it=""
fi
${ECHO} docker build \
--build-arg REAL_UID="$(id -u)" \
--build-arg REAL_GID="$(id -g)" \
--cache-from ${tag} \
-t ${tag} \
-f ${dockerfile} .
${ECHO} docker run --rm ${it} --privileged \
-v "$(pwd):/src:z" \
-v /var/run/docker.sock:/var/run/docker.sock:z \
-w /src \
-e BUILD_REV="${BUILD_REV}" \
-e TARGET="${target}" \
-u builder \
--group-add $(getent group docker | cut -f3 -d:) \
${tag} $@
}
if [[ "${command}" ]]; then
$command
else
cross_run x86_64-unknown-linux-musl make dist
cross_run aarch64-unknown-linux-musl make dist
cross_run x86_64-unknown-linux-musl ./packaging/build-rpm.sh amd64
cross_run x86_64-unknown-linux-musl ./packaging/build-deb.sh amd64
cross_run aarch64-unknown-linux-musl ./packaging/build-deb.sh arm64
if [[ "${skip_windows}" != "yes" ]]; then
cross_run x86_64-pc-windows-gnu make dist
fi
fi