Files
o3de-flatpak/scripts/make-flatpak.sh
T
pc-heini 583c81ed51 Fix editable-install patch for 26.05 + unblock icon in unprivileged build
The previous patch matched a development-branch variable that does not
exist in release 2605.0, so the warning fired and the editable install was
not patched. In 2605.0 the -e is hardcoded in the pip command
("pip install -e ${package_folder_path}"); strip the -e there instead.

Also, flatpak build-export validates exported app icons in a bwrap sandbox,
which fails in an unprivileged container. Keep the icon inside the app (for
the running window/taskbar) but remove it from build-dir/export so export
skips validation. Host menu icon stays generic; build needs no privileges.

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

78 lines
3.1 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 -qF -- '-m pip install -e ' "$LYPYTHON"; then
sed -i 's/-m pip install -e /-m pip install /g' "$LYPYTHON"
echo " patched: $LYPYTHON"
else
echo " WARNING: 'pip install -e' 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 validates exported app icons in a bwrap sandbox, which
# fails in an unprivileged container ("is not a valid icon: bwrap ..."). The
# icon stays inside the app (so the running window/taskbar shows it); we just
# drop it from the *exported* set so export skips validation. Trade-off: the
# host menu launcher icon is generic. (A privileged runner would avoid this.)
rm -rf build-dir/export/share/icons
flatpak build-export repo build-dir "$BRANCH"
flatpak build-update-repo repo --title="O3DE (unofficial Flatpak)" --prune --prune-depth=1
echo ">> done: ./repo"