diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44aa3dd37..a02a6856e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -384,9 +384,30 @@ jobs: name: shadps4-linux-qt-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }} path: Shadps4-qt.AppImage + linux-flatpak: + runs-on: ubuntu-24.04 + needs: get-info + container: + image: bilelmoussaoui/flatpak-github-actions:kde-6.7 + options: --privileged + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: flatpak/flatpak-github-actions/flatpak-builder@master + with: + manifest-path: net.shadps4.shadPS4.yaml + cache-key: flatpak-builder-${{ github.sha }} + bundle: shadps4.flatpak + upload-artifact: false + - uses: actions/upload-artifact@v4 + with: + path: shadps4.flatpak + name: shadps4-linux-flatpak-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }} + pre-release: if: github.ref == 'refs/heads/main' && github.repository == 'shadps4-emu/shadPS4' && github.event_name == 'push' - needs: [get-info, windows-sdl, windows-qt, macos-sdl, macos-qt, linux-sdl, linux-qt] + needs: [get-info, windows-sdl, windows-qt, macos-sdl, macos-qt, linux-sdl, linux-qt, linux-flatpak] runs-on: ubuntu-latest steps: - name: Download all artifacts diff --git a/.gitignore b/.gitignore index 61d9e32e1..016ce4567 100644 --- a/.gitignore +++ b/.gitignore @@ -414,3 +414,9 @@ FodyWeavers.xsd # for macOS **/.DS_Store + +# flatpak build +builddir +.flatpak-builder +repo +*.flatpak diff --git a/net.shadps4.shadPS4.yaml b/net.shadps4.shadPS4.yaml new file mode 100644 index 000000000..92db5d714 --- /dev/null +++ b/net.shadps4.shadPS4.yaml @@ -0,0 +1,68 @@ +# SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +id: net.shadps4.shadPS4 +runtime: org.kde.Platform +runtime-version: '6.8' +sdk: org.kde.Sdk +command: shadps4 +rename-icon: shadps4 +rename-desktop-file: shadps4.desktop +rename-appdata-file: shadps4.metainfo.xml +separate-locales: false +finish-args: + - --share=network + - --socket=pulseaudio + - --socket=wayland + - --socket=fallback-x11 + - --allow=bluetooth + - --filesystem=home + - --device=dri + - --device=input + - --filesystem=/media + - --filesystem=/run/media + - --talk-name=org.kde.StatusNotifierWatcher +add-extensions: + org.freedesktop.Platform.ffmpeg-full: + directory: lib/ffmpeg + add-ld-path: . + version: '24.08' + autodownload: true + autodelete: false +cleanup-commands: + - mkdir -p ${FLATPAK_DEST}/lib/ffmpeg +modules: + - name: rapidjson + buildsystem: cmake + config-opts: + - -DRAPIDJSON_BUILD_CXX11=OFF + - -DRAPIDJSON_BUILD_TESTS=OFF + sources: + - type: git + url: https://github.com/Tencent/rapidjson.git + commit: 858451e5b7d1c56cf8f6d58f88cf958351837e53 + cleanup: + - '*' + - name: libfmt + buildsystem: cmake + config-opts: + - -DFMT_TEST=OFF + sources: + - type: git + url: https://github.com/fmtlib/fmt.git + commit: 56ce41ef6368dfbe7d6aefe19d20365bd601a3b0 + cleanup: + - '*' + - name: shadPS4 + buildsystem: cmake + builddir: true + config-opts: + - -DCMAKE_BUILD_TYPE=Release + - -DENABLE_QT_GUI=ON + build-options: + env: + CMAKE_C_COMPILER: clang + CMAKE_CXX_COMPILER: clang++ + sources: + - type: dir + path: . diff --git a/src/qt_gui/check_update.cpp b/src/qt_gui/check_update.cpp index a9aba0b84..c3c2a040e 100644 --- a/src/qt_gui/check_update.cpp +++ b/src/qt_gui/check_update.cpp @@ -91,7 +91,11 @@ void CheckUpdate::CheckForUpdates(const bool showMessage) { #ifdef Q_OS_WIN platformString = "win64-qt"; #elif defined(Q_OS_LINUX) - platformString = "linux-qt"; + if (std::getenv("container")) { + platformString = "linux-flatpak"; + } else if (std::getenv("APPIMAGE")) { + platformString = "linux-qt"; + } #elif defined(Q_OS_MAC) platformString = "macos-qt"; #endif @@ -462,23 +466,53 @@ void CheckUpdate::Install() { " exit 1\n" " fi\n" "}\n" + "set_package_type() {\n" + " if pgrep -f \"Shadps4-qt.AppImage\" > /dev/null; then\n" + " TYPE=\"appimage\"\n" + " else\n" + " TYPE=\"flatpak\"\n" + " fi\n" + "}\n" + "kill_process() {\n" + " if [ \"$TYPE\" == \"appimage\" ]; then\n" + " pkill -f \"Shadps4-qt.AppImage\"\n" + " sleep 2\n" + " else\n" + " pkill -f \"Shadps4\"\n" + " sleep 2\n" + " fi\n" + "}\n" + "update_package() {\n" + " if [ \"$TYPE\" == \"appimage\" ]; then\n" + " cp -r \"$1/\"* \"$2/\"\n" + " chmod +x \"$2/Shadps4-qt.AppImage\"\n" + " else\n" + " flatpak install -u \"$2/shadps4.flatpak\"\n" + " fi\n" + "}\n" + "restart_app() {\n" + " if [ \"$TYPE\" == \"appimage\" ]; then\n" + " cd \"$1\" && ./Shadps4-qt.AppImage\n" + " else\n" + " flatpak run -u net.shadps4.shadPS4\n" + " fi\n" + "}\n" "main() {\n" " check_unzip\n" " echo \"%1\"\n" " sleep 2\n" " extract_file\n" " sleep 2\n" - " if pgrep -f \"Shadps4-qt.AppImage\" > /dev/null; then\n" - " pkill -f \"Shadps4-qt.AppImage\"\n" - " sleep 2\n" - " fi\n" - " cp -r \"%2/\"* \"%3/\"\n" + " set_package_type\n" " sleep 2\n" + " kill_process\n" + " sleep 2\n" + " update_package \"%2\" \"%3\"\n" + " sleep 2\n" + " restart_app \"%3\"\n" " rm \"%3/update.sh\"\n" " rm \"%3/temp_download_update.zip\"\n" - " chmod +x \"%3/Shadps4-qt.AppImage\"\n" " rm -r \"%2\"\n" - " cd \"%3\" && ./Shadps4-qt.AppImage\n" "}\n" "main\n"); arguments << scriptFileName;