Skip to content

Commit e913fd2

Browse files
committed
Modernize and fix build system
1 parent 44e4db9 commit e913fd2

File tree

6 files changed

+54
-88
lines changed

6 files changed

+54
-88
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ jobs:
88
fail-fast: false
99
matrix:
1010
include:
11-
- DIST: focal
11+
- RELEASE: latest
1212
ARCH: x86_64
13-
- DIST: focal
13+
- RELEASE: latest
1414
ARCH: i386
1515

1616
# special builds
17-
- DIST: focal
17+
- RELEASE: latest
1818
ARCH: x86_64
1919
BUILD_TYPE: coverage
20-
- DIST: focal
20+
- RELEASE: latest
2121
ARCH: x86_64
2222
BUILD_TYPE: shared-only
2323
LIBAPPIMAGE_SHARED_ONLY: 1
@@ -26,7 +26,7 @@ jobs:
2626
runs-on: ubuntu-latest
2727
env:
2828
ARCH: ${{ matrix.ARCH }}
29-
DIST: ${{ matrix.DIST }}
29+
RELEASE: ${{ matrix.RELEASE }}
3030
BUILD_TYPE: ${{ matrix.DIST }}
3131
LIBAPPIMAGE_SHARED_ONLY: ${{ matrix.LIBAPPIMAGE_SHARED_ONLY }}
3232
steps:

ci/Dockerfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# these args are available *only* for the FROM call
2-
ARG DOCKER_ARCH
3-
ARG DIST
2+
ARG RELEASE
43

5-
FROM $DOCKER_ARCH/ubuntu:$DIST
4+
FROM ubuntu:$RELEASE
65

76
# we need to repeat all args from above which we need during build and runtime to make them available
87
ARG ARCH
@@ -12,9 +11,9 @@ ENV CI=1
1211

1312
COPY ./install-deps.sh /
1413
# see above, for build time we need to pass the args manually (using ENV does not work)
15-
RUN bash -xe install-deps.sh
14+
RUN bash -xe /install-deps.sh
1615

1716
# create unprivileged user for non-build-script use of this image
1817
# build-in-docker.sh will likely not use this one, as it enforces the caller's uid inside the container
19-
RUN adduser --system --group build
18+
RUN useradd build
2019
USER build

ci/build-and-test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ cleanup () {
2121
trap cleanup EXIT
2222

2323
# store repo root as variable
24-
REPO_ROOT="$(readlink -f "$(dirname "$(dirname "$0")")")"
25-
OLD_CWD="$(readlink -f .)"
24+
REPO_ROOT="$(readlink -f "$(dirname "$(dirname "${BASH_SOURCE[0]}")")")"
25+
OLD_CWD="$(readlink -f "$PWD")"
2626

2727
pushd "$BUILD_DIR"
2828

ci/build-docker-image.sh

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#! /bin/bash
22

3-
if [[ "$DIST" == "" ]] || [[ "$ARCH" == "" ]]; then
4-
echo "Usage: env ARCH=... DIST=... bash $0"
3+
if [[ "${ARCH:-}" == "" ]] || [[ "${RELEASE:-}" == "" ]]; then
4+
echo "Usage: env ARCH=... RELEASE=... bash $0"
55
exit 1
66
fi
77

8-
set -x
9-
set -e
8+
set -euo pipefail
109

1110
# the other script sources this script, therefore we have to support that use case
1211
if [[ "${BASH_SOURCE[*]}" != "" ]]; then
@@ -15,30 +14,21 @@ else
1514
this_dir="$(readlink -f "$(dirname "$0")")"
1615
fi
1716

18-
case "$ARCH" in
19-
x86_64)
20-
export DOCKER_ARCH=amd64
21-
;;
22-
*)
23-
export DOCKER_ARCH="$ARCH"
24-
;;
25-
esac
26-
27-
image=quay.io/appimage/libappimage-build:"$DIST"-"$ARCH"
17+
image=quay.io/appimage/libappimage-build:"$RELEASE"
2818

2919
extra_build_args=()
30-
if [[ "$NO_PULL" == "" ]]; then
20+
if [[ "${NO_PULL:-}" == "" ]]; then
3121
# speed up build by pulling last built image from quay.io and building the docker file using the old image as a base
3222
docker pull "$image" || true
3323
extra_build_args=(--cache-from "$image")
3424
fi
3525

3626
# if the image hasn't changed, this should be a no-op
3727
docker build \
28+
--platform "$platform" \
3829
--pull \
39-
--build-arg DOCKER_ARCH \
4030
--build-arg ARCH \
41-
--build-arg DIST \
31+
--build-arg RELEASE \
4232
-t "$image" \
4333
"${extra_build_args[@]}" \
4434
"$this_dir"
@@ -48,7 +38,7 @@ docker build \
4838
# rebuilt anyway
4939
# credentials shall only be available on (protected) master branch
5040
set +x
51-
if [[ "$DOCKER_USERNAME" != "" ]]; then
41+
if [[ "${DOCKER_USERNAME:-}" != "" ]]; then
5242
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin quay.io
5343
docker push "$image"
5444
fi

