File appimage.yml of Package linphone-desktop

# Yaml script tested with linphone as of March 11, 2024 version 5.2.2
# See https://download.linphone.org/releases/linux/app/
# for latest linphone version.

app: linphone-desktop
binpatch: true

ingredients:
  packages:
    - libxml2-2
    - libz1
    - linphone-desktop

build:
  packages:
    - bash
    - awk
    - libxml2-2
    - libz1
    - shared-mime-info
    - rsync
    - linuxdeployqt
    - linuxdeploy
    - Mesa-gallium
    - libqt5-qtbase-common-devel
    - libQt5Multimedia5
    - libQt5Svg5
    - libQt5X11Extras5
    - libQt5Network5
    - libQt5Xml5
    - libQtQuick5
    - libQt5TextToSpeech5
    - libQt5QuickControls2-5
    - libQt5Gui5
    - libv4l1-0
    - libGLEW2_2
    - libjpeg62
    - libpulse0
    - libvpx7
    - libxcb-xtest0
    - libxcb-image0
    - libxcb-keysyms1
    - libxcb-xfixes0
    - libxcb-shape0
    - libxcb-shm0
    - libxcb-randr0
    - libxcb-util1
    - libxkbcommon-x11-0

script:
  - echo "Linphone wants at runtime libQt5Quick.so.5 with string Qt_5.15.12_PRIVATE_API"
  - echo "AppImage will not open unless it contains this specific version of the library."
  - echo "openSUSE Leap 15.5 has libQt5Quick.so.5 with string Qt_5.15.8_PRIVATE_API"
  - echo "openSUSE Leap 15.6 has libQt5Quick.so.5 with string Qt_5.15.12_PRIVATE_API"
  - echo "libxml2-2 has to be installed before shared-mime-info, otherwise error"
  - echo "--- Yaml script start ---"
  - echo "linuxdeploy complains about these libraries that cannot be found:"
  - find /usr/lib64/ -name libpulsecommon*
  - find /usr/lib64/ -name libQt5Quick*
  - strings /usr/lib64/libQt5Quick.so.5|grep Qt.*API
  - find /usr/lib64 -name libQt5Quick.so*
  - find /usr/lib64 -name libQt5Quick.so* -exec bash -c "echo {} ; strings {} | grep Qt.*API" \;
  - echo "\$BUILD_APPDIR=$BUILD_APPDIR"
  - echo "--- Show contents of $BUILD_APPDIR ---"
  - find $BUILD_APPDIR
  - echo "--- End show contents of $BUILD_APPDIR ---"
  - echo "Find out which libraries that are missing and add them to build packages on row 10:"
  - echo "/opt/linphone/lib/lib*.so* libraries and libraries that are located elsewhere"
  - echo "will likely not be found by ldd if the directories are not specified. Put:"
  - echo "LD_LIBRARY_PATH=$BUILD_APPDIR/opt/linphone/lib:$BUILD_APPDIR/opt/linphone/path/to/libs"
  - echo "in front of the command to help finding libraries"
  - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_APPDIR/opt/linphone/lib64 ldd $BUILD_APPDIR/opt/linphone/bin/linphone
  - unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
  - export appName=linphone
  - export executable=${appName}
  - export desktopFileName=${appName}
  - export iconFileName=${appName}
  - ls -al $BUILD_APPDIR/usr/bin/
  - rm -fv $BUILD_APPDIR/usr/bin/*
  - echo "Structure the files so that ldd can find them, typically in /usr/lib or /usr/lib64. (Maybe not neccessary)"
  - echo "Move all misplaced libraries to $BUILD_APPDIR/usr/lib64/"
  - cp -v /usr/lib64/pulseaudio/libpulsecommon* $BUILD_APPDIR/usr/lib64/.
  - cp -v /usr/lib64/libQt5Quick.so.5* $BUILD_APPDIR/usr/lib64/.
  - echo "Let us try to keep the files in /opt/linphone"
  - echo "If it does not work, we have to move the files to $BUILD_APPDIR/{bin, lib64, share ...}"
  - echo "When two directories have to be merged, maybe we can use rsync"
  - echo something like: rsync -v --stats --progress -a $BUILD_APPDIR/opt/linphone/* $BUILD_APPDIR/usr/
  - echo mv -v $BUILD_APPDIR/opt/linphone/bin/* $BUILD_APPDIR/usr/bin/.
  - echo mv -v $BUILD_APPDIR/opt/linphone/lib64/* $BUILD_APPDIR/usr/lib64/.
  - echo mv -v $BUILD_APPDIR/opt/linphone/share/* $BUILD_APPDIR/usr/share/.
  - echo rsync $BUILD_APPDIR/opt/linphone/share/ $BUILD_APPDIR/usr/share/
  - echo mv -v $BUILD_APPDIR/opt/linphone/cmake/* $BUILD_APPDIR/usr/lib64/cmake/.
  - echo "Create a launcher:"
  - echo cat $BUILD_APPDIR/opt/linphone/linphone-launcher
  - cat $BUILD_APPDIR/opt/linphone/linphone-launcher
  - #mv -v $BUILD_APPDIR/opt/linphone/linphone-launcher $BUILD_APPDIR/usr/bin/.
  - #sed -i 's/\./..\/../g' $BUILD_APPDIR/usr/bin/linphone-launcher
  - #echo "#!/bin/bash" > $BUILD_APPDIR/usr/bin/linphone-launcher
  - #echo "SCRIPT_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" >> $BUILD_APPDIR/usr/bin/linphone-launcher
  - #echo "echo \"Script directory: \$SCRIPT_DIR\"" >> $BUILD_APPDIR/usr/bin/linphone-launcher
  - #echo "LD_LIBRARY_PATH=\"\$SCRIPT_DIR/../opt/linphone/lib64\" \"\$SCRIPT_DIR/../../opt/linphone/bin/linphone\" \"$@\"" >> $BUILD_APPDIR/usr/bin/linphone-launcher
  - #chmod 755 $BUILD_APPDIR/usr/bin/linphone-launcher
  - echo '#!/bin/bash' > "$BUILD_APPDIR/usr/bin/linphone-launcher"
  - echo 'SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"' >> "$BUILD_APPDIR/usr/bin/linphone-launcher"
  - #echo 'echo "Script directory: $SCRIPT_DIR"' >> "$BUILD_APPDIR/usr/bin/linphone-launcher"
  - echo 'LD_LIBRARY_PATH="$SCRIPT_DIR/../../opt/linphone/lib64:$LD_LIBRARY_PATH" "$SCRIPT_DIR/../../opt/linphone/bin/linphone" "$@"' >> "$BUILD_APPDIR/usr/bin/linphone-launcher"
  - chmod +x "$BUILD_APPDIR/usr/bin/linphone-launcher"
  - echo cat $BUILD_APPDIR/usr/bin/linphone-launcher
  - cat $BUILD_APPDIR/usr/bin/linphone-launcher
  - ls -al $BUILD_APPDIR
  - echo "${desktopFileName}.desktop should be placed in $BUILD_APPDIR"
  - echo "This is the existing *.desktop file:"
  - echo ls -al $BUILD_APPDIR/usr/share/applications/*.desktop
  - ls -al $BUILD_APPDIR/usr/share/applications/*.desktop
  - echo "Show current .desktop file content:"
  - echo "cat $BUILD_APPDIR/usr/share/applications/*.desktop"
  - cat $BUILD_APPDIR/usr/share/applications/*.desktop
  - echo "Cleanup the desktop file in the package if needed:"
  - echo sed -i -e 's|/usr/bin/app %U|AppLauncher %U|g' $BUILD_APPDIR/usr/share/applications/app.desktop
  - echo sed -i -e 's|^MimeType=.*$|MimeType=x-scheme-handler/appmtg;x-scheme-handler/appus;x-scheme-handler/tel;|g' $BUILD_APPDIR/usr/share/applications/app.desktop
  - echo cp -v $BUILD_APPDIR/usr/bin/version.txt $BUILD_APPDIR/usr/VERSION
  - echo mkdir -pv $BUILD_APPDIR/usr/share/icons/hicolor/256x256/apps/
  - echo cp -v $BUILD_APPDIR/usr/share/pixmaps/app.png $BUILD_APPDIR/usr/share/icons/hicolor/256x256/apps/
  - echo cp -v $BUILD_APPDIR/usr/share/pixmaps/app.png $BUILD_APPDIR/.
  - cp -v $BUILD_SOURCE_DIR/icon $BUILD_APPDIR/${iconFileName}.svg
  - mkdir -pv $BUILD_APPDIR/usr/share/applications/
  - mkdir -pv $BUILD_APPDIR/usr/share/icons/hicolor/scalable/apps/
  - echo ls -al $BUILD_APPDIR/usr/share/icons/hicolor/scalable/apps
  - ls -al $BUILD_APPDIR/usr/share/icons/hicolor/scalable/apps
  - echo "Remove (vector) app icon(s):"
  - echo "rm -fv $BUILD_APPDIR/usr/share/icons/hicolor/scalable/apps/*"
  - rm -fv $BUILD_APPDIR/usr/share/icons/hicolor/scalable/apps/*
  - echo ls -al $BUILD_APPDIR/usr/share/applications/
  - ls -al $BUILD_APPDIR/usr/share/applications/
  - echo "Remove current .desktop file:"
  - echo "rm -fv $BUILD_APPDIR/usr/share/applications/*.desktop"
  - rm -fv $BUILD_APPDIR/usr/share/applications/*.desktop
  - echo "Use the uploaded desktop file:"
  - cp -v $BUILD_SOURCE_DIR/desktop $BUILD_APPDIR/${desktopFileName}.desktop
  - echo "Sometimes it works better with linuxdeployqt:"
  - echo linuxdeployqt $BUILD_APPDIR/${desktopFileName}.desktop -executable=/usr/bin/${executable} -no-copy-copyright-files -qmake=/usr/bin/qmake-qt5 -qmldir=/usr/lib64/qt5/qml -no-copy-copyright-files -exclude-libs=ffmpeg.so
  - echo "Sometimes it works better with linuxdeploy:"
  - echo LD_LIBRARY_PATH=$BUILD_APPDIR$LD_LIBRARY_PATH:$BUILD_APPDIR/usr/lib64 linuxdeploy --verbosity=1 --appdir=$BUILD_APPDIR --desktop-file=$BUILD_APPDIR/${desktopFileName}.desktop --icon-file=$BUILD_APPDIR/${iconFileName}.svg
  - find $BUILD_APPDIR
  - echo ldd $BUILD_APPDIR/usr/bin/app
  - echo ldd $BUILD_APPDIR/opt/linphone/bin/linphone
  - echo "--- linuxdeploy starts here ---"
  - linuxdeploy --verbosity=1 --appdir=$BUILD_APPDIR --desktop-file=$BUILD_APPDIR/${desktopFileName}.desktop --icon-file=$BUILD_APPDIR/${iconFileName}.svg
  - echo "--- linuxdeploy should have finnished here ---"
  - echo "--- Files that will be packaged in AppImage ---"
  - find $BUILD_APPDIR | sed "s|$BUILD_APPDIR||g"
  - echo "--- Files that will be packaged in AppImage ---"
  - find $BUILD_APPDIR -name libQt5Quick.so.5
  - echo find /usr/lib64 -name libQt5Quick.so* -exec bash -c "strings {} | grep Qt.*API" \;
  - find /usr/lib64 -name libQt5Quick.so* -exec bash -c "strings {} | grep Qt.*API" \;
  - echo find $BUILD_APPDIR -name libQt5Quick.so* -exec bash -c "strings {} | grep Qt.*API" \;
  - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BUILD_APPDIR/usr/lib64:/usr/lib64/pulseaudio:$BUILD_APPDIR/usr/lib64/pulseaudio:/usr/lib64 find $BUILD_APPDIR -name libQt5Quick.so* -exec bash -c "strings {} | grep Qt.*API" \;
  - echo "You should soon see an *.AppImage file being saved."
  - echo "--- End of Yaml script ---"
openSUSE Build Service is sponsored by