Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppImage: increase compatibility & add tests #17

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 96 additions & 14 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,45 @@ on:
types: [published]
workflow_dispatch:

env:
BASE_OS: ubuntu
APT_PUBKEY: 871920D1991BC93C

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
target:
- platform: linux/amd64
arch: amd64
- platform: linux/arm64
arch: arm64
codename:
- jammy
- noble
base:
- os: ubuntu
codename: focal
pubkey: 871920D1991BC93C
recipe: AppImageBuilder.ubuntu-focal.yml
- os: ubuntu
codename: jammy
pubkey: 871920D1991BC93C
recipe: AppImageBuilder.yml
- os: ubuntu
codename: noble
pubkey: 871920D1991BC93C
recipe: AppImageBuilder.yml
- os: debian
codename: bullseye
pubkey: 0E98404D386FA1D9
pubkey_security: 54404762BBB6E853
recipe: AppImageBuilder.debian-bullseye.yml
- os: debian
codename: bookworm
pubkey: 0E98404D386FA1D9
pubkey_security: 54404762BBB6E853
recipe: AppImageBuilder.debian.yml
- os: debian
codename: trixie
pubkey: 0E98404D386FA1D9
pubkey_security: 54404762BBB6E853
recipe: AppImageBuilder.debian.yml

steps:
- uses: actions/checkout@v4
Expand All @@ -42,8 +62,8 @@ jobs:
platforms: ${{ matrix.target.platform }}
outputs: build
build-args: |
BASE_OS
BASE_CODENAME=${{ matrix.codename }}
BASE_OS=${{ matrix.base.os }}
BASE_CODENAME=${{ matrix.base.codename }}

- name: Prepare environment to build AppImage
env:
Expand All @@ -56,31 +76,93 @@ jobs:
rm build/.build-metadata.env
fi
APPIMAGE_SOURCE=build
APPIMAGE_VERSION="${GITHUB_REF_SLUG}-${{ matrix.codename }}"
APPIMAGE_VERSION="${GITHUB_REF_SLUG}-${{ matrix.base.codename }}"
APPIMAGE_APT_ARCH="${TARGETARCH}"
APPIMAGE_APT_DISTRO="${{ matrix.codename }}"
APPIMAGE_APT_PUBKEY="${APT_PUBKEY}"
APPIMAGE_APT_DISTRO="${{ matrix.base.codename }}"
APPIMAGE_APT_PUBKEY="${{ matrix.base.pubkey }}"
APPIMAGE_APT_PUBKEY_SECURITY="${{ matrix.base.pubkey_security }}"
APPIMAGE_ARCH="${TARGETMACHINE}"
printenv | grep ^APPIMAGE_ >>"${GITHUB_ENV}"

