From bb7e08cdce1de6265978304d9ecf7d5136641101 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 29 Oct 2023 21:26:01 +1000 Subject: [PATCH] CI/AppImage: Add I_WANT_A_BROKEN_WAYLAND_UI environment variable --- .../workflows/scripts/linux/appimage-qt.sh | 53 ++++++++++++++++++- .../linux/apprun-hooks/default-to-x11.sh | 9 ++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/scripts/linux/apprun-hooks/default-to-x11.sh diff --git a/.github/workflows/scripts/linux/appimage-qt.sh b/.github/workflows/scripts/linux/appimage-qt.sh index d3db1f075b9ba..76dc35f235963 100755 --- a/.github/workflows/scripts/linux/appimage-qt.sh +++ b/.github/workflows/scripts/linux/appimage-qt.sh @@ -42,6 +42,16 @@ BINARY=pcsx2-qt APPDIRNAME=PCSX2.AppDir STRIP=strip +declare -a MANUAL_QT_LIBS=( + "libQt6WaylandEglClientHwIntegration.so.6" +) + +declare -a MANUAL_QT_PLUGINS=( + "wayland-decoration-client" + "wayland-graphics-integration-client" + "wayland-shell-integration" +) + set -e LINUXDEPLOY=./linuxdeploy-x86_64.AppImage @@ -65,7 +75,6 @@ if [ ! -f "$APPIMAGETOOL" ]; then fi OUTDIR=$(realpath "./$APPDIRNAME") -SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") rm -fr "$OUTDIR" # Why the nastyness? linuxdeploy strips our main binary, and there's no option to turn it off. @@ -89,7 +98,8 @@ cp "$PCSX2DIR/.github/workflows/scripts/linux/pcsx2-qt.desktop" "net.pcsx2.PCSX2 cp "$PCSX2DIR/bin/resources/icons/AppIconLarge.png" "PCSX2.png" echo "Running linuxdeploy to create AppDir..." -EXTRA_QT_PLUGINS="core;gui;network;svg;widgets;xcbqpa" \ +EXTRA_QT_PLUGINS="core;gui;network;svg;waylandclient;widgets;xcbqpa" \ +EXTRA_PLATFORM_PLUGINS="libqwayland-egl.so;libqwayland-generic.so" \ QMAKE="$DEPSDIR/bin/qmake" \ NO_STRIP="1" \ $LINUXDEPLOY --plugin qt --appdir="$OUTDIR" --executable="$BUILDDIR/bin/pcsx2-qt" \ @@ -98,6 +108,34 @@ $LINUXDEPLOY --plugin qt --appdir="$OUTDIR" --executable="$BUILDDIR/bin/pcsx2-qt echo "Copying resources into AppDir..." cp -a "$BUILDDIR/bin/resources" "$OUTDIR/usr/bin" +# LinuxDeploy's Qt plugin doesn't include Wayland support. So manually copy in the additional Wayland libraries. +echo "Copying Qt Wayland libraries..." +for lib in "${MANUAL_QT_LIBS[@]}"; do + srcpath="$DEPSDIR/lib/$lib" + dstpath="$OUTDIR/usr/lib/$lib" + echo " $srcpath -> $dstpath" + cp "$srcpath" "$dstpath" + $PATCHELF --set-rpath '$ORIGIN' "$dstpath" +done + +# .. and plugins. +echo "Copying Qt Wayland plugins..." +for GROUP in "${MANUAL_QT_PLUGINS[@]}"; do + srcpath="$DEPSDIR/plugins/$GROUP" + dstpath="$OUTDIR/usr/plugins/$GROUP" + echo " $srcpath -> $dstpath" + mkdir -p "$dstpath" + + for srcsopath in $(find "$DEPSDIR/plugins/$GROUP" -iname '*.so'); do + # This is ../../ because it's usually plugins/group/name.so + soname=$(basename "$srcsopath") + dstsopath="$dstpath/$soname" + echo " $srcsopath -> $dstsopath" + cp "$srcsopath" "$dstsopath" + $PATCHELF --set-rpath '$ORIGIN/../../lib:$ORIGIN' "$dstsopath" + done +done + # Restore unstripped deps (for cache). rm -fr "$DEPSDIR" mv "$DEPSDIR.bak" "$DEPSDIR" @@ -111,6 +149,17 @@ echo "Generating AppStream metainfo..." mkdir -p "$OUTDIR/usr/share/metainfo" "$SCRIPTDIR/generate-metainfo.sh" "$OUTDIR/usr/share/metainfo/net.pcsx2.PCSX2.appdata.xml" +# Copy in AppRun hooks. +# Unfortunately linuxdeploy is a bit lame and doesn't let us provide our own AppRun hooks, instead +# they have to come from plugins.. and screw writing one of those just to disable Wayland. +echo "Copying AppRun hooks..." +mkdir -p "$OUTDIR/apprun-hooks" +for hookpath in "$SCRIPTDIR/apprun-hooks"/*; do + hookname=$(basename "$hookpath") + cp -v "$hookpath" "$OUTDIR/apprun-hooks/$hookname" + sed -i -e 's/exec /source "$this_dir"\/apprun-hooks\/"'"$hookname"'"\nexec /' "$OUTDIR/AppRun" +done + echo "Generating AppImage..." rm -f "$NAME.AppImage" $APPIMAGETOOL -v "$OUTDIR" "$NAME.AppImage" diff --git a/.github/workflows/scripts/linux/apprun-hooks/default-to-x11.sh b/.github/workflows/scripts/linux/apprun-hooks/default-to-x11.sh new file mode 100644 index 0000000000000..16ee82f12a9c9 --- /dev/null +++ b/.github/workflows/scripts/linux/apprun-hooks/default-to-x11.sh @@ -0,0 +1,9 @@ +if [[ -z "$I_WANT_A_BROKEN_WAYLAND_UI" ]]; then + echo "Forcing X11 instead of Wayland, due to various protocol limitations" + echo "and Qt issues. If you want to use Wayland, launch PCSX2 with" + echo "I_WANT_A_BROKEN_WAYLAND_UI=YES set." + export QT_QPA_PLATFORM=xcb +else + echo "Wayland is not being disabled. Do not complain when things break." +fi +