ci/build-in-docker.sh

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
11
#! /bin/bash
22

3-
if [[ "$DIST" == "" ]] || [[ "$ARCH" == "" ]]; then
4-
echo "Usage: env ARCH=... DIST=... bash $0"
3+
if [[ "${ARCH:-}" == "" ]] || [[ "${RELEASE:-}" == "" ]]; then
4+
echo "Usage: env ARCH=... RELEASE=... bash $0"
55
exit 1
66
fi
77

8-
set -x
9-
set -e
8+
set -euo pipefail
109

11-
cd "$(readlink -f "$(dirname "$0")")"
12-
13-
if [[ "$DIST" != appimagebuild* ]]; then
14-
# sets variables $image
15-
source build-docker-image.sh
10+
# the other script sources this script, therefore we have to support that use case
11+
if [[ "${BASH_SOURCE[*]}" != "" ]]; then
12+
this_dir="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
1613
else
17-
image=quay.io/appimage/appimagebuild:centos7-"$ARCH"
18-
docker pull "$image"
14+
this_dir="$(readlink -f "$(dirname "$0")")"
1915
fi
2016

17+
case "$ARCH" in
18+
x86_64)
19+
platform=linux/amd64
20+
;;
21+
i686)
22+
platform=linux/i386
23+
;;
24+
armhf)
25+
platform=linux/arm/v7
26+
;;
27+
aarch64)
28+
platform=linux/arm64/v8
29+
;;
30+
*)
31+
echo "unknown architecture: $ARCH"
32+
exit 2
33+
;;
34+
esac
35+
36+
cd "$(readlink -f "$(dirname "$0")")"
37+
38+
# sets variables $image
39+
source build-docker-image.sh
40+
2141
DOCKER_OPTS=()
2242
# fix for https://stackoverflow.com/questions/51195528/rcc-error-in-resource-qrc-cannot-find-file-png
23-
if [ "$CI" != "" ]; then
43+
if [ "${CI:-}" != "" ]; then
2444
DOCKER_OPTS+=("--security-opt" "seccomp:unconfined")
2545
fi
2646

2747
# only if there's more than 3G of free space in RAM, we can build in a RAM disk
28-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
48+
if [[ "${GITHUB_ACTIONS:-}" != "" ]]; then
2949
echo "Building on GitHub actions, which does not support --tmpfs flag -> building on regular disk"
3050
elif [[ "$(free -m | grep "Mem:" | awk '{print $4}')" -gt 3072 ]]; then
3151
echo "Host system has enough free memory -> building in RAM disk"

ci/install-deps.sh

Lines changed: 2 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,20 @@
11
#! /bin/bash
22

3-
set -e
3+
set -euo pipefail
44

5-
if [[ "$ARCH" == "" ]]; then
6-
echo "Usage: env ARCH=... bash $0"
7-
exit 2
8-
fi
9-
10-
if [[ "$CI" == "" ]]; then
5+
if [[ "${CI:-}" == "" ]]; then
116
echo "Caution: this script is supposed to run inside a (disposable) CI environment"
127
echo "It will alter a system, and should not be run on workstations or alike"
138
echo "You can export CI=1 to prevent this error from being shown again"
149
exit 3
1510
fi
1611

17-
case "$ARCH" in
18-
x86_64|i386|armhf|arm64)
19-
;;
20-
*)
21-
echo "Error: unsupported architecture: $ARCH"
22-
exit 4
23-
;;
24-
esac
25-
26-
case "$DIST" in
27-
bionic|focal)
28-
;;
29-
*)
30-
echo "Error: unsupported distribution: $DIST"
31-
exit 5
32-
;;
33-
esac
34-
3512
set -x
3613

3714
packages=(
3815
libfuse-dev
3916
desktop-file-utils
4017
ca-certificates
41-
gcc-multilib
4218
make
4319
build-essential
4420
git
@@ -60,27 +36,8 @@ packages=(
6036
libboost-dev
6137
)
6238

63-
# install gcc-10 (supports C++17 with std::filesystem properly)
64-
if [[ "$DIST" == "bionic" ]]; then
65-
apt-get update
66-
apt-get install --no-install-recommends -y software-properties-common
67-
add-apt-repository -y ppa:ubuntu-toolchain-r/test
68-
packages+=(g++-10-multilib)
69-
else
70-
packages+=(g++-multilib)
71-
fi
72-
7339
# make sure installation won't hang on GitHub actions
7440
export DEBIAN_FRONTEND=noninteractive
7541

7642
apt-get update
7743
apt-get -y --no-install-recommends install "${packages[@]}"
78-
79-
# install more recent CMake version
80-
wget https://artifacts.assassinate-you.net/prebuilt-cmake/continuous/cmake-v3.24.1-ubuntu_"$DIST"-"$ARCH".tar.gz -qO- | \
81-
tar xz -C/usr/local --strip-components=1
82-
83-
# g++-10 should be used by default
84-
if [[ "$DIST" == "bionic" ]]; then
85-
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-10 9999
86-
fi

0 commit comments

Comments
 (0)