- name: Build AppImage
uses: AppImageCrafters/[email protected]
with:
recipe: "${{ matrix.base.recipe }}"

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: appimage-${{ matrix.codename }}-${{ matrix.target.arch }}
name: appimage-${{ matrix.base.codename }}-${{ matrix.target.arch }}
path: |
./*.AppImage
./*.AppImage.zsync
if-no-files-found: error

test:
runs-on: ubuntu-latest
needs:
- build
strategy:
fail-fast: false
matrix:
target:
- platform: linux/amd64
arch: amd64
base:
- os: ubuntu
codename: focal
- os: ubuntu
codename: jammy
- os: ubuntu
codename: noble
- os: debian
codename: bullseye
- os: debian
codename: bookworm
- os: debian
codename: trixie
- os: fedora
codename: "39"
- os: fedora
codename: "40"
- os: archlinux
codename: base

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: appimage-*-${{ matrix.target.arch }}
path: appimages
merge-multiple: true

- name: Setup qemu for docker
uses: docker/setup-qemu-action@v3
if: matrix.target.platform != 'linux/amd64'

- name: Setup buildx for docker
uses: docker/setup-buildx-action@v3

- name: Test AppImages
uses: docker/build-push-action@v5
with:
file: AppImageBuilder.test.Dockerfile
context: appimages
platforms: ${{ matrix.target.platform }}
build-args: |
BASE_OS=${{ matrix.base.os }}
BASE_CODENAME=${{ matrix.base.codename }}

release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

needs:
- build
- test

permissions:
contents: write
Expand Down
180 changes: 180 additions & 0 deletions AppImageBuilder.debian-bullseye.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
version: 1

script:
- |
set -eu

if [ "{{APPIMAGE_SOURCE}}" != "${TARGET_APPDIR}" ]; then
mv "{{APPIMAGE_SOURCE}}" "${TARGET_APPDIR}"
fi

# Manual installation of squashfs-tools is required
# until https://github.com/AppImageCrafters/build-appimage/issues/5 is fixed
if ! command -v mksquashfs >/dev/null; then
apt-get update && apt-get install -y --no-install-recommends squashfs-tools
fi

AppDir:
app_info:
id: org.c0rn3j.sc-controller
name: sc-controller
version: "{{APPIMAGE_VERSION}}"
icon: sc-controller
exec: usr/bin/python3
exec_args: -c "import os, sys; os.execvp('$APPDIR/usr/bin/scc', ['$APPDIR/usr/bin/scc'] + (sys.argv[1:] if len(sys.argv) > 1 else ['gui']))" $@

after_bundle: |
set -eu

# appimage-builder expects .desktop file to start with appinfo-id
desktop="$(find "${TARGET_APPDIR}/usr" -name sc-controller.desktop)"
sed -i "s:Exec=.*:Exec=./usr/bin/scc gui:g" "${desktop}"
ln -sr "${desktop}" "${TARGET_APPDIR}/usr/share/applications/org.c0rn3j.sc-controller.desktop"

# appimage-builder expects utf-8 encoding when patching shebangs,
# but pygettext3 has iso-8859-1 encoding
find "${TARGET_APPDIR}/usr/bin" -name 'pygettext*' | while read -r file; do
encoding="ISO-8859-1"
if file -bi "${file}" | grep -iq "${encoding}"; then
<"${file}" iconv -f "${encoding}" -t utf-8 -o "${file}"
sed -i -E '1,2 s|^(\s*#.*coding[=:]\s*)([[:alnum:].-]+)|\1utf-8|g' "${file}"
fi
done

# install python3-vdf manually if not available as package
if ! apt-cache search --names-only python3-vdf | grep -q .; then
pip install --target "${TARGET_APPDIR}/usr/lib/python3/dist-packages/" vdf
fi

after_runtime: |
set -eu

# python3 is linked against 'lib64/ld-linux-x86-64.so.2'
# but 'compat/lib64' is missing for Ubuntu Noble
compat="${TARGET_APPDIR}/runtime/compat"
if [ ! -e "${compat}/lib64" ] && [ -d "${compat}/usr/lib64" ]; then
ln -s "usr/lib64" "${compat}/"
fi

apt:
arch:
- "{{APPIMAGE_APT_ARCH}}"
sources:
- sourceline: deb http://deb.debian.org/debian {{APPIMAGE_APT_DISTRO}} main
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}}
- sourceline: deb http://deb.debian.org/debian {{APPIMAGE_APT_DISTRO}}-updates main
- sourceline: deb http://deb.debian.org/debian-security/ {{APPIMAGE_APT_DISTRO}}-security main
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY_SECURITY}}

include:
- gir1.2-gtk-3.0
- gir1.2-rsvg-2.0
- libbluetooth3
- libgtk-3-0
- librsvg2-common
- libx11-6
- libxcb1
- libxext6
- libxfixes3
- python3-evdev
- python3-gi-cairo
- python3-pylibacl
- binutils # required for detection of bluetooth library
- coreutils # provides /usr/bin/env
- shared-mime-info # required for gui if host provides no MIME info, e.g. when XDG_DATA_DIRS is missing

exclude:
# coreutils
- libacl* # filesystem
- libattr* # filesystem
- libgmp* # arithmetics

# gir1.2-rsvg-2.0
- libicu* # i18n
- libstdc* # development
- libxml* # codec

# libgtk3-0
- "*-icon-theme" # gui
- "*crypt*" # security
- "*dconf*" # gui configuration
- "*dbus*" # process communication
- "*gcc*" # development
- "*systemd*" # linux core
- libblk* # filesystem
- libcolord* # gui
- libcups* # printing
- libepoxy* # gui
- libfontconfig* # fonts
- libfreetype* # fonts
- libfribidi* # i18n
- libgtk-3-common # gui
- liblz* # codec
- libmount* # filesystem
- libtiff* # codec
- libwebp* # codec

# python3
- "*krb*" # security
- "*readline*" # terminal
- "*sqlite*" # database
- libbz* # codec
- libdb* # database
- libmpdec* # arithmetics
- libncurses* # terminal
- libnsl* # network
- libssl* # security
- libtirpc* # development
- libuuid* # development
- media-types # codec

# Debian Trixie
- libgprofng* # development
- libjansson* # codec
- libsframe* # development
- libcloudproviders* # networking
- netbase # network
- tzdata # date/time

# Debian Bullseye
- glib-networking* # network
- gsettings* # gui configuration
- libidn2* # codec
- libjson* # codec
- libpsl* # networking
- librest-* # networking
- libsoup* # networking
- libunistring* # unicode

files:
exclude:
- usr/bin/*gold* # alternative for ld
- usr/bin/*gp-display-html* # requires perl
- usr/lib/*/gconv # unicode
- usr/lib/*/gdk-pixbuf-2.0/*/loaders/libpixbufloader-??[!g].so # only png & svg are required
- usr/lib/*/glib-2.0
- usr/lib/python*/cgi.py
- usr/lib/python*/email
- usr/lib/python*/test
- usr/lib/python*/unittest
- usr/share/doc
- usr/share/glib-2.0
- usr/share/gtk-doc
- usr/share/icu
- usr/share/locale
- usr/share/man
- usr/share/python3/runtime.d
- usr/share/thumbnailers

runtime:
env:
# `usr/lib/python3.*/site-packages` is required in $PYTHONPATH,
# but the python version and hence the actual location is unknown here.
# Fortunately the site-packages directory is on the $PATH, so we add $PATH instead.
# It must precede an existing $PYTHONPATH to work.
PYTHONPATH: "${APPDIR}/usr/lib/python3/dist-packages:${PATH}:${PYTHONPATH}"
SCC_SHARED: "${APPDIR}/usr/share/scc"

AppImage:
arch: "{{APPIMAGE_ARCH}}"
update-information: "gh-releases-zsync|C0rn3j|sc-controller|latest|sc-controller-*-{{APPIMAGE_APT_DISTRO}}-{{APPIMAGE_ARCH}}.AppImage.zsync"
Loading