build/linux: Add org.flatpak.Builder support for Flatpak .sh scripts

This commit is contained in:
Bruno Lopes 2025-04-25 20:27:43 -03:00
parent d59bb64ffa
commit c2771753db
No known key found for this signature in database
2 changed files with 21 additions and 16 deletions

View file

@ -14,16 +14,22 @@ fi
# Install part of the deps
if [ ! -f '/usr/bin/flatpak-builder' ]; then
if [ $(which flatpak-builder 2>/dev/null) ]; then
export FLATPAK_BUILDER='flatpak-builder'
elif [ -f '/var/lib/flatpak/exports/bin/org.flatpak.Builder' ]; then
export FLATPAK_BUILDER='flatpak run --system org.flatpak.Builder'
elif [ -f "${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/exports/bin/org.flatpak.Builder" ]; then
export FLATPAK_BUILDER='flatpak run --user org.flatpak.Builder'
else
echo -e '\033[31m(ERROR)\033[0m: flatpak-builder not found. Please, install it using your package manager.'
exit 1
fi
builder_version=$(flatpak-builder --version | sed 's/flatpak-builder//' | sed 's/-//' | sed 's/ //' | sed 's/\.//g')
builder_version=$(eval $FLATPAK_BUILDER --version | sed 's/flatpak-builder//' | sed 's/-//' | sed 's/ //' | sed 's/\.//g')
if [ "$builder_version" -lt '143' ]; then
## Pre-1.4.3 flatpak-builder fails at Cmake deps, let's prevent this
echo -e "\033[31m(ERROR)\033[0m: Installed flatpak-builder is too old. Our .json manifest requires at least 1.4.3."
exit 1
fi
fi #End of check
if [ -z "$GITLAB_CI" ]; then
flatpak update -y
@ -40,19 +46,19 @@ fi
# Build some deps (including babl and GEGL)
if [ -z "$GITLAB_CI" ] && [ "$1" != '--ci' ]; then
flatpak-builder --force-clean --ccache --state-dir=../.flatpak-builder --keep-build-dirs --stop-at=gimp \
eval $FLATPAK_BUILDER --force-clean --ccache --state-dir=../.flatpak-builder --keep-build-dirs --stop-at=gimp \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json 2>&1 | tee flatpak-builder.log
elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then
## (The deps building is too long and no complete output would be collected,
## even from GitLab runner messages. So, let's silent and save logs as a file.)
echo -e "\e[0Ksection_start:`date +%s`:deps_build[collapsed=true]\r\e[0KBuilding dependencies not present in GNOME runtime"
flatpak-builder --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=babl \
eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=babl \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json &> flatpak-builder.log
echo -e "\e[0Ksection_end:`date +%s`:deps_build\r\e[0K"
echo -e "\e[0Ksection_start:`date +%s`:babl_build[collapsed=true]\r\e[0KBuilding babl"
flatpak-builder --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gegl \
eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gegl \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then
tar cf babl-meson-log.tar .flatpak-builder/build/babl-1/_flatpak_build/meson-logs/meson-log.txt
@ -60,7 +66,7 @@ elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then
echo -e "\e[0Ksection_end:`date +%s`:babl_build\r\e[0K"
echo -e "\e[0Ksection_start:`date +%s`:gegl_build[collapsed=true]\r\e[0KBuilding gegl"
flatpak-builder --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gimp \
eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gimp \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then
tar cf gegl-meson-log.tar .flatpak-builder/build/gegl-1/_flatpak_build/meson-logs/meson-log.txt

View file

@ -15,16 +15,15 @@ if [ -z "$GITLAB_CI" ]; then
fi
# Install part of the deps
source <(cat build/linux/flatpak/1_build-deps-flatpak.sh | sed -n "/Install part/,/End of check/p")
if [ "$GITLAB_CI" ]; then
# Extract deps from previous job
tar xf .flatpak-builder.tar
fi
# GNOME script to customize gimp module in the manifest (not needed)
#rewrite-flatpak-manifest build/linux/flatpak/org.gimp.GIMP-nightly.json gimp ${CONFIG_OPTS}
# Prepare env (only GIMP_PREFIX is needed for flatpak)
if [ -z "$GIMP_PREFIX" ]; then
export GIMP_PREFIX="$PWD/../_install"
@ -34,18 +33,18 @@ fi
# Build GIMP only
if [ -z "$GITLAB_CI" ] && [ "$1" != '--ci' ]; then
if [ ! -f "_build/build.ninja" ]; then
flatpak-builder --run --ccache "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json meson setup _build -Dprefix=/app/ -Dlibdir=/app/lib/
eval $FLATPAK_BUILDER --run --ccache "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json meson setup _build -Dprefix=/app/ -Dlibdir=/app/lib/
if [ ! -f '_build/.gitignore' ]; then
echo '*' > _build/.gitignore
fi
fi
cd _build
flatpak-builder --run --ccache "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja
flatpak-builder --run "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja install
eval $FLATPAK_BUILDER --run --ccache "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja
eval $FLATPAK_BUILDER --run "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja install
elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then
echo -e "\e[0Ksection_start:`date +%s`:gimp_build[collapsed=true]\r\e[0KBuilding GIMP"
flatpak-builder --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --disable-download \
eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --disable-download \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json &> gimp-flatpak-builder.log || cat gimp-flatpak-builder.log
if [ "$GITLAB_CI" ]; then
tar cf gimp-meson-log.tar .flatpak-builder/build/gimp-1/_flatpak_build/meson-logs/meson-log.txt
@ -55,7 +54,7 @@ elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then
## Cleanup GIMP_PREFIX (not working) and export it to OSTree repo
## https://github.com/flatpak/flatpak-builder/issues/14
echo -e "\e[0Ksection_start:`date +%s`:gimp_bundle[collapsed=true]\r\e[0KCreating OSTree repo"
flatpak-builder --user --disable-rofiles-fuse --finish-only --repo=repo \
eval $FLATPAK_BUILDER --user --disable-rofiles-fuse --finish-only --repo=repo \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then
tar cf repo.tar repo/