mirror of
https://git.srhtnin.garden/sarah/SaraSuite.git
synced 2026-10-14 10:28:11 +02:00
62 lines
3.0 KiB
Bash
Executable File
62 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Builds dist/SaraSuite-x86_64.AppImage: a PyInstaller one-file build (with
|
|
# the program manifests, fonts and icon bundled) wrapped by appimagetool,
|
|
# the same way SaraFem's AppImage is made. Needs podman and appimagetool
|
|
# on PATH.
|
|
set -euo pipefail
|
|
cd "$(dirname "$(readlink -f "$0")")/.."
|
|
|
|
find Programs -name __pycache__ -type d -prune -exec rm -rf {} +
|
|
|
|
# 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 flet-desktop pyinstaller
|
|
# The Flet window needs libsecret, which some systems lack: bundled as a
|
|
# fallback (RestoreLibraryPath.py uses only what the system lacks).
|
|
dnf -y -q install libsecret >/dev/null
|
|
mkdir -p build/FallbackLibs
|
|
for Library in libsecret-1.so.0 libgcrypt.so.20 libgpg-error.so.0; do cp -L /usr/lib64/$Library build/FallbackLibs/; done
|
|
# Each finds the others beside it, wherever they are put (a client lib folder).
|
|
patchelf --set-rpath "\$ORIGIN" build/FallbackLibs/libsecret-1.so.0 build/FallbackLibs/libgcrypt.so.20
|
|
build/Container/venv/bin/pyinstaller --noconfirm --clean --log-level WARN \
|
|
--onefile --windowed --name SaraSuite --collect-data flet \
|
|
--runtime-hook "$PWD/Packaging/RestoreLibraryPath.py" \
|
|
--add-data "$PWD/build/FallbackLibs:FallbackLibs" \
|
|
--add-data "$PWD/assets:assets" --add-data "$PWD/Programs:Programs" \
|
|
--distpath build/PyInstaller/dist --workpath build/PyInstaller/work --specpath build/PyInstaller \
|
|
"$PWD/Main.py"'
|
|
|
|
AppDir=build/AppDir
|
|
rm -rf "$AppDir"
|
|
mkdir -p "$AppDir/usr/bin"
|
|
cp build/PyInstaller/dist/SaraSuite "$AppDir/usr/bin/SaraSuite"
|
|
ln -s usr/bin/SaraSuite "$AppDir/AppRun"
|
|
cp assets/Icon.png "$AppDir/SaraSuite.png"
|
|
ln -s SaraSuite.png "$AppDir/.DirIcon"
|
|
cat > "$AppDir/SaraSuite.desktop" << DESKTOP
|
|
[Desktop Entry]
|
|
Type=Application
|
|
Name=SaraSuite
|
|
Comment=Install, update and remove Sara programs
|
|
Exec=SaraSuite
|
|
Icon=SaraSuite
|
|
Terminal=false
|
|
Categories=System;
|
|
StartupWMClass=srhtnin.SaraSuite
|
|
DESKTOP
|
|
|
|
mkdir -p dist
|
|
# Built under a temporary name, then renamed into place: the AppImage can't be
|
|
# overwritten while SaraSuite is running from it ("Text file busy"), but a
|
|
# rename is fine, and the running copy keeps working until it's closed.
|
|
ARCH=x86_64 appimagetool --no-appstream "$AppDir" dist/SaraSuite-x86_64.AppImage.new
|
|
mv -f dist/SaraSuite-x86_64.AppImage.new dist/SaraSuite-x86_64.AppImage
|
|
echo "Built dist/SaraSuite-x86_64.AppImage"
|