|
1 | 1 | #! /bin/bash |
2 | 2 |
|
3 | | -if [[ "$DIST" == "" ]] || [[ "$ARCH" == "" ]]; then |
4 | | - echo "Usage: env ARCH=... DIST=... bash $0" |
| 3 | +if [[ "$ARCH" == "" ]]; then |
| 4 | + echo "Usage: env ARCH=... bash $0" |
5 | 5 | exit 1 |
6 | 6 | fi |
7 | 7 |
|
8 | | -set -e |
9 | | -set -x |
| 8 | +set -euxo pipefail |
| 9 | + |
| 10 | +case "$ARCH" in |
| 11 | + x86_64) |
| 12 | + docker_platform=linux/amd64 |
| 13 | + ;; |
| 14 | + i686) |
| 15 | + CMAKE_ARCH=i386 |
| 16 | + docker_platform=linux/386 |
| 17 | + ;; |
| 18 | + armhf) |
| 19 | + docker_platform=linux/arm32/v7 |
| 20 | + ;; |
| 21 | + aarch64) |
| 22 | + docker_platform=linux/arm64/v8 |
| 23 | + ;; |
| 24 | + *) |
| 25 | + echo "Unsupported architecture: $ARCH" |
| 26 | + exit 2 |
| 27 | +esac |
| 28 | + |
| 29 | +CMAKE_ARCH="${CMAKE_ARCH:-"$ARCH"}" |
10 | 30 |
|
11 | 31 | cwd="$PWD" |
12 | 32 | repo_root="$(readlink -f "$(dirname "$0")"/..)" |
13 | 33 |
|
14 | 34 | # needed to keep user ID in and outside Docker in sync to be able to write to workspace directory |
15 | | -image=appimageupdate-build:"$DIST"-"$ARCH" |
16 | | -dockerfile=Dockerfile."$ARCH" |
17 | | - |
18 | | -if [ ! -f "$repo_root"/ci/"$dockerfile" ]; then |
19 | | - echo "Error: $dockerfile could not be found" |
20 | | - exit 1 |
21 | | -fi |
| 35 | +image=appimageupdate-build |
22 | 36 |
|
23 | 37 | # building local image to "cache" installed dependencies for subsequent builds |
24 | | -docker build -t "$image" -f "$repo_root"/ci/"$dockerfile" --build-arg DIST="$DIST" "$repo_root"/ci |
| 38 | +docker build \ |
| 39 | + --platform "$docker_platform" \ |
| 40 | + -t "$image" \ |
| 41 | + --build-arg ARCH="$ARCH" \ |
| 42 | + --build-arg CMAKE_ARCH="$CMAKE_ARCH" \ |
| 43 | + "$repo_root"/ci |
25 | 44 |
|
26 | 45 | # run the build with the current user to |
27 | 46 | # a) make sure root is not required for builds |
28 | 47 | # b) allow the build scripts to "mv" the binaries into the /out directory |
29 | 48 | uid="$(id -u)" |
| 49 | + |
| 50 | +tty_args=() |
| 51 | +if [ -t 0 ]; then tty_args+=("-t"); fi |
| 52 | + |
30 | 53 | # mount workspace read-only, trying to make sure the build doesn't ever touch the source code files |
31 | 54 | # of course, this only works reliably if you don't run this script from that directory |
32 | 55 | # but it's still not the worst idea to do so |
33 | | -docker run --platform "$ARCH" \ |
34 | | - --user "$uid" --rm -i -e ARCH -e GITHUB_RUN_NUMBER -e CI=1 -v "$repo_root":/ws:ro -v "$cwd":/out "$image" \ |
35 | | - bash -xec 'cd /out && bash -xe /ws/ci/build-appimages.sh' |
| 56 | +docker run \ |
| 57 | + --rm \ |
| 58 | + -i \ |
| 59 | + "${tty_args[@]}" \ |
| 60 | + -e CI=1 \ |
| 61 | + -e GITHUB_RUN_NUMBER \ |
| 62 | + -v "$repo_root":/ws:ro \ |
| 63 | + -v "$cwd":/out \ |
| 64 | + -w /out \ |
| 65 | + --user "$uid" \ |
| 66 | + "$image" \ |
| 67 | + bash /ws/ci/build-appimages.sh |
0 commit comments