From 832e24c6f7e261f4ffe4c9c47785a979fe98248f Mon Sep 17 00:00:00 2001 From: Agel Date: Thu, 19 Nov 2026 14:49:54 +0100 Subject: [PATCH] fix(linux): preserve AppImage executable bit via .tar.gz and auto-integrate Ubuntu icons Browsers strip POSIX executable permissions (+x) from raw .AppImage files downloaded directly over HTTP, leaving the downloaded binary non-executable in Ubuntu Files (Nautilus). Additionally, Ubuntu displays a generic cog icon for standalone AppImages in both Nautilus and the Ubuntu Dock on Wayland unless desktop metadata, high-DPI icons, and GVfs custom icon attributes are registered. - Wrap `Asteria-.AppImage` (`0755`) in a `.AppImage.tar.gz` archive in `package-linux.sh` and point CI wiki links to the archive so extracting the download preserves executable permissions out of the box. - Copy `.DirIcon` as a regular PNG file rather than a symlink so SquashFS icon extractors that do not follow symlinks receive valid image bytes. - Add non-blocking first-launch integration in `AppRun` to install `hicolor` icons and `asteria-qt.desktop` (`StartupWMClass=asteria-qt`) under `XDG_DATA_HOME` and apply `metadata::custom-icon` on `$APPIMAGE` via `gio` for Nautilus. - Embed 128x128, 256x256, and 512x512 icons in Qt resources and register them with `QApplication::setWindowIcon()`. --- .gitlab-ci.yml | 8 +++--- AGENTS.md | 2 +- CMakeLists.txt | 3 +++ packaging/asteria-qt.desktop | 5 ++-- packaging/package-linux.sh | 4 +++ scripts/bundle-linux-appdir.py | 45 +++++++++++++++++++++++++++++++++- src/main.cpp | 3 +++ 7 files changed, 63 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1d93d7..1a17fdc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -327,6 +327,7 @@ package-linux: name: "asteria-qt-linux-appimage-${CI_COMMIT_SHORT_SHA}" paths: - Asteria-x86_64.AppImage + - Asteria-x86_64.AppImage.tar.gz expire_in: 1 day when: on_success rules: @@ -350,6 +351,7 @@ package-linux-arm64: name: "asteria-qt-linux-arm64-appimage-${CI_COMMIT_SHORT_SHA}" paths: - Asteria-arm64.AppImage + - Asteria-arm64.AppImage.tar.gz expire_in: 1 day when: on_success rules: @@ -462,8 +464,8 @@ update-wiki: - API_URL="${CI_API_V4_URL:-https://gitlab.com/api/v4}/projects/${CI_PROJECT_ID}" - WIKI_URL="${API_URL}/wikis/home" - ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/download" - - LINUX_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-x86_64.AppImage?job=package-linux" - - LINUX_ARM64_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-arm64.AppImage?job=package-linux-arm64" + - LINUX_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-x86_64.AppImage.tar.gz?job=package-linux" + - LINUX_ARM64_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-arm64.AppImage.tar.gz?job=package-linux-arm64" - WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows" - WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64" - MACOS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria.dmg?job=package-macos" @@ -472,7 +474,7 @@ update-wiki: --header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \ "${WIKI_URL}") - NEW_SECTION=$(printf '## Latest dev builds (v%s)\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage](%s) |\n| Linux (ARM64) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%s) |' \ + NEW_SECTION=$(printf '## Latest dev builds (v%s)\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage (.tar.gz)](%s) |\n| Linux (ARM64) | [AppImage (.tar.gz)](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%s) |' \ "${ASTERIA_VERSION}" "${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \ "${LINUX_URL}" "${LINUX_ARM64_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}" "${MACOS_URL}") diff --git a/AGENTS.md b/AGENTS.md index 1bab2f0..3775e7d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -114,7 +114,7 @@ cmake -S . -B build-linux-arm64 -G Ninja \ -DQT_HOST_PATH=/opt/qt/6.12.0/gcc_64 cmake --build build-linux-arm64 --target asteria-qt ``` -AppImage Packaging (uses `scripts/bundle-linux-appdir.py` + `appimagetool` for both `x86_64` and `arm64`): +AppImage Packaging (uses `scripts/bundle-linux-appdir.py` + `appimagetool` for both `x86_64` and `arm64`, outputting `Asteria-.AppImage` (`0755`) and a permission-preserving `Asteria-.AppImage.tar.gz` archive; `AppRun` auto-integrates `~/.local/share/applications/asteria-qt.desktop`, `hicolor` icons, and Nautilus `metadata::custom-icon` on first launch): ```bash packaging/package-linux.sh build-linux /opt/qt/6.12.0/gcc_64 dist x86_64 packaging/package-linux.sh build-linux-arm64 /opt/qt/6.12.0/gcc_arm64 dist arm64 diff --git a/CMakeLists.txt b/CMakeLists.txt index c671077..d94f525 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,9 @@ qt_add_qml_module(asteria-qt packaging/icons/32x32/asteria-qt.png packaging/icons/48x48/asteria-qt.png packaging/icons/64x64/asteria-qt.png + packaging/icons/128x128/asteria-qt.png + packaging/icons/256x256/asteria-qt.png + packaging/icons/512x512/asteria-qt.png RESOURCE_PREFIX / ) diff --git a/packaging/asteria-qt.desktop b/packaging/asteria-qt.desktop index 030b6e5..e2ee7c9 100644 --- a/packaging/asteria-qt.desktop +++ b/packaging/asteria-qt.desktop @@ -2,7 +2,8 @@ Type=Application Name=Asteria Comment=Cross-platform book reader -Exec=asteria-qt +Exec=asteria-qt %f Icon=asteria-qt +StartupWMClass=asteria-qt Categories=Office;Viewer; -MimeType=text/plain; +MimeType=application/epub+zip;application/x-fictionbook+xml;application/vnd.comicbook+zip;application/vnd.comicbook-rar;text/plain; diff --git a/packaging/package-linux.sh b/packaging/package-linux.sh index f05d3bf..713c0a5 100755 --- a/packaging/package-linux.sh +++ b/packaging/package-linux.sh @@ -65,4 +65,8 @@ fi ARCH="$APPIMAGE_ARCH" appimagetool "${APPIMAGETOOL_ARGS[@]}" \ "$APPDIR" "$OUTPUT_DIR/$OUTPUT_NAME" +chmod 0755 "$OUTPUT_DIR/$OUTPUT_NAME" +tar -czf "$OUTPUT_DIR/${OUTPUT_NAME}.tar.gz" -C "$OUTPUT_DIR" "$OUTPUT_NAME" + echo "==> AppImage ($ARCH) created: $OUTPUT_DIR/$OUTPUT_NAME ($(du -sh "$OUTPUT_DIR/$OUTPUT_NAME" | cut -f1))" +echo "==> Archive ($ARCH) created: $OUTPUT_DIR/${OUTPUT_NAME}.tar.gz ($(du -sh "$OUTPUT_DIR/${OUTPUT_NAME}.tar.gz" | cut -f1))" diff --git a/scripts/bundle-linux-appdir.py b/scripts/bundle-linux-appdir.py index 8ed2ab9..27e35b3 100755 --- a/scripts/bundle-linux-appdir.py +++ b/scripts/bundle-linux-appdir.py @@ -130,7 +130,7 @@ def setup_appdir_metadata(appdir): dir_icon = os.path.join(appdir, ".DirIcon") if os.path.lexists(dir_icon): os.remove(dir_icon) - os.symlink("asteria-qt.png", dir_icon) + shutil.copy2(icon_src, dir_icon) apprun_path = os.path.join(appdir, "AppRun") with open(apprun_path, "w", encoding="utf-8") as f: @@ -141,6 +141,49 @@ def setup_appdir_metadata(appdir): 'export QT_PLUGIN_PATH="$HERE/usr/plugins"\n' 'export QML2_IMPORT_PATH="$HERE/usr/qml"\n' 'export QML_IMPORT_PATH="$HERE/usr/qml"\n' + "\n" + '# Auto-integrate desktop icon & Nautilus file icon when running as an AppImage\n' + 'if [ -n "${APPIMAGE:-}" ] && [ -f "$APPIMAGE" ] && [ -n "${HOME:-}" ]; then\n' + " (\n" + ' DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"\n' + " for sz in 16 32 48 64 128 256 512; do\n" + ' SRC_ICON="$HERE/usr/share/icons/hicolor/${sz}x${sz}/apps/asteria-qt.png"\n' + ' DST_DIR="$DATA_HOME/icons/hicolor/${sz}x${sz}/apps"\n' + ' if [ -f "$SRC_ICON" ]; then\n' + ' mkdir -p "$DST_DIR"\n' + ' cp -f "$SRC_ICON" "$DST_DIR/asteria-qt.png"\n' + " fi\n" + " done\n" + ' ICON_256="$DATA_HOME/icons/hicolor/256x256/apps/asteria-qt.png"\n' + ' APPS_DIR="$DATA_HOME/applications"\n' + ' mkdir -p "$APPS_DIR"\n' + ' ESCAPED_APPIMAGE=$(printf "%s" "$APPIMAGE" | sed \'s/"/\\\\"/g\')\n' + ' cat < "$APPS_DIR/asteria-qt.desktop"\n' + "[Desktop Entry]\n" + "Type=Application\n" + "Name=Asteria\n" + "Comment=Cross-platform book reader\n" + 'Exec="$ESCAPED_APPIMAGE" %f\n' + "TryExec=$APPIMAGE\n" + "Icon=$ICON_256\n" + "StartupWMClass=asteria-qt\n" + "Categories=Office;Viewer;\n" + "MimeType=application/epub+zip;application/x-fictionbook+xml;application/vnd.comicbook+zip;application/vnd.comicbook-rar;text/plain;\n" + "EOF\n" + ' chmod 755 "$APPS_DIR/asteria-qt.desktop"\n' + " if command -v gio >/dev/null 2>&1; then\n" + ' gio set "$APPIMAGE" metadata::custom-icon "file://$ICON_256" 2>/dev/null || true\n' + ' gio set "$APPS_DIR/asteria-qt.desktop" metadata::trusted true 2>/dev/null || true\n' + " fi\n" + " if command -v update-desktop-database >/dev/null 2>&1; then\n" + ' update-desktop-database "$APPS_DIR" 2>/dev/null || true\n' + " fi\n" + " if command -v gtk-update-icon-cache >/dev/null 2>&1; then\n" + ' gtk-update-icon-cache -f -t "$DATA_HOME/icons/hicolor" 2>/dev/null || true\n' + " fi\n" + " ) >/dev/null 2>&1 &\n" + "fi\n" + "\n" 'exec "$HERE/usr/bin/asteria-qt" "$@"\n' ) os.chmod(apprun_path, 0o755) diff --git a/src/main.cpp b/src/main.cpp index 33b2e7a..1d7ca99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,6 +90,9 @@ int main(int argc, char *argv[]) appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/32x32/asteria-qt.png"), QSize(32, 32)); appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/48x48/asteria-qt.png"), QSize(48, 48)); appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/64x64/asteria-qt.png"), QSize(64, 64)); + appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/128x128/asteria-qt.png"), QSize(128, 128)); + appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/256x256/asteria-qt.png"), QSize(256, 256)); + appIcon.addFile(QStringLiteral(":/Asteria/packaging/icons/512x512/asteria-qt.png"), QSize(512, 512)); QApplication::setWindowIcon(appIcon); #ifdef Q_OS_MACOS