-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathbuild-debian-pkg
executable file
·55 lines (46 loc) · 1.43 KB
/
build-debian-pkg
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
#!/bin/bash
#
# Build TinyPilot Debian packages.
#
# Usage:
# build-debian-pkg [target architectures]
#
# target architecture: A comma-separated list of architectures that Docker
# accepts for its --platform argument. If omitted, defaults to
# "linux/arm/v7,linux/amd64". The only supported targets are linux/arm/v7 and
# linux/amd64.
#
# Examples
# build-debian-pkg "linux/arm/v7"
# build-debian-pkg "linux/arm/v7,linux/amd64"
# Exit build script on first failure.
set -e
# Echo commands before executing them, by default to stderr.
set -x
# Exit on unset variable.
set -u
BUILD_TARGETS="${1:-linux/arm/v7,linux/amd64}"
print_tinypilot_version() {
# Format build hash suffix according to SemVer (`-ghhhhhhh` -> `+hhhhhhh`).
git describe --tags --long |
sed --expression 's/\(-g\([0-9a-f]\{7\}\)\)$/+\2/g'
}
TINYPILOT_VERSION="$(print_tinypilot_version)"
readonly TINYPILOT_VERSION
PKG_VERSION="$(date '+%Y%m%d%H%M%S')"
readonly PKG_VERSION
# Use plain Docker build progress output when we're running in CI.
DOCKER_PROGRESS='auto'
if [[ -n "${CI:-}" ]]; then
DOCKER_PROGRESS='plain'
fi
readonly DOCKER_PROGRESS
DOCKER_BUILDKIT=1 docker buildx build \
--file debian-pkg/Dockerfile \
--platform "${BUILD_TARGETS}" \
--build-arg TINYPILOT_VERSION="${TINYPILOT_VERSION}" \
--build-arg PKG_VERSION="${PKG_VERSION}" \
--target=artifact \
--progress="${DOCKER_PROGRESS}" \
--output "type=local,dest=$(pwd)/debian-pkg/releases/" \
.