forked from Ryochan7/sc-controller
-
Notifications
You must be signed in to change notification settings - Fork 3
/
AppImageBuilder.debian.yml
205 lines (180 loc) · 7.67 KB
/
AppImageBuilder.debian.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
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
# install python3-ioctl-opt manually as it is not packaged anywhere
pip install --target "${TARGET_APPDIR}/usr/lib/python3/dist-packages/" ioctl-opt
# 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
# remove unused icons
icons="${TARGET_APPDIR}/usr/share/icons"
keep=$(
# Subset of: `wget -q https://specifications.freedesktop.org/icon-naming-spec/latest -O- | sed -nE 's:.*</td></tr><tr><td>([^<]+).*:\1:p' | sort`
printf '%s\n' index.theme close- edit- go- list- pan- window-
grep -rhoP '"icon_name">\K[^<]+(?=<)' glade
grep -rhoP 'icon_name *= *"\K[^"]+(?=")' scc
)
map_item() { echo "${1}" | while read -r item; do printf -- "${2}" "${item}"; done; }
paths=$(find "${icons}" '(' -false $(map_item "${keep}" ' -o -name %s*') ')' -print -type l -printf '%h/%l\n' | sort | uniq)
find "${icons}" \( -type d -empty -or -not -type d $(map_item "${paths}" ' -not -samefile %s') \) -delete
cancel() { echo >&2 "ERROR: ${@}" && return 1; }
if find "${icons}" -xtype l | grep .; then
cancel 'The symlinks shown above are broken.'
fi
if echo "${keep}" | while read -r icon; do echo "${paths}" | grep -q "${icon}[^/]*$" || echo "${icon}"; done | grep .; then
cancel 'The icons above are missing.'
fi
# Enable icon theme
xdg_settings="${TARGET_APPDIR}/etc/xdg/gtk-3.0/settings.ini"
if [ ! -e "${xdg_settings}" ]; then
mkdir -p "$(dirname "${xdg_settings}")"
theme=$(find "${icons}" -mindepth 1 -maxdepth 1 -type d -printf %f -quit)
printf '[Settings]\ngtk-icon-theme-name = %s\n' "${theme}" >"${xdg_settings}"
fi
# python3-usb1 expects 'libusb-1.0.so', see https://github.com/vpelletier/python-libusb1/issues/78
find "${TARGET_APPDIR}" -name 'libusb-1.0.so.[0-9]' | while read -r file; do
path="$(dirname "${file}")"
link="${file%.[0-9]}"
[ -e "${link}" ] || ln -sr "${file}" "${link}"
done
# Trixie expects libpixbufloader libs with a dash suffix, not underscore
# see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1082676
find "${TARGET_APPDIR}" -type f -name 'libpixbufloader_*' | while read -r file; do
path="$(dirname "${file}")"
link="${path}/$(echo "$(basename "${file}")" | tr _ -)"
[ -e "${link}" ] || ln -sr "${file}" "${link}"
done
after_runtime: |
set -eu
# python3 is linked against 'lib64/ld-linux-x86-64.so.2' but 'compat/lib64' is missing
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
- python-is-python3
- python3-evdev
- python3-gi-cairo
- python3-pylibacl
- python3-usb1
- python3-vdf
- binutils # required for detection of bluetooth library
- coreutils # provides /usr/bin/env
- paper-icon-theme # required for icons
- shared-mime-info # required for gui if host provides no MIME info, e.g. when XDG_DATA_DIRS is missing
exclude:
# coreutils
- 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
- 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
- netbase # network
- tzdata # date/time
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*/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"