From 0ed7678901ebeb771e9ae6156f0fadb190f71fe5 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Mon, 25 Apr 2022 14:10:32 +0100 Subject: [PATCH] Update build AppImage script backport changes from next, including fixes for FreeType deployment SF-ID: https://sourceforge.net/p/flightgear/codetickets/2732/ --- build_appimage.sh | 81 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 12 deletions(-) diff --git a/build_appimage.sh b/build_appimage.sh index 62c9d34..4076179 100755 --- a/build_appimage.sh +++ b/build_appimage.sh @@ -39,11 +39,7 @@ mkdir -p appdir/usr/ssl #copy everything we need in cp dist/bin/* appdir/usr/bin - -cp -a dist/lib64/* appdir/usr/lib - -# remove SimGearCore,Scene and any other static libs which leaked -rm appdir/usr/lib/lib*.a +cp -d dist/lib64/* appdir/usr/lib cp -a dist/lib64/osgPlugins-3.4.2 appdir/usr/lib @@ -64,25 +60,80 @@ cp /etc/pki/tls/certs/ca-bundle.crt appdir/usr/ssl/cacert.pem # https://sourceforge.net/p/flightgear/codetickets/2590/ cp -a /lib64/libharfbuzz.so* appdir/usr/lib +# as we are copying over libharfbuzz we need the older libfontconfig, +# libfreetype & libpng15 as 2.11 breaks compatibility: see +# https://sourceforge.net/p/flightgear/codetickets/2651/ +cp -a /usr/lib64/libfontconfig.so* appdir/usr/lib +cp -a /usr/lib64/libfreetype.so* appdir/usr/lib +cp -a /usr/lib64/libpng15.so* appdir/usr/lib +patchelf --set-rpath \$ORIGIN appdir/usr/lib/libfontconfig.so* +patchelf --set-rpath \$ORIGIN appdir/usr/lib/libfreetype.so* +patchelf --set-rpath \$ORIGIN appdir/usr/lib/libharfbuzz.so* + #modify the desktop file so that linuxdeployqt doesn't barf (version to 1.0, add semicolon to end of certain line types) sed -i 's/^Categor.*/&;/ ; s/^Keyword.*/&;/ ; s/1\.1/1\.0/' appdir/usr/share/applications/org.flightgear.FlightGear.desktop #generate AppRun script -# Note: don't set LD_LIBRARY_PATH here. -# if you do, you need to add code to unset it *sinde* FlightGear (eg, bootstrap.cxx), -# so that fork-ed processes don't inherit the value. For an example see: -# https://github.com/KDAB/hotspot/blob/master/src/main.cpp#L87 - cat << 'EOF' > appdir/AppRun #!/bin/bash HERE="$(dirname "$(readlink -f "${0}")")" +BIN_DIR="${HERE}/usr/bin" +EXEC_OPT="--exec-app" + export SIMGEAR_TLS_CERT_PATH=$HERE/usr/ssl/cacert.pem export OSG_LIBRARY_PATH=${HERE}/usr/lib -if [[ $# -eq 0 ]]; then +# Run launcher directly if no parameters are passed +if [[ "$#" -eq "0" ]]; then echo "Started with no arguments; assuming --launcher" exec "${HERE}/usr/bin/fgfs" --launcher + exit "$?" +fi + +# Check for special argument "--exec-app=" and execute selected application +if [[ "$1" == ${EXEC_OPT}=* ]] || [[ "$1" == "${EXEC_OPT}" ]]; then + OPT_VAL="${1#*=}" + APP_PATH="${BIN_DIR}/${OPT_VAL}" + + # Call without arguments + if [[ "$1" == "${EXEC_OPT}" ]] || [[ -z "${OPT_VAL}" ]]; then + ERROR="1" + # Make sure executable name does not contain any "/" + elif [[ "${OPT_VAL}" == */* ]]; then + echo "Error: path separator \"/\" was used in application name!" + ERROR="1" + # Check if resulting file exists and is executable + elif [[ -z "$(find "${APP_PATH}" -type f \( \( -perm -00005 -a ! -user "$(id -u)" -a ! -group "$(id -g)" \) -o \( -perm -00500 -a -user "$(id -u)" \) -o \( -perm -00050 -a -group "$(id -g)" \) \) 2>/dev/null)" ]]; then + echo "Error: \"${OPT_VAL}\" is not a valid application name or cannot be executed by current user!" + ERROR="1" + fi + + # In case of error or no arguments show help + if [[ ! -z "${ERROR}" ]]; then + + # Determine AppImage's filename + IMAGE_FILE_NAME="$(basename "${APPIMAGE}" 2>/dev/null)" + if [[ -z "${IMAGE_FILE_NAME}" ]]; then + IMAGE_FILE_NAME="FlightGear.AppImage" + fi + + # Print help + echo "Usage: ./${IMAGE_FILE_NAME} ${EXEC_OPT}=" + echo "Pass ${EXEC_OPT} as first positional argument." + echo "Additional arguments are passed to the called application." + echo "Valid values for are:" + while IFS= read -r -d $'\0' bin_exe; do + echo " $(basename "${bin_exe}")" + done < <( find "${BIN_DIR}/" -maxdepth 1 -type f \( \( -perm -00005 -a ! -user "$(id -u)" -a ! -group "$(id -g)" \) -o \( -perm -00500 -a -user "$(id -u)" \) -o \( -perm -00050 -a -group "$(id -g)" \) \) -exec printf "%s\0" "{}" \; ) + # We have to use these odd find conditions since "find -executable" also lists non-executables when AppImage is executed. The reason is most likely the way it is mounted. + exit 1 + fi + + # Execute selected application and pass remaining parameters + # "pop" the first argument + shift + exec "${APP_PATH}" "$@" else exec "${HERE}/usr/bin/fgfs" "$@" fi @@ -99,5 +150,11 @@ chmod +x linuxdeployqt-7-x86_64.AppImage #set VERSION for AppImage creation export VERSION=`cat flightgear/flightgear-version` -./linuxdeployqt-7-x86_64.AppImage appdir/usr/share/applications/org.flightgear.FlightGear.desktop -appimage -qmldir=flightgear/src/GUI/qml/ +# Add all executable binaries as additional binaries to AppImage and use special quoted array expansion +ADDITIONAL_EXES=() +while IFS= read -r -d $'\0' bin_exe; do + ADDITIONAL_EXES+=("-executable=${bin_exe}") +done < <( find "appdir/usr/bin/" -maxdepth 1 -type f \( \( -perm -00500 -o -perm -00050 -o -perm -00005 \) -a ! -name "fgfs" \) -exec printf "%s\0" "{}" \; ) +# This find statement filters for all files with at least one executability bit set +./linuxdeployqt-7-x86_64.AppImage appdir/usr/share/applications/org.flightgear.FlightGear.desktop -appimage -qmldir=flightgear/src/GUI/qml/ "${ADDITIONAL_EXES[@]}"