diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d890556..baf151c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,12 +260,13 @@ jobs: SCCACHE_GHA_ENABLED: "true" run: bash build-aux/appimage/build-container.sh - # The AppImage catalog tests on the oldest Ubuntu LTS in standard - # support. Loading the app there proves its glibc needs are old enough. - - name: Start AppImage on Ubuntu 22.04 - run: | - docker run --rm -v "$PWD/appimage-build:/appimage:ro" ubuntu:22.04 \ - sh -euc '/appimage/AdventureMods-*.AppImage --appimage-extract-and-run --version' + # The AppImage catalog opens the app on the oldest Ubuntu LTS in + # standard support, with only a virtual X server. The window there + # proves that its glibc needs are old enough and that it brings the + # libraries it opens at runtime. + - name: Open AppImage window on Ubuntu 22.04 + timeout-minutes: 10 + run: bash build-aux/appimage/test-window.sh appimage-build/AdventureMods-*.AppImage - name: Upload artifact uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 @@ -273,6 +274,34 @@ jobs: name: AdventureMods-AppImage-${{ matrix.arch }} path: appimage-build/*.AppImage* + # The AppImage catalog (appimage.github.io) runs its own test on every + # entry: lint, firejail, a screenshot and checks on it. This runs that test + # on its runner, so that a release does not fail there. + appimage-catalog: + needs: appimage + runs-on: ubuntu-22.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Download AppImage + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: AdventureMods-AppImage-x86_64 + path: appimage-build + + - name: Run the AppImage catalog test + run: bash build-aux/appimage/catalog-test.sh appimage-build/AdventureMods-*-x86_64.AppImage Adventure_Mods + + - name: Upload catalog test result + if: always() + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + # Outside the AdventureMods-AppImage-* pattern the release job downloads. + name: appimage-catalog-test + path: appimage-catalog-result + if-no-files-found: ignore + snap: needs: changes if: needs.changes.outputs.packaging == 'true' @@ -333,7 +362,7 @@ jobs: ci: name: CI / Required if: always() - needs: [changes, test, translations, coverage, flatpak, appimage, snap] + needs: [changes, test, translations, coverage, flatpak, appimage, appimage-catalog, snap] runs-on: ubuntu-26.04 steps: - name: Check job results @@ -390,7 +419,7 @@ jobs: release: if: startsWith(github.ref, 'refs/tags/') - needs: [test, coverage, appimage, snap, flatpak, create-release] + needs: [test, coverage, appimage, appimage-catalog, snap, flatpak, create-release] runs-on: ubuntu-26.04 permissions: contents: write diff --git a/Cargo.lock b/Cargo.lock index 22e8675..410a6fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,7 +134,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adventure-mods" -version = "1.3.5" +version = "1.3.6" dependencies = [ "anyhow", "async-channel", diff --git a/Cargo.toml b/Cargo.toml index af78e46..345fede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "adventure-mods" -version = "1.3.5" +version = "1.3.6" edition = "2024" license = "MIT" diff --git a/build-aux/appimage/build-appimage.sh b/build-aux/appimage/build-appimage.sh index 4478ccd..3268437 100755 --- a/build-aux/appimage/build-appimage.sh +++ b/build-aux/appimage/build-appimage.sh @@ -54,16 +54,39 @@ cat >"$APPDIR/apprun-hooks/adventure-mods.sh" <<'HOOK' export PATH="$APPDIR/usr/bin:$PATH" HOOK +# File managers and the AppImage catalog show .DirIcon as the thumbnail, and +# the catalog wants a PNG. linuxdeploy links it to the SVG, unless it exists. +icon_name="io.github.astrovm.AdventureMods" +icon_png="usr/share/icons/hicolor/256x256/apps/$icon_name.png" +mkdir -p "$APPDIR/$(dirname "$icon_png")" +rsvg-convert -w 256 -h 256 -o "$APPDIR/$icon_png" \ + "$APPDIR/usr/share/icons/hicolor/scalable/apps/$icon_name.svg" +ln -sfn "$icon_png" "$APPDIR/.DirIcon" + echo "==> Bundling libraries and creating the AppImage" cd "$BUILD_DIR" -# OpenGL, Vulkan, Wayland and xkbcommon are loaded at runtime from the host, -# so they match its graphics drivers and are not bundled. +# winit opens the X11 and Wayland libraries at runtime, so linuxdeploy can't +# see them. OpenGL, EGL, libX11, libxcb and libwayland-client come from the +# host: they are on the AppImage exclude list, because they must match its +# graphics drivers and display server. These are not on it, and minimal +# systems don't have them, so the AppImage brings them. linuxdeploy adds +# what they need in turn, such as libxcb-xkb and libXrender. +runtime_libs=() +for lib in libxkbcommon.so.0 libxkbcommon-x11.so.0 libXcursor.so.1 libXi.so.6; do + path="$(/sbin/ldconfig -p | awk -v lib="$lib" '$1 == lib { print $NF; exit }')" + if [ -z "$path" ]; then + echo "Missing $lib on the build system. Install it in build-container.sh." >&2 + exit 1 + fi + runtime_libs+=(--library "$path") +done export NO_STRIP=1 export LDAI_UPDATE_INFORMATION="gh-releases-zsync|astrovm|AdventureMods|latest|AdventureMods-v*-${APPIMAGE_ARCH}.AppImage.zsync" ./linuxdeploy --appimage-extract-and-run \ --appdir "$APPDIR" \ --desktop-file "$APPDIR/usr/share/applications/io.github.astrovm.AdventureMods.desktop" \ --icon-file "$APPDIR/usr/share/icons/hicolor/scalable/apps/io.github.astrovm.AdventureMods.svg" \ + "${runtime_libs[@]}" \ --output appimage # An AppImage uses the host's glibc, so it only starts where that glibc is at diff --git a/build-aux/appimage/build-container.sh b/build-aux/appimage/build-container.sh index ba39b65..6ca19d1 100755 --- a/build-aux/appimage/build-container.sh +++ b/build-aux/appimage/build-container.sh @@ -37,6 +37,7 @@ fi apt-get install -y -qq \ build-essential pkg-config ninja-build python3-pip gettext \ libudev-dev desktop-file-utils appstream \ + libxkbcommon-x11-0 libxcursor1 libxi6 librsvg2-bin \ wget unzip file libfuse2 curl git sudo zsync pip3 install --quiet --no-cache-dir -r build-aux/appimage/requirements.txt curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --quiet diff --git a/build-aux/appimage/catalog-test.sh b/build-aux/appimage/catalog-test.sh new file mode 100755 index 0000000..cb6808e --- /dev/null +++ b/build-aux/appimage/catalog-test.sh @@ -0,0 +1,146 @@ +#!/usr/bin/env bash +# Run the AppImage catalog's own test on a local AppImage: code/worker.sh from +# AppImage/appimage.github.io, set up as its .github/workflows/test.yml does. +# It runs the app in firejail, which loop-mounts the AppImage as root, so it +# needs a real host with sudo, such as a GitHub ubuntu-22.04 runner (the +# catalog uses one). A rootless container is not enough; for a quick local +# check, use test-window.sh. +# +# It also changes the host as root, as the catalog's runner does: it installs +# packages and copies firejail into /lib, /usr and /etc. So it runs only on +# GitHub Actions, or with ALLOW_HOST_CHANGES=1 on a throwaway machine. +# +# Usage: catalog-test.sh +# It writes log.txt, findings.txt and the screenshot to $CATALOG_RESULT +# (default: appimage-catalog-result). It fails when the catalog test fails, +# makes no screenshot, or finds a warning or error that is not in $known. +set -euo pipefail + +# The catalog changes its test often. Update this commit on purpose. +CATALOG_COMMIT="ba37bcf481d0e8429b4a5ef67d095c279dac7aa2" + +# The findings this app is known to have. Any other warning or error fails, +# so that a fixed warning, such as the icon format, cannot come back. +# - No appdata file present: the catalog looks only for *appdata.xml, and its +# old appstreamcli fails on the current file under that name. +# - The window is mostly dark: the app's blue design. The catalog ignores it +# for its screenshot-ok label. +known='^WARNING: (No appdata file present|The window is mostly dark)' + +if [ ! -f "${1:-}" ] || [ -z "${2:-}" ]; then + echo "Usage: $0 " >&2 + exit 2 +fi +if [ "${GITHUB_ACTIONS:-}" != true ] && [ "${ALLOW_HOST_CHANGES:-}" != 1 ]; then + echo "This test changes the host as root. Run it on GitHub Actions, or set ALLOW_HOST_CHANGES=1 on a throwaway machine." >&2 + exit 2 +fi +appimage="$(readlink -f "$1")" +name="$2" +result="$(readlink -f "${CATALOG_RESULT:-appimage-catalog-result}")" +work="$(mktemp -d)" +serve="$work/serve" +catalog="$work/catalog" +rm -rf "$result" +mkdir -p "$result" "$serve" + +pids=() +cleanup() { + if [ "${#pids[@]}" -gt 0 ]; then + kill "${pids[@]}" 2>/dev/null || true + fi + # worker.sh extracts firejail into the work folder as root. + sudo rm -rf "$work" +} +trap cleanup EXIT + +git clone -q --filter=blob:none https://github.com/AppImage/appimage.github.io "$catalog" +git -C "$catalog" checkout -q "$CATALOG_COMMIT" +cd "$catalog" + +echo "==> Installing the catalog's test packages" +packages="$(sed -n 's/^ *packages: *//p' .github/workflows/test.yml)" +if [ -z "$packages" ]; then + echo "Found no package list in the catalog's test.yml" >&2 + exit 1 +fi +sudo apt-get update -qq +# shellcheck disable=SC2086 # The list is space-separated. +sudo apt-get install -y -qq --no-install-recommends $packages >/dev/null +# worker.sh converts the desktop file with dv (dupervisor), as the catalog +# workflow installs it. It skips asar, which only Electron apps need. +sudo gem install dupervisor -v 1.0.5 >/dev/null +bash code/fetch-deps.sh >/dev/null +cp -a deps/. . +# The catalog workflow stops when this fails, so this test stops too. +sudo bash code/prep-dummy-soundcard.sh >/dev/null + +# The catalog downloads the AppImage from the link in data/. Serve this +# one under its own file name, so that the name checks see the real name. +cp "$appimage" "$serve/" +# GitHub runners have Node.js. +node -e ' +const http = require("http"), fs = require("fs"), path = require("path"); +const dir = process.argv[1]; +http.createServer((request, response) => { + const file = path.join(dir, path.basename(decodeURIComponent(request.url.split("?")[0]))); + fs.stat(file, (error, stat) => { + if (error || !stat.isFile()) { response.writeHead(404); return response.end(); } + response.writeHead(200, { "Content-Length": stat.size }); + if (request.method === "HEAD") return response.end(); + fs.createReadStream(file).pipe(response); + }); +}).listen(8765, "127.0.0.1"); +' "$serve" & +pids+=($!) +url="http://127.0.0.1:8765/$(basename "$appimage")" +for _ in $(seq 20); do + curl -fsI "$url" >/dev/null 2>&1 && break + sleep 0.5 +done +echo "$url" >"data/$name" + +mkdir -p "$HOME/.icewm" +cat >"$HOME/.icewm/preferences" <<'EOF' +ShowTaskBar = 0 +TaskBarAutoHide = 1 +TaskBarShowWorkspaces = 0 +TaskBarShowAllWindows = 0 +TaskBarShowClock = 0 +TaskBarShowMailboxStatus = 0 +TaskBarShowCPUStatus = 0 +TaskBarShowWindowListMenu = 0 +EOF +Xvfb :99 -screen 0 800x600x24 >/dev/null 2>&1 & +pids+=($!) +export DISPLAY=:99 IS_PULLREQUEST=true STRICT=true + +echo "==> Running the catalog test" +set +e +timeout --kill-after=30 600 bash -e code/worker.sh "$catalog/data/$name" >log.txt 2>&1 +status=$? +set -e +cp log.txt "$result/" +cp "database/$name/screenshot.png" "$result/" 2>/dev/null || true +cp failure-screens/*.png "$result/" 2>/dev/null || true +grep -hE '^(ERROR|WARNING|NOTE): ' log.txt | sort -u >"$result/findings.txt" || true +bash code/diagnose.sh log.txt >"$result/hints.md" 2>/dev/null || true + +echo "==> Findings" +cat "$result/findings.txt" +if [ "$status" -ne 0 ]; then + echo "The catalog test failed (exit $status). See $result/log.txt." >&2 + tail -n 40 log.txt >&2 + exit 1 +fi +if [ ! -f "$result/screenshot.png" ]; then + echo "The catalog test made no screenshot." >&2 + exit 1 +fi +unknown="$(grep -E '^(WARNING|ERROR): ' "$result/findings.txt" | grep -Ev "$known" || true)" +if [ -n "$unknown" ]; then + echo "The catalog test found new warnings or errors:" >&2 + echo "$unknown" >&2 + exit 1 +fi +echo "The catalog test passed." diff --git a/build-aux/appimage/test-window.sh b/build-aux/appimage/test-window.sh new file mode 100755 index 0000000..dbed0d6 --- /dev/null +++ b/build-aux/appimage/test-window.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# Start the AppImage on a minimal Ubuntu 22.04 with only a virtual X server, +# the way the AppImage catalog tests it, and check that its window opens. +# Usage: test-window.sh [platform, such as linux/arm64] +set -euo pipefail + +if [ ! -f "${1:-}" ]; then + echo "Usage: $0 [platform]. No AppImage at '${1:-}'." >&2 + exit 2 +fi +appimage="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" +platform="${2:-}" +engine="$(command -v podman || command -v docker)" +platform_args=() +if [ -n "$platform" ]; then + platform_args=(--platform "$platform") +fi + +"$engine" run --rm "${platform_args[@]}" \ + -e DEBIAN_FRONTEND=noninteractive \ + -v "$appimage:/app.AppImage:ro" \ + docker.io/library/ubuntu:22.04 \ + bash -c ' + set -euo pipefail + apt-get update -qq + # Xvfb brings libX11 and libxcb; Mesa brings OpenGL. Nothing else. + apt-get install -y -qq --no-install-recommends \ + xvfb x11-utils libgl1-mesa-dri libgl1 libegl1 >/dev/null + Xvfb :99 -screen 0 1280x800x24 >/dev/null 2>&1 & + export DISPLAY=:99 HOME=/tmp/home + mkdir -p "$HOME" + for _ in $(seq 30); do + xdpyinfo >/dev/null 2>&1 && break + sleep 0.5 + done + xdpyinfo >/dev/null + cd /tmp + /app.AppImage --appimage-extract-and-run >/tmp/app.log 2>&1 & + app=$! + for _ in $(seq 60); do + # The window is mapped, not only created. + state="$(xwininfo -name "Adventure Mods" 2>/dev/null || true)" + if grep -q "IsViewable" <<<"$state"; then + # The app must survive its first frames too. + sleep 3 + if kill -0 "$app" 2>/dev/null; then + echo "The window opened." + kill "$app" 2>/dev/null || true + exit 0 + fi + echo "The window opened, but the app then stopped:" >&2 + cat /tmp/app.log >&2 + exit 1 + fi + if ! kill -0 "$app" 2>/dev/null; then + break + fi + sleep 1 + done + echo "The window did not open within 60 seconds:" >&2 + cat /tmp/app.log >&2 + exit 1 + ' diff --git a/data/io.github.astrovm.AdventureMods.metainfo.xml.in b/data/io.github.astrovm.AdventureMods.metainfo.xml.in index 18732b0..e0d5f7b 100644 --- a/data/io.github.astrovm.AdventureMods.metainfo.xml.in +++ b/data/io.github.astrovm.AdventureMods.metainfo.xml.in @@ -55,6 +55,11 @@ #1a5fb4 + + +

The AppImage opens its window on systems without some X11 keyboard and cursor libraries, such as a minimal Ubuntu 22.04.

+
+

The AppImage now starts on older systems, such as Ubuntu 22.04.

diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index 0c2a93b..819d88f 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -134,7 +134,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" [[package]] name = "adventure-mods" -version = "1.3.4" +version = "1.3.6" dependencies = [ "anyhow", "async-channel",