Files
o3de-flatpak/scripts/make-flatpak.sh
T
pc-heini f4d2dddd02 Fix read-only /app failure + add app icon
On first launch O3DE pip-installs its 'o3de' CLI with 'pip install -e'
(editable), which writes an egg-info next to the source under read-only
/app and fails ([Errno 30] Read-only file system), leaving the venv broken
("unable to install O3DE's built-in Python").

- Patch cmake/LYPython.cmake at build time to force a normal (non-editable)
  install, which builds in a temp dir and lands in the writable ~/.o3de venv.
- Drop the build-time get_python "bake": the venv is per-user (keyed to
  $HOME), so it can only be created at runtime; baking under a throwaway
  build HOME did nothing. Speeds up CI; removes cmake/python3 build deps and
  the network build-arg.
- Add a real launcher icon (org.o3de.O3DE.png).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 12:02:41 +02:00

72 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build the O3DE Flatpak WITHOUT flatpak-builder.
#
# flatpak-builder runs every build command inside a bubblewrap sandbox, which
# needs user namespaces / a privileged container - awkward in CI. We don't need
# it: our "build" is just unpacking a .deb and running get_python.sh, both plain
# shell. flatpak build-init/build-finish/build-export only touch files and the
# OSTree repo (no bwrap), so this works in an unprivileged container.
#
# Expects ./o3de.deb to already be present. Produces ./repo (an OSTree repo).
set -euo pipefail
cd "$(dirname "$0")/.."
APP_ID=org.o3de.O3DE
RUNTIME=org.freedesktop.Sdk
RUNTIME_VER=24.08
BRANCH=stable
rm -rf build-dir data repo
echo ">> build-init"
flatpak build-init build-dir "$APP_ID" "$RUNTIME" "$RUNTIME" "$RUNTIME_VER"
DEST=build-dir/files
echo ">> extracting .deb payload"
mkdir -p data
ar x o3de.deb
tar -C data -xf data.tar.*
mkdir -p "$DEST/opt"
cp -a data/opt/. "$DEST/opt/"
echo ">> patching the editable pip install (read-only /app workaround)"
# On first launch O3DE sets up a per-user Python venv in ~/.o3de and pip-installs
# its 'o3de' CLI with 'pip install -e' (editable). Editable mode writes an
# egg-info next to the source under /app, which is read-only in a Flatpak, so it
# fails. Force a normal (non-editable) install instead: pip builds in a temp dir
# and installs into the writable ~/.o3de venv. (Nothing Python-related needs to
# be baked into the image; it all lives per-user under ~/.o3de.)
LYPYTHON=$(find "$DEST/opt/O3DE" -path '*/cmake/LYPython.cmake' | head -n1)
if [ -n "$LYPYTHON" ] && grep -q 'set(_pip_install_mode_args "-e")' "$LYPYTHON"; then
sed -i 's/set(_pip_install_mode_args "-e")/set(_pip_install_mode_args "")/' "$LYPYTHON"
echo " patched: $LYPYTHON"
else
echo " WARNING: editable-install line not found in LYPython.cmake; O3DE layout may have changed" >&2
fi
echo ">> installing launcher + metadata"
install -Dm755 o3de-wrapper.sh "$DEST/bin/o3de-wrapper.sh"
install -Dm644 org.o3de.O3DE.desktop "$DEST/share/applications/$APP_ID.desktop"
install -Dm644 org.o3de.O3DE.metainfo.xml "$DEST/share/metainfo/$APP_ID.metainfo.xml"
install -Dm644 org.o3de.O3DE.png "$DEST/share/icons/hicolor/256x256/apps/$APP_ID.png"
echo ">> build-finish (command + sandbox permissions)"
flatpak build-finish build-dir \
--command=o3de-wrapper.sh \
--share=ipc \
--share=network \
--socket=x11 \
--socket=wayland \
--socket=pulseaudio \
--device=dri \
--device=all \
--filesystem=home \
--talk-name=org.freedesktop.Notifications \
--env=QT_QPA_PLATFORM=xcb
echo ">> export to OSTree repo"
flatpak build-export repo build-dir "$BRANCH"
flatpak build-update-repo repo --title="O3DE (unofficial Flatpak)" --prune --prune-depth=1
echo ">> done: ./repo"