From bff65d0db52eec653b163bdb19a77bc5e192d38b Mon Sep 17 00:00:00 2001 From: Christian Date: Sat, 21 Sep 2024 15:22:42 +0200 Subject: [PATCH] AppImage: add missing icons (#25) * feat(appimage): increase compatibility, add tests, add missing icons * chore(appimage): update github release action --- .github/workflows/appimage.yml | 2 +- AppImageBuilder.debian-bullseye.yml | 54 +++++++++++++++++------------ AppImageBuilder.debian.yml | 40 ++++++++++++++++----- AppImageBuilder.test.Dockerfile | 11 ++++++ AppImageBuilder.ubuntu-focal.yml | 50 +++++++++++++++----------- AppImageBuilder.yml | 40 ++++++++++++++++----- 6 files changed, 137 insertions(+), 60 deletions(-) diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index 86ba8e4b..470d9e10 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -182,6 +182,6 @@ jobs: shasum --binary --algorithm "${algo}" "${asset}" >"${asset}.sha${algo}" done - name: Upload artifacts to GitHub release - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: assets/* diff --git a/AppImageBuilder.debian-bullseye.yml b/AppImageBuilder.debian-bullseye.yml index eda29976..0984849e 100644 --- a/AppImageBuilder.debian-bullseye.yml +++ b/AppImageBuilder.debian-bullseye.yml @@ -41,24 +41,42 @@ AppDir: 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 + # 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:.*([^<]+).*:\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 - after_runtime: | - set -eu + # 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 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}/" + # 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 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}} @@ -72,16 +90,13 @@ AppDir: - libbluetooth3 - libgtk-3-0 - librsvg2-common - - libx11-6 - - libxcb1 - - libxext6 - - libxfixes3 - python3-evdev - python3-gi-cairo - python3-pylibacl - python3-usb1 - 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: @@ -128,14 +143,7 @@ AppDir: - libtirpc* # development - libuuid* # development - media-types # codec - - # Debian Trixie - - libgprofng* # development - - libjansson* # codec - - libsframe* # development - - libcloudproviders* # networking - - netbase # network - - tzdata # date/time + - tzdata # Debian Bullseye - glib-networking* # network @@ -152,7 +160,7 @@ AppDir: - 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/*/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 diff --git a/AppImageBuilder.debian.yml b/AppImageBuilder.debian.yml index 4ce9287a..2f0cec9d 100644 --- a/AppImageBuilder.debian.yml +++ b/AppImageBuilder.debian.yml @@ -41,11 +41,37 @@ AppDir: 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:.*([^<]+).*:\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 + after_runtime: | set -eu - # python3 is linked against 'lib64/ld-linux-x86-64.so.2' - # but 'compat/lib64' is missing for Ubuntu Noble + # 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}/" @@ -54,6 +80,7 @@ AppDir: 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}} @@ -67,17 +94,14 @@ AppDir: - libbluetooth3 - libgtk-3-0 - librsvg2-common - - libx11-6 - - libxcb1 - - libxext6 - - libxfixes3 - python3-evdev - python3-gi-cairo - python3-pylibacl - - python3-vdf - 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: @@ -138,7 +162,7 @@ AppDir: - 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/*/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 diff --git a/AppImageBuilder.test.Dockerfile b/AppImageBuilder.test.Dockerfile index b4dbb424..20e4489f 100644 --- a/AppImageBuilder.test.Dockerfile +++ b/AppImageBuilder.test.Dockerfile @@ -27,11 +27,22 @@ RUN </dev/null; then + apt-get update && apt-get install -y --no-install-recommends libx11-6 + elif command -v pacman >/dev/null; then + pacman -Syu --noconfirm libx11 + elif command -v dnf >/dev/null; then + dnf list updates && dnf install -y libX11 + fi + } + main() { files="$(find /opt/ -maxdepth 1 -type f -name '*.AppImage')" if [ -z "${files}" ]; then cancel "Error: No AppImage file found." fi + prepare echo "${files}" | while read -r file; do log "${file}" chmod +x "${file}" diff --git a/AppImageBuilder.ubuntu-focal.yml b/AppImageBuilder.ubuntu-focal.yml index f97e57a6..ce77ea1a 100644 --- a/AppImageBuilder.ubuntu-focal.yml +++ b/AppImageBuilder.ubuntu-focal.yml @@ -46,19 +46,37 @@ AppDir: pip install --target "${TARGET_APPDIR}/usr/lib/python3/dist-packages/" vdf fi - after_runtime: | - set -eu + # 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:.*([^<]+).*:\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 - # 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}/" + # 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 apt: arch: - "{{APPIMAGE_APT_ARCH}}" + sources: - sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ {{APPIMAGE_APT_DISTRO}} main universe key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}} @@ -67,6 +85,8 @@ AppDir: - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}} main universe - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}}-updates main universe - sourceline: deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports/ {{APPIMAGE_APT_DISTRO}}-security main universe + - sourceline: deb https://ppa.launchpadcontent.net/snwh/ppa/ubuntu focal main + key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x023634F5E3DE42B7594EB77B9528DA3D98902E4B include: - gir1.2-gtk-3.0 @@ -74,16 +94,13 @@ AppDir: - libbluetooth3 - libgtk-3-0 - librsvg2-common - - libx11-6 - - libxcb1 - - libxext6 - - libxfixes3 - python3-evdev - python3-gi-cairo - - python3-pylibacl - python3-libusb1 + - python3-pylibacl - 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: @@ -140,19 +157,12 @@ AppDir: - libunistring* # unicode - mime-support # codec - # Ubuntu Noble - - 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/*/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 diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml index 52ffc3ee..07e1f8d1 100644 --- a/AppImageBuilder.yml +++ b/AppImageBuilder.yml @@ -41,11 +41,37 @@ AppDir: 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:.*([^<]+).*:\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 + after_runtime: | set -eu - # python3 is linked against 'lib64/ld-linux-x86-64.so.2' - # but 'compat/lib64' is missing for Ubuntu Noble + # 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}/" @@ -54,6 +80,7 @@ AppDir: apt: arch: - "{{APPIMAGE_APT_ARCH}}" + sources: - sourceline: deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ {{APPIMAGE_APT_DISTRO}} main universe key_url: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x{{APPIMAGE_APT_PUBKEY}} @@ -69,17 +96,14 @@ AppDir: - libbluetooth3 - libgtk-3-0 - librsvg2-common - - libx11-6 - - libxcb1 - - libxext6 - - libxfixes3 - python3-evdev - python3-gi-cairo - python3-pylibacl + - python3-usb1 - python3-vdf - - python3-libusb1 - 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: @@ -139,7 +163,7 @@ AppDir: - 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/*/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