Files
wehub-resource-sync 3e779be6f3
CI / lint (push) Failing after 13m4s
CI / test (3.11, ubuntu-latest) (push) Failing after 2m4s
CI / test (3.13, ubuntu-latest) (push) Successful in 13m30s
CI / test (3.14, ubuntu-latest) (push) Successful in 17m21s
CI / test (3.12, ubuntu-latest) (push) Successful in 17m55s
CI / discover-apps-ps (push) Successful in 1m56s
CI / test (3.9, ubuntu-latest) (push) Successful in 13m17s
CI / test (3.10, ubuntu-latest) (push) Successful in 26m21s
CI / audit (push) Successful in 13m38s
Deploy site / deploy (push) Has been cancelled
CI / test (3.14, ubuntu-24.04-arm) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:32:37 +08:00

94 lines
3.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Local AppImage build helper.
#
# Builds an x86_64 AppImage of winpodx using python-appimage. The
# resulting `winpodx-<version>-x86_64.AppImage` lands in this
# directory. CI uses the same flow via .github/workflows/appimage-
# publish.yml.
#
# Prerequisites (host):
# - Python 3.11+ with pip
# - The python-appimage package on PATH (`pip install python-appimage`)
# - `build` (PyPA build) for generating the local wheel
# - Internet access (PySide6 + Pillow + cairosvg wheels pulled from PyPI)
#
# Output:
# - winpodx-<version>-x86_64.AppImage in packaging/appimage/
#
# The recipe directory describes a "lean" Thin AppImage: Python runtime +
# winpodx wheel + PySide6 (Qt6) + reverse-open extras. System binaries
# (FreeRDP, podman/docker) are NOT bundled; winpodx's existing
# `winpodx setup` / `winpodx doctor` paths detect them and emit per-
# distro install hints if any are missing.
#
# The CI Thin AppImage additionally bundles the FreeRDP 3 client stack
# (xfreerdp3 / wlfreerdp3 / sdl-freerdp3 + libwinpr from Fedora 41) via
# bundle-system-bins.sh -- see packaging/appimage/README.md for the
# split between this local-lean build and the CI release artefact.
# Neither build bundles a container runtime (0.6.0 item A, #357 / #363).
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
REPO_ROOT="$(cd "${HERE}/../.." && pwd)"
cd "${REPO_ROOT}"
echo "[appimage] Building winpodx wheel + sdist into ./dist/ ..."
python3 -m pip install --upgrade build python-appimage >/dev/null
python3 -m build --outdir dist
# Find the wheel we just built and rewrite the recipe's requirements.txt
# to point at it. This keeps the AppImage in sync with the current
# branch's code instead of pulling whatever's on PyPI.
WHEEL="$(ls -t dist/winpodx-*.whl | head -n1)"
if [ -z "${WHEEL}" ]; then
echo "[appimage] No wheel produced under dist/; aborting." >&2
exit 1
fi
echo "[appimage] Using wheel: ${WHEEL}"
WHEEL_ABS="$(readlink -f "${WHEEL}")"
REQ="${HERE}/recipe/requirements.txt"
# Pin to absolute path of the freshly-built wheel + keep the extras so
# pip pulls PySide6 + Pillow + cairosvg into the AppImage.
printf '%s[gui,reverse-open]\n' "${WHEEL_ABS}" > "${REQ}"
cd "${HERE}"
echo "[appimage] Running python-appimage build ..."
python3 -m python_appimage build app -p 3.11 recipe/
echo "[appimage] Resulting AppImage(s):"
ls -lh winpodx-*-x86_64.AppImage 2>/dev/null || {
echo "[appimage] No AppImage produced. Check python-appimage output above." >&2
exit 1
}
# Slim the bundled Qt6 to match the CI release artefact: PySide6 wheels
# ship the whole Qt6 stack (QtWebEngine etc.), but winpodx links only
# QtCore/QtGui/QtWidgets/QtSvg/QtDBus. Extract -> prune -> repack. Best-
# effort locally: if appimagetool isn't on PATH, the slimmed AppDir is left
# in squashfs-root/ and CI still slims the release build.
APP="$(ls -t winpodx-*-x86_64.AppImage | head -n1)"
echo "[appimage] Slimming bundled Qt6 in ${APP} ..."
rm -rf squashfs-root
"./${APP}" --appimage-extract >/dev/null
PYSIDE_DIR="$(find squashfs-root -type d -name PySide6 -path '*site-packages*' | head -n1)"
if [ -n "${PYSIDE_DIR}" ]; then
bash "${HERE}/slim-pyside6.sh" "${PYSIDE_DIR}"
if command -v appimagetool >/dev/null 2>&1; then
ARCH=x86_64 appimagetool squashfs-root "${APP}" >/dev/null 2>&1
chmod +x "${APP}"
rm -rf squashfs-root
echo "[appimage] Re-packed slim ${APP}: $(du -h "${APP}" | cut -f1)"
else
echo "[appimage] appimagetool not on PATH -- slimmed AppDir left in squashfs-root/; install appimagetool to repack locally (CI repacks the release build)." >&2
fi
else
echo "[appimage] PySide6 dir not found in extracted AppImage -- skipping slim." >&2
rm -rf squashfs-root
fi
# Restore the recipe to its committed shape so the next git status is clean.
printf 'winpodx[gui,reverse-open]\n' > "${REQ}"
echo "[appimage] Done."