build/linux: Reduce bashisms on AppImage script

This commit is contained in:
Bruno Lopes 2024-06-01 09:07:09 -03:00 committed by Bruno
parent 796005216d
commit a91599c454
1 changed files with 12 additions and 15 deletions

View File

@ -10,7 +10,7 @@ set -e
# AGNOSTIC VARIABLES (only touch them to make even more portable, without casuistry)
## This script is arch-agnostic. The packager can specify it when calling the script
if [[ -z "$1" ]]; then
if [ -z "$1" ]; then
export ARCH=$(uname -m)
else
export ARCH=$1
@ -22,16 +22,15 @@ BUILD_ARTIF=$(echo _build*)
## putting everything in /usr or in AppDir(root) just specifying the 2nd parameter.
GIMP_DISTRIB="$CI_PROJECT_DIR/build/linux/appimage/AppDir"
GIMP_PREFIX="$GIMP_DISTRIB/usr"
if [[ -z "$2" ]] || [[ "$2" == "usr" ]]; then
if [ -z "$2" ] || [ "$2" = "usr" ]; then
OPT_PREFIX="${GIMP_PREFIX}"
elif [[ "$2" == "AppDir" ]]; then
elif [ "$2" = "AppDir" ]; then
OPT_PREFIX="${GIMP_DISTRIB}"
fi
## This script is distro-agnostic too. We take universal variables from .gitlab-ci.yml
OLD_IFS=$IFS
IFS=$'\n' VAR_ARRAY=($(cat .gitlab-ci.yml | sed -n '/export PATH=/,/GI_TYPELIB_PATH}\"/p' | sed 's/ - //'))
IFS=$OLD_IFS
IFS=$' \t\n'
for VAR in "${VAR_ARRAY[@]}"; do
eval "$VAR" || continue
done
@ -59,16 +58,14 @@ find_lib ()
find_dat ()
{
DAT_PATH=$(echo $1)
DAT_PATH=$(sed "s|/usr/||g" <<< $DAT_PATH)
DAT_PATH=$(echo $1 | sed 's|/usr/||g')
mkdir -p $OPT_PREFIX/$DAT_PATH
cp -r $1/$2 $OPT_PREFIX/$DAT_PATH/$3
}
conf_app ()
{
VAR_PATH=$(echo $2/$3)
VAR_PATH=$(sed "s|${2}/||g" <<< $VAR_PATH)
VAR_PATH=$(echo $2/$3 | sed "s|${2}/||g")
sed -i "s|${1}_WILD|OPT_PREFIX_WILD${VAR_PATH}|" build/linux/appimage/AppRun
}
@ -149,14 +146,14 @@ conf_app PYTHONPATH "/usr" "${LIB_DIR}/${LIB_SUBDIR}python3.11"
### Auto detect and copy deps of binaries copied above
"./$go_appimagetool" --appimage-extract-and-run -s deploy $OPT_PREFIX/share/applications/org.gimp.GIMP.desktop
### Rearranje babl, GEGL and GIMP (only the needed files)
if [[ -z "$2" ]] || [[ "$2" == "usr" ]]; then
if [ -z "$2" ] || [ "$2" = "usr" ]; then
cp -r $GIMP_DISTRIB/etc $GIMP_PREFIX
rm -r $GIMP_DISTRIB/etc
cp -r $GIMP_DISTRIB/lib $GIMP_PREFIX
rm -r $GIMP_DISTRIB/lib
cp -r $GIMP_DISTRIB/lib64 $GIMP_PREFIX
rm -r $GIMP_DISTRIB/lib64
elif [[ "$2" == "AppDir" ]]; then
elif [ "$2" = "AppDir" ]; then
cp -r $GIMP_PREFIX/* $GIMP_DISTRIB
rm -r $GIMP_PREFIX
fi
@ -177,9 +174,9 @@ sed -i "s|\"/usr/|\"|g" "$OPT_PREFIX/${LIB_DIR}/${LIB_SUBDIR}gtk-3.0/3.0.0/immod
# CONFIGURE APPRUN
cp build/linux/appimage/AppRun $GIMP_DISTRIB
if [[ -z "$2" ]] || [[ "$2" == "usr" ]]; then
if [ -z "$2" ] || [ "$2" = "usr" ]; then
sed -i "s|OPT_PREFIX_WILD|usr/|g" $GIMP_DISTRIB/AppRun
elif [[ "$2" == "AppDir" ]]; then
elif [ "$2" = "AppDir" ]; then
sed -i "s|OPT_PREFIX_WILD||g" $GIMP_DISTRIB/AppRun
fi
@ -189,7 +186,7 @@ sed -i "s|GIMP_APP_VERSION|${GIMP_APP_VERSION}|" $GIMP_DISTRIB/AppRun
# CONFIGURE METADATA
sed -i '/kudo/d' $OPT_PREFIX/share/metainfo/org.gimp.GIMP.appdata.xml
if [[ "$2" == "AppDir" ]]; then
if [ "$2" = "AppDir" ]; then
mkdir -p $GIMP_PREFIX/share
cp -r $GIMP_DISTRIB/share/metainfo $GIMP_PREFIX/share
cp -r $GIMP_DISTRIB/share/applications $GIMP_PREFIX/share
@ -198,7 +195,7 @@ fi
# CONFIGURE ICON
cp $OPT_PREFIX/share/icons/hicolor/scalable/apps/org.gimp.GIMP.svg $GIMP_DISTRIB/org.gimp.GIMP.svg
if [[ "$2" == "AppDir" ]]; then
if [ "$2" = "AppDir" ]; then
cp -r $GIMP_DISTRIB/share/icons/ $GIMP_PREFIX/share
fi