build/linux: Set LD interpreter but unset LD_LIBRARY_PATH on AppImage

This avoids calling host libs, fixing the last pendency on !1440 desc.
In other words, the AppImage now can be run, in thesis, in any distro.

Thanks for helping me with this, @samueru
This commit is contained in:
Bruno 2024-10-15 10:10:04 -03:00
parent 10dc081c05
commit 8fe7ddf36c
No known key found for this signature in database
2 changed files with 17 additions and 13 deletions

View file

@ -55,13 +55,14 @@ fi
patch_app_id '-R' patch_app_id '-R'
# INSTALL GO-APPIMAGETOOL # INSTALL GO-APPIMAGETOOL AND COMPLEMENTARY TOOLS
echo '(INFO): downloading go-appimagetool' echo '(INFO): downloading go-appimagetool'
if [ -f "*appimagetool*.AppImage" ]; then if [ -f "*appimagetool*.AppImage" ]; then
rm *appimagetool*.AppImage rm *appimagetool*.AppImage
fi fi
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
apt-get install -y --no-install-recommends wget >/dev/null 2>&1 apt-get install -y --no-install-recommends wget >/dev/null 2>&1
apt-get install -y --no-install-recommends patchelf >/dev/null 2>&1
fi fi
arch=$(uname -m) arch=$(uname -m)
@ -161,6 +162,7 @@ conf_app ()
esac esac
var_path=$(echo $prefix/$2 | sed "s|${prefix}/||g") var_path=$(echo $prefix/$2 | sed "s|${prefix}/||g")
sed -i "s|${1}_WILD|usr/${var_path}|" build/linux/appimage/AppRun sed -i "s|${1}_WILD|usr/${var_path}|" build/linux/appimage/AppRun
eval $1="usr/$var_path"
} }
wipe_usr () wipe_usr ()
@ -281,10 +283,18 @@ bund_usr "$GIMP_PREFIX" "bin/gegl"
bund_usr "$GIMP_PREFIX" "share/applications/org.gimp.GIMP.desktop" bund_usr "$GIMP_PREFIX" "share/applications/org.gimp.GIMP.desktop"
"./$go_appimagetool" --appimage-extract-and-run -s deploy $USR_DIR/share/applications/org.gimp.GIMP.desktop &> appimagetool.log "./$go_appimagetool" --appimage-extract-and-run -s deploy $USR_DIR/share/applications/org.gimp.GIMP.desktop &> appimagetool.log
## Manual adjustments (go-appimagetool don't handle these things gracefully) ## Manual adjustments (go-appimagetool don't handle Linux FHS gracefully)
### Undo the mess that go-appimagetool makes on the prefix which breaks babl and gegl) ### Ensure that LD is in right dir
cp -r $APP_DIR/lib64 $USR_DIR cp -r $APP_DIR/lib64 $USR_DIR
rm -r $APP_DIR/lib64 rm -r $APP_DIR/lib64
chmod +x "$APP_DIR/$LD_LINUX"
exec_array=($(find "$USR_DIR/bin" "$USR_DIR/$LIB_DIR" ! -iname "*.so*" -type f -exec head -c 4 {} \; -exec echo " {}" \; | grep ^.ELF))
for exec in "${exec_array[@]}"; do
if [[ ! "$exec" =~ 'ELF' ]]; then
patchelf --set-interpreter "./$LD_LINUX" "$exec" >/dev/null 2>&1 || continue
fi
done
### Undo the mess that go-appimagetool makes on the prefix which breaks babl and GEGL
cp -r $APP_DIR/lib/* $USR_DIR/${LIB_DIR} cp -r $APP_DIR/lib/* $USR_DIR/${LIB_DIR}
rm -r $APP_DIR/lib rm -r $APP_DIR/lib
### Remove unnecessary files bunbled by go-appimagetool ### Remove unnecessary files bunbled by go-appimagetool
@ -301,7 +311,6 @@ rm -r $APP_DIR/etc
echo '(INFO): configuring AppRun' echo '(INFO): configuring AppRun'
GIMP_APP_VERSION=$(grep GIMP_APP_VERSION _build/config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/') GIMP_APP_VERSION=$(grep GIMP_APP_VERSION _build/config.h | head -1 | sed 's/^.*"\([^"]*\)"$/\1/')
sed -i "s|GIMP_APP_VERSION|${GIMP_APP_VERSION}|" build/linux/appimage/AppRun sed -i "s|GIMP_APP_VERSION|${GIMP_APP_VERSION}|" build/linux/appimage/AppRun
sed -i "s|DEBIAN_VERSION|$(cat /etc/debian_version)|" build/linux/appimage/AppRun
mv build/linux/appimage/AppRun $APP_DIR mv build/linux/appimage/AppRun $APP_DIR
chmod +x $APP_DIR/AppRun chmod +x $APP_DIR/AppRun
mv build/linux/appimage/AppRun.bak build/linux/appimage/AppRun mv build/linux/appimage/AppRun.bak build/linux/appimage/AppRun

View file

@ -14,9 +14,8 @@ HERE="$(dirname "$(readlink -f "${0}")")"
## Minimum runtime paths ## Minimum runtime paths
export PATH="$HERE"/usr/bin/:"$PATH" export PATH="$HERE"/usr/bin/:"$PATH"
export LD_LIBRARY_PATH="$HERE"/usr/lib/:"$HERE"/usr/lib/x86_64-linux-gnu/:"$HERE"/usr/lib64/:"$LD_LIBRARY_PATH"
export XDG_DATA_DIRS="$HERE"/usr/share/:"$XDG_DATA_DIRS" export XDG_DATA_DIRS="$HERE"/usr/share/:"$XDG_DATA_DIRS"
LD_LINUX="$HERE/LD_LINUX_WILD --inhibit-cache" LD_LINUX="$HERE/LD_LINUX_WILD"
## GTK-related paths ## GTK-related paths
export GIO_MODULE_DIR="$HERE"/GIO_MODULE_DIR_WILD/modules export GIO_MODULE_DIR="$HERE"/GIO_MODULE_DIR_WILD/modules
@ -42,10 +41,6 @@ export PYTHONDONTWRITEBYTECODE=1
# RUN MAIN_BIN # RUN MAIN_BIN
echo "This is a CI build of GIMP compatible with Debian DEBIAN_VERSION. See: https://gitlab.gnome.org/GNOME/gimp/-/issues/7661" # FIXME: We need to run on squash-fs dir since LD is hardlinked into executables
echo '.js (JavaScript) plug-ins | supported.' cd "$HERE"
echo '.py (Python) plug-ins | supported.' exec "${LD_LINUX}" --inhibit-cache "$HERE"/usr/bin/gimp-GIMP_APP_VERSION "$@"
echo '.scm (ScriptFu) plug-ins | supported.'
echo '.vala (Vala) plug-ins | supported.'
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libc.so.6 "$HERE"/usr/bin/gimp-GIMP_APP_VERSION "$@"