Skip to content

Commit cf39960

Browse files
feat(appimage): increase compatibility, add tests (#17)
1 parent 3291bf7 commit cf39960

File tree

7 files changed

+769
-72
lines changed

7 files changed

+769
-72
lines changed

.github/workflows/appimage.yml

Lines changed: 96 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,45 @@ on:
55
types: [published]
66
workflow_dispatch:
77

8-
env:
9-
BASE_OS: ubuntu
10-
APT_PUBKEY: 871920D1991BC93C
11-
128
jobs:
139
build:
1410
runs-on: ubuntu-latest
1511

1612
strategy:
17-
fail-fast: true
1813
matrix:
1914
target:
2015
- platform: linux/amd64
2116
arch: amd64
2217
- platform: linux/arm64
2318
arch: arm64
24-
codename:
25-
- jammy
26-
- noble
19+
base:
20+
- os: ubuntu
21+
codename: focal
22+
pubkey: 871920D1991BC93C
23+
recipe: AppImageBuilder.ubuntu-focal.yml
24+
- os: ubuntu
25+
codename: jammy
26+
pubkey: 871920D1991BC93C
27+
recipe: AppImageBuilder.yml
28+
- os: ubuntu
29+
codename: noble
30+
pubkey: 871920D1991BC93C
31+
recipe: AppImageBuilder.yml
32+
- os: debian
33+
codename: bullseye
34+
pubkey: 0E98404D386FA1D9
35+
pubkey_security: 54404762BBB6E853
36+
recipe: AppImageBuilder.debian-bullseye.yml
37+
- os: debian
38+
codename: bookworm
39+
pubkey: 0E98404D386FA1D9
40+
pubkey_security: 54404762BBB6E853
41+
recipe: AppImageBuilder.debian.yml
42+
- os: debian
43+
codename: trixie
44+
pubkey: 0E98404D386FA1D9
45+
pubkey_security: 54404762BBB6E853
46+
recipe: AppImageBuilder.debian.yml
2747

2848
steps:
2949
- uses: actions/checkout@v4
@@ -42,8 +62,8 @@ jobs:
4262
platforms: ${{ matrix.target.platform }}
4363
outputs: build
4464
build-args: |
45-
BASE_OS
46-
BASE_CODENAME=${{ matrix.codename }}
65+
BASE_OS=${{ matrix.base.os }}
66+
BASE_CODENAME=${{ matrix.base.codename }}
4767
4868
- name: Prepare environment to build AppImage
4969
env:
@@ -56,31 +76,93 @@ jobs:
5676
rm build/.build-metadata.env
5777
fi
5878
APPIMAGE_SOURCE=build
59-
APPIMAGE_VERSION="${GITHUB_REF_SLUG}-${{ matrix.codename }}"
79+
APPIMAGE_VERSION="${GITHUB_REF_SLUG}-${{ matrix.base.codename }}"
6080
APPIMAGE_APT_ARCH="${TARGETARCH}"
61-
APPIMAGE_APT_DISTRO="${{ matrix.codename }}"
62-
APPIMAGE_APT_PUBKEY="${APT_PUBKEY}"
81+
APPIMAGE_APT_DISTRO="${{ matrix.base.codename }}"
82+
APPIMAGE_APT_PUBKEY="${{ matrix.base.pubkey }}"
83+
APPIMAGE_APT_PUBKEY_SECURITY="${{ matrix.base.pubkey_security }}"
6384
APPIMAGE_ARCH="${TARGETMACHINE}"
6485
printenv | grep ^APPIMAGE_ >>"${GITHUB_ENV}"
6586
6687
- name: Build AppImage
6788
uses: AppImageCrafters/build-appimage@v1.3
89+
with:
90+
recipe: "${{ matrix.base.recipe }}"
6891

6992
- name: Upload artifacts
7093
uses: actions/upload-artifact@v4
7194
with:
72-
name: appimage-${{ matrix.codename }}-${{ matrix.target.arch }}
95+
name: appimage-${{ matrix.base.codename }}-${{ matrix.target.arch }}
7396
path: |
7497
./*.AppImage
7598
./*.AppImage.zsync
7699
if-no-files-found: error
77100

101+
test:
102+
runs-on: ubuntu-latest
103+
needs:
104+
- build
105+
strategy:
106+
fail-fast: false
107+
matrix:
108+
target:
109+
- platform: linux/amd64
110+
arch: amd64
111+
base:
112+
- os: ubuntu
113+
codename: focal
114+
- os: ubuntu
115+
codename: jammy
116+
- os: ubuntu
117+
codename: noble
118+
- os: debian
119+
codename: bullseye
120+
- os: debian
121+
codename: bookworm
122+
- os: debian
123+
codename: trixie
124+
- os: fedora
125+
codename: "39"
126+
- os: fedora
127+
codename: "40"
128+
- os: archlinux
129+
codename: base
130+
131+
steps:
132+
- name: Checkout
133+
uses: actions/checkout@v4
134+
135+
- name: Download artifacts
136+
uses: actions/download-artifact@v4
137+
with:
138+
pattern: appimage-*-${{ matrix.target.arch }}
139+
path: appimages
140+
merge-multiple: true
141+
142+
- name: Setup qemu for docker
143+
uses: docker/setup-qemu-action@v3
144+
if: matrix.target.platform != 'linux/amd64'
145+
146+
- name: Setup buildx for docker
147+
uses: docker/setup-buildx-action@v3
148+
149+
- name: Test AppImages
150+
uses: docker/build-push-action@v5
151+
with:
152+
file: AppImageBuilder.test.Dockerfile
153+
context: appimages
154+
platforms: ${{ matrix.target.platform }}
155+
build-args: |
156+
BASE_OS=${{ matrix.base.os }}
157+
BASE_CODENAME=${{ matrix.base.codename }}
158+
78159
release:
79160
if: startsWith(github.ref, 'refs/tags/')
80161
runs-on: ubuntu-latest
81162

82163
needs:
83164
- build
165+
- test
84166

85167
permissions:
86168
contents: write
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
version: 1
2+
3+
script:
4+
- |
5+
set -eu
6+
7+
if [ "{{APPIMAGE_SOURCE}}" != "${TARGET_APPDIR}" ]; then
8+
mv "{{APPIMAGE_SOURCE}}" "${TARGET_APPDIR}"
9+
fi
10+
11+
# Manual installation of squashfs-tools is required
12+
# until https://github.com/AppImageCrafters/build-appimage/issues/5 is fixed
13+
if ! command -v mksquashfs >/dev/null; then
14+
apt-get update && apt-get install -y --no-install-recommends squashfs-tools
15+
fi
16+
17+
AppDir:
18+
app_info:
19+
id: org.c0rn3j.sc-controller
20+
name: sc-controller
21+
version: "{{APPIMAGE_VERSION}}"
22+
icon: sc-controller
23+
exec: usr/bin/python3
24+
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']))" $@
25+
26+
after_bundle: |
27+
set -eu
28+
29+
# appimage-builder expects .desktop file to start with appinfo-id
30+
desktop="$(find "${TARGET_APPDIR}/usr" -name sc-controller.desktop)"
31+
sed -i "s:Exec=.*:Exec=./usr/bin/scc gui:g" "${desktop}"
32+
ln -sr "${desktop}" "${TARGET_APPDIR}/usr/share/applications/org.c0rn3j.sc-controller.desktop"
33+
34+
# appimage-builder expects utf-8 encoding when patching shebangs,
35+
# but pygettext3 has iso-8859-1 encoding
36+
find "${TARGET_APPDIR}/usr/bin" -name 'pygettext*' | while read -r file; do
37+
encoding="ISO-8859-1"
38+
if file -bi "${file}" | grep -iq "${encoding}"; then
39+
<"${file}" iconv -f "${encoding}" -t utf-8 -o "${file}"
40+
sed -i -E '1,2 s|^(\s*#.*coding[=:]\s*)([[:alnum:].-]+)|\1utf-8|g' "${file}"
41+
fi
42+
done
43+
44+
# install python3-vdf manually if not available as package
45+
if ! apt-cache search --names-only python3-vdf | grep -q .; then
46+
pip install --target "${TARGET_APPDIR}/usr/lib/python3/dist-packages/" vdf
47+
fi
48+
49+
after_runtime: |
50+
set -eu
51+
52+
# python3 is linked against 'lib64/ld-linux-x86-64.so.2'
53+
# but 'compat/lib64' is missing for Ubuntu Noble
54+
compat="${TARGET_APPDIR}/runtime/compat"
55+
if [ ! -e "${compat}/lib64" ] && [ -d "${compat}/usr/lib64" ]; then
56+
ln -s "usr/lib64" "${compat}/"
57+
fi
58+
59+
apt:
60+
arch:
61+
- "{{APPIMAGE_APT_ARCH}}"
62+
sources:
63+
- sourceline: deb http://deb.debian.org/debian {{APPIMAGE_APT_DISTRO}} main
64+
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}}
65+
- sourceline: deb http://deb.debian.org/debian {{APPIMAGE_APT_DISTRO}}-updates main
66+
- sourceline: deb http://deb.debian.org/debian-security/ {{APPIMAGE_APT_DISTRO}}-security main
67+
key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY_SECURITY}}
68+
69+
include:
70+
- gir1.2-gtk-3.0
71+
- gir1.2-rsvg-2.0
72+
- libbluetooth3
73+
- libgtk-3-0
74+
- librsvg2-common
75+
- libx11-6
76+
- libxcb1
77+
- libxext6
78+
- libxfixes3
79+
- python3-evdev
80+
- python3-gi-cairo
81+
- python3-pylibacl
82+
- binutils # required for detection of bluetooth library
83+
- coreutils # provides /usr/bin/env
84+
- shared-mime-info # required for gui if host provides no MIME info, e.g. when XDG_DATA_DIRS is missing
85+
86+
exclude:
87+
# coreutils
88+
- libacl* # filesystem
89+
- libattr* # filesystem
90+
- libgmp* # arithmetics
91+
92+
# gir1.2-rsvg-2.0
93+
- libicu* # i18n
94+
- libstdc* # development
95+
- libxml* # codec
96+
97+
# libgtk3-0
98+
- "*-icon-theme" # gui
99+
- "*crypt*" # security
100+
- "*dconf*" # gui configuration
101+
- "*dbus*" # process communication
102+
- "*gcc*" # development
103+
- "*systemd*" # linux core
104+
- libblk* # filesystem
105+
- libcolord* # gui
106+
- libcups* # printing
107+
- libepoxy* # gui
108+
- libfontconfig* # fonts
109+
- libfreetype* # fonts
110+
- libfribidi* # i18n
111+
- libgtk-3-common # gui
112+
- liblz* # codec
113+
- libmount* # filesystem
114+
- libtiff* # codec
115+
- libwebp* # codec
116+
117+
# python3
118+
- "*krb*" # security
119+
- "*readline*" # terminal
120+
- "*sqlite*" # database
121+
- libbz* # codec
122+
- libdb* # database
123+
- libmpdec* # arithmetics
124+
- libncurses* # terminal
125+
- libnsl* # network
126+
- libssl* # security
127+
- libtirpc* # development
128+
- libuuid* # development
129+
- media-types # codec
130+
131+
# Debian Trixie
132+
- libgprofng* # development
133+
- libjansson* # codec
134+
- libsframe* # development
135+
- libcloudproviders* # networking
136+
- netbase # network
137+
- tzdata # date/time
138+
139+
# Debian Bullseye
140+
- glib-networking* # network
141+
- gsettings* # gui configuration
142+
- libidn2* # codec
143+
- libjson* # codec
144+
- libpsl* # networking
145+
- librest-* # networking
146+
- libsoup* # networking
147+
- libunistring* # unicode
148+
149+
files:
150+
exclude:
151+
- usr/bin/*gold* # alternative for ld
152+
- usr/bin/*gp-display-html* # requires perl
153+
- usr/lib/*/gconv # unicode
154+
- usr/lib/*/gdk-pixbuf-2.0/*/loaders/libpixbufloader-??[!g].so # only png & svg are required
155+
- usr/lib/*/glib-2.0
156+
- usr/lib/python*/cgi.py
157+
- usr/lib/python*/email
158+
- usr/lib/python*/test
159+
- usr/lib/python*/unittest
160+
- usr/share/doc
161+
- usr/share/glib-2.0
162+
- usr/share/gtk-doc
163+
- usr/share/icu
164+
- usr/share/locale
165+
- usr/share/man
166+
- usr/share/python3/runtime.d
167+
- usr/share/thumbnailers
168+
169+
runtime:
170+
env:
171+
# `usr/lib/python3.*/site-packages` is required in $PYTHONPATH,
172+
# but the python version and hence the actual location is unknown here.
173+
# Fortunately the site-packages directory is on the $PATH, so we add $PATH instead.
174+
# It must precede an existing $PYTHONPATH to work.
175+
PYTHONPATH: "${APPDIR}/usr/lib/python3/dist-packages:${PATH}:${PYTHONPATH}"
176+
SCC_SHARED: "${APPDIR}/usr/share/scc"
177+
178+
AppImage:
179+
arch: "{{APPIMAGE_ARCH}}"
180+
update-information: "gh-releases-zsync|C0rn3j|sc-controller|latest|sc-controller-*-{{APPIMAGE_APT_DISTRO}}-{{APPIMAGE_ARCH}}.AppImage.zsync"

0 commit comments

Comments
 (0)