Mulberry/packaging/linux/build-linux.sh
Jacob Ward 623ced06b7 Build scripts: Windows (PowerShell) and Linux from source
packaging/windows/build-windows.ps1 makes the portable zip and the installer;
packaging/linux/build-linux.sh makes the tarball and the AppImage. Both follow
the steps of the CI workflow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-16 01:05:23 -05:00

44 lines
2 KiB
Shell
Executable file

#!/usr/bin/env bash
# Builds Mulberry for Linux from source: the app folder, a tarball and an AppImage.
# Same steps as the "linux" job in .github/workflows/build.yml.
#
# Needs: python3 (3.11+), curl, internet for the first run.
# Run: bash packaging/linux/build-linux.sh
# Output: dist/Mulberry-Linux-x86_64.tar.gz and dist/Mulberry-x86_64.AppImage
#
# The result runs on distros at least as new as the one it was built on (glibc), so build on an
# older distro (CI uses Ubuntu 22.04) for downloads you share.
set -euo pipefail
cd "$(dirname "$0")/../.."
# ---- Python environment (.venv in the repo)
[ -x .venv/bin/python ] || python3 -m venv .venv
.venv/bin/pip install --upgrade pip
.venv/bin/pip install -r requirements.txt pyinstaller
# ---- App
.venv/bin/python packaging/make_icons.py
.venv/bin/pyinstaller packaging/mulberry.spec --noconfirm --distpath build/dist --workpath build/work
# ---- Tarball
mkdir -p dist
cp mulberry.desktop mulberry/assets/mulberry.svg build/dist/Mulberry/
tar -C build/dist -czf dist/Mulberry-Linux-x86_64.tar.gz Mulberry
echo "== dist/Mulberry-Linux-x86_64.tar.gz"
# ---- AppImage
APPDIR=build/AppDir
rm -rf "$APPDIR"
mkdir -p $APPDIR/usr/lib $APPDIR/usr/share/icons/hicolor/256x256/apps $APPDIR/usr/share/applications
cp -r build/dist/Mulberry $APPDIR/usr/lib/mulberry
cp packaging/linux/AppRun $APPDIR/AppRun && chmod +x $APPDIR/AppRun
grep -v '^Actions=\|^\[Desktop Action\|^Name=Play\|^Name=Next\|^Name=Previous\|^Exec=dbus' mulberry.desktop > $APPDIR/mulberry.desktop
cp $APPDIR/mulberry.desktop $APPDIR/usr/share/applications/
cp packaging/build-icons/mulberry-256.png $APPDIR/mulberry.png
cp packaging/build-icons/mulberry-256.png $APPDIR/usr/share/icons/hicolor/256x256/apps/mulberry.png
if [ ! -x build/appimagetool ]; then
curl -sSfL -o build/appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x build/appimagetool
fi
ARCH=x86_64 build/appimagetool --appimage-extract-and-run $APPDIR dist/Mulberry-x86_64.AppImage
echo "== dist/Mulberry-x86_64.AppImage"