Files
SaraFem/Packaging/BuildAppImage.sh
T
2026-10-13 10:22:00 +02:00

36 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Builds Packaging/appimage/SaraFem-x86_64.AppImage (where Install.sh expects
# it): a PyInstaller one-file build from SaraFem.spec, put into the AppDir
# next to it and wrapped by appimagetool. Needs podman and appimagetool on
# PATH.
set -euo pipefail
cd "$(dirname "$(readlink -f "$0")")/.."
# PyInstaller runs in a manylinux_2_28 container (glibc 2.28) with uv's
# portable Python, not with Fedora's: PyInstaller bundles libpython, and
# Fedora's needs a newer glibc than many distros have ("GLIBC_ABI_GNU2_TLS
# not found"). The Python, venv and downloads are cached in build/Container.
mkdir -p build/Container
podman run --rm --security-opt label=disable -v "$PWD:/src" -w /src \
-e UV_CACHE_DIR=/src/build/Container/cache -e UV_PYTHON_INSTALL_DIR=/src/build/Container/python \
quay.io/pypa/manylinux_2_28_x86_64 bash -euo pipefail -c '
uv venv --quiet --allow-existing --managed-python --python 3.14 build/Container/venv
uv pip install --quiet --python build/Container/venv -r requirements.txt pyinstaller
build/Container/venv/bin/pyinstaller --noconfirm --clean --log-level WARN \
--distpath build/PyInstaller/dist --workpath build/PyInstaller/work \
SaraFem.spec'
AppDir=Packaging/appimage/AppDir
mkdir -p "$AppDir/usr/bin"
cp build/PyInstaller/dist/SaraFem "$AppDir/usr/bin/SaraFem"
# Both icons are copies of assets/Icon.png (Install.sh installs Icon.png), so
# updating that one is enough.
cp assets/Icon.png "$AppDir/sarafem.png"
cp assets/Icon.png Packaging/appimage/Icon.png
# Built under a temporary name, then renamed into place: the AppImage can't be
# overwritten while SaraFem is running from it ("Text file busy").
ARCH=x86_64 appimagetool --no-appstream "$AppDir" Packaging/appimage/SaraFem-x86_64.AppImage.new
mv -f Packaging/appimage/SaraFem-x86_64.AppImage.new Packaging/appimage/SaraFem-x86_64.AppImage
echo "Built Packaging/appimage/SaraFem-x86_64.AppImage"