Skip to content

Commit

Permalink
Keep i386 alive and add ARM builds
Browse files Browse the repository at this point in the history
As a consequence of bionic having gone end-of-life, we move to using
Debian oldstable as a consequence.

This also required changes to prebuilt-cmake, which now supports a lot
more distros for all of x86_64, i386, armhf and aarch64.
  • Loading branch information
TheAssassin committed Dec 10, 2023
1 parent e57e1fc commit 5731f09
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 76 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ARCH: [x86_64, i386]
ARCH: [x86_64, i686, aarch64, armhf]

name: AppImage ${{ matrix.ARCH }}
runs-on: ubuntu-20.04
Expand All @@ -18,8 +18,13 @@ jobs:
- uses: actions/checkout@v2
with:
submodules: recursive

- name: Set up QEMU integration for Docker
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

- name: Build AppImage in Docker
run: bash -ex ci/build-in-docker.sh

- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
34 changes: 34 additions & 0 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
ARG DOCKER_ARCH

# current Debian oldstable as of Dec 2023
# we use Debian because they still provide i386 builds
FROM ${DOCKER_ARCH}/debian:bullseye

ARG ARCH
ARG DOCKER_ARCH
ARG CMAKE_ARCH

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -y \
gcc g++ make libxpm-dev git libcurl4-openssl-dev libssl-dev wget zlib1g-dev libc6-dev bsdmainutils pkgconf libgcrypt20-dev ca-certificates file libglib2.0-0

RUN wget https://artifacts.assassinate-you.net/prebuilt-cmake/cmake-v3.28.0-debian-bullseye-${CMAKE_ARCH}.tar.gz -O- | \
tar xz -C /usr/local --strip-components=1

COPY ./install-gtest.sh /
RUN bash /install-gtest.sh

COPY libgcrypt.pc /usr/lib/i386-linux-gnu/pkgconfig/libgcrypt.pc
RUN triplet="$(find /usr/lib/ -maxdepth 1 -type d -iname '*-linux-gnu*' | head -n1 | rev | cut -d/ -f1 | rev)" && \
sed -i "s|x86_64-linux-gnu|${triplet}|g" /usr/lib/*/pkgconfig/libgcrypt.pc

# work around bug in FindCURL.cmake, which does not parse the pkg-config provided protocols and features into lists causing
# the comparison in the loop to yield false negative results
# this makes it use curl-config which works much better
RUN rm /usr/lib/*/pkgconfig/libcurl.pc

ENV APPIMAGE_EXTRACT_AND_RUN=1

ENV ARCH=${ARCH}
26 changes: 0 additions & 26 deletions ci/Dockerfile.bionic-i386

This file was deleted.

25 changes: 0 additions & 25 deletions ci/Dockerfile.bionic-x86_64

This file was deleted.

16 changes: 9 additions & 7 deletions ci/build-appimages.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#! /bin/bash

set -x
set -e
set -euxo pipefail

if [ "$ARCH" == "" ]; then
echo "Usage: env ARCH=... bash $0"
Expand Down Expand Up @@ -41,24 +40,27 @@ mkdir -p AppDir
make -j"$(nproc)"
make install DESTDIR=AppDir

LD_ARCH="$ARCH"
if [ "$ARCH" == "i686" ]; then LD_ARCH="i386"; fi

# get linuxdeploy
wget https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-"$ARCH".AppImage
wget https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-"$LD_ARCH".AppImage
chmod +x linuxdeploy*.AppImage

patch_appimage() {
while [[ "$1" != "" ]]; do
while [[ "${1:-}" != "" ]]; do
dd if=/dev/zero of="$1" conv=notrunc bs=1 count=3 seek=8
shift
done
}
patch_appimage linuxdeploy-"$ARCH".AppImage
patch_appimage linuxdeploy-"$LD_ARCH".AppImage

# determine Git commit ID
# linuxdeploy uses this for naming the file
export VERSION=$(cd "$REPO_ROOT" && git rev-parse --short HEAD)

# prepend GitHub actions run number if possible
if [ "$GITHUB_RUN_NUMBER" != "" ]; then
if [ "${GITHUB_RUN_NUMBER:-}" != "" ]; then
export VERSION="$GITHUB_RUN_NUMBER-$VERSION"
fi

Expand All @@ -71,7 +73,7 @@ for app in zsync2 zsyncmake2; do
# prepare AppDir with linuxdeploy and create AppImage
export UPD_INFO="gh-releases-zsync|AppImage|zsync2|continuous|$app-*x86_64.AppImage.zsync"

./linuxdeploy-"$ARCH".AppImage --appdir AppDir \
./linuxdeploy-"$LD_ARCH".AppImage --appdir AppDir \
-d "$REPO_ROOT"/resources/"$app".desktop \
-i "$REPO_ROOT"/resources/zsync2.svg \
--output appimage
Expand Down
63 changes: 48 additions & 15 deletions ci/build-in-docker.sh
Original file line number Diff line number Diff line change
@@ -1,31 +1,64 @@
#! /bin/bash

if [[ "$DIST" == "" ]] || [[ "$ARCH" == "" ]]; then
echo "Usage: env ARCH=... DIST=... bash $0"
if [[ "$ARCH" == "" ]]; then
echo "Usage: env ARCH=... bash $0"
exit 1
fi

set -e
set -x
set -euxo pipefail

case "$ARCH" in
x86_64)
DOCKER_ARCH=amd64
;;
i686)
CMAKE_ARCH=i386
DOCKER_ARCH=i386
;;
armhf)
DOCKER_ARCH=arm32v7
;;
aarch64)
DOCKER_ARCH=arm64v8
;;
*)
echo "Unsupported architecture: $ARCH"
exit 2
esac

CMAKE_ARCH="${CMAKE_ARCH:-"$ARCH"}"

cwd="$PWD"
repo_root="$(readlink -f "$(dirname "$0")"/..)"
repo_root="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")"/..)"

# needed to keep user ID in and outside Docker in sync to be able to write to workspace directory
uid="$(id -u)"
image=zsync2-build:"$DIST"-"$ARCH"-uid"$uid"
dockerfile=Dockerfile."$DIST"-"$ARCH"

if [ ! -f "$repo_root"/ci/"$dockerfile" ]; then
echo "Error: $dockerfile could not be found"
exit 1
fi
image=zsync2-build:"$ARCH"

# building local image to "cache" installed dependencies for subsequent builds
docker build -t "$image" -f "$repo_root"/ci/"$dockerfile" --build-arg UID="$uid" "$repo_root"/ci
docker build \
"${tty_args[@]}" \
-t "$image" \
--build-arg ARCH="$ARCH" \
--build-arg DOCKER_ARCH="$DOCKER_ARCH" \
--build-arg CMAKE_ARCH="$CMAKE_ARCH" \
"$repo_root"/ci

tty_args=()
if [ -t 0 ]; then tty_args+=("-t"); fi

# mount workspace read-only, trying to make sure the build doesn't ever touch the source code files
# of course, this only works reliably if you don't run this script from that directory
# but it's still not the worst idea to do so
docker run --rm -i -e CI=1 -e GITHUB_RUN_NUMBER -v "$repo_root":/ws:ro -v "$cwd":/out "$image" \
bash -xec 'cd /out && bash -xe /ws/ci/build-appimages.sh'
docker run \
--rm \
-i \
"${tty_args[@]}" \
-e CI=1 \
-e GITHUB_RUN_NUMBER \
-v "$repo_root":/ws:ro \
-v "$cwd":/out \
-w /out \
--user "$uid" \
"$image" \
bash /ws/ci/build-appimages.sh
3 changes: 1 addition & 2 deletions ci/install-gtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ trap _cleanup EXIT

cd "$tempdir"

#git clone https://github.com/google/googletest -b release-1.8.1 .
git clone https://github.com/google/googletest -b v1.13.0 .
git clone https://github.com/google/googletest -b v1.13.0 . --depth 1

mkdir build
cd build
Expand Down

0 comments on commit 5731f09

Please sign in to comment.