From c9a06fd8a7e8f2f3411e7d307e724b7571a47fbe Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 9 Jun 2025 12:39:57 -0400 Subject: [PATCH] build(linux): consolidate appstream metainfo (#3954) --- .github/workflows/CI.yml | 4 ++- .github/workflows/update-flathub-repo.yml | 23 ++----------- cmake/packaging/linux.cmake | 23 +++---------- cmake/prep/build_version.cmake | 31 +++++++++++++++++ .../prep/special_package_configuration.cmake | 14 +++----- ...op => dev.lizardbyte.app.Sunshine.desktop} | 12 +++---- packaging/linux/Arch/PKGBUILD | 8 +++++ ...op => dev.lizardbyte.app.Sunshine.desktop} | 16 ++++----- .../dev.lizardbyte.app.Sunshine.metainfo.xml | 34 ++++++++++++------- ....lizardbyte.app.Sunshine.terminal.desktop} | 0 packaging/linux/fedora/Sunshine.spec | 12 +++++-- ...op => dev.lizardbyte.app.Sunshine.desktop} | 2 +- packaging/linux/flatpak/exceptions.json | 2 +- packaging/linux/sunshine.appdata.xml | 21 ------------ scripts/linux_build.sh | 16 +++++++++ 15 files changed, 118 insertions(+), 100 deletions(-) rename packaging/linux/AppImage/{sunshine.desktop => dev.lizardbyte.app.Sunshine.desktop} (86%) rename packaging/linux/{sunshine.desktop => dev.lizardbyte.app.Sunshine.desktop} (71%) rename packaging/linux/{flatpak => }/dev.lizardbyte.app.Sunshine.metainfo.xml (65%) rename packaging/linux/{sunshine_terminal.desktop => dev.lizardbyte.app.Sunshine.terminal.desktop} (100%) rename packaging/linux/flatpak/{sunshine.desktop => dev.lizardbyte.app.Sunshine.desktop} (81%) delete mode 100644 packaging/linux/sunshine.appdata.xml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 418e3133..6123ca60 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -264,6 +264,8 @@ jobs: build_linux: name: Linux ${{ matrix.type }} + env: + APP_ID: dev.lizardbyte.app.Sunshine runs-on: ubuntu-${{ matrix.dist }} needs: setup_release strategy: @@ -364,7 +366,7 @@ jobs: chmod +x ./AppDir/AppRun # variables - DESKTOP_FILE="${DESKTOP_FILE:-sunshine.desktop}" + DESKTOP_FILE="${DESKTOP_FILE:-${APP_ID}.desktop}" ICON_FILE="${ICON_FILE:-sunshine.png}" # AppImage diff --git a/.github/workflows/update-flathub-repo.yml b/.github/workflows/update-flathub-repo.yml index 524a8a41..b1004cb1 100644 --- a/.github/workflows/update-flathub-repo.yml +++ b/.github/workflows/update-flathub-repo.yml @@ -133,30 +133,11 @@ jobs: xml_file="flathub/${{ env.FLATHUB_PKG }}/${{ env.FLATHUB_PKG }}.metainfo.xml" # Extract release information - version="${{ github.event.release.tag_name }}" && version="${version#v}" - date="${{ github.event.release.published_at }}" && date="${date%%T*}" changelog="${{ github.event.release.body }}" && changelog="${changelog//&/&}" && \ changelog="${changelog///>}" - # Store the old release information into a temp file to be used for precise replacement - tmpfile=$(mktemp) - - # Match the existing block, replace it with the new data - awk -v version="$version" -v date="$date" -v changelog="$changelog" ' - BEGIN { replaced = 0 } - // { - if (!replaced) { - print " " - print "

" changelog "

" - print "
" - replaced = 1 - } - } - !// && !/<\/release>/ { print $0 } - ' "$xml_file" > "$tmpfile" - - # Move the updated file back to the original location - mv "$tmpfile" "$xml_file" + # Replace changelog placeholder with actual changelog + sed -i "s||$changelog|g" "$xml_file" - name: Update submodule if: >- diff --git a/cmake/packaging/linux.cmake b/cmake/packaging/linux.cmake index 6f4ebbe3..659bbc37 100644 --- a/cmake/packaging/linux.cmake +++ b/cmake/packaging/linux.cmake @@ -136,26 +136,13 @@ if(${SUNSHINE_TRAY} STREQUAL 1) endif() # desktop file -# todo - validate desktop files with `desktop-file-validate` -if(NOT ${SUNSHINE_BUILD_FLATPAK}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.desktop" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") -else() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.desktop" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications" - RENAME "${PROJECT_FQDN}.desktop") -endif() +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.desktop" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") if(NOT ${SUNSHINE_BUILD_APPIMAGE} AND NOT ${SUNSHINE_BUILD_FLATPAK}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine_terminal.desktop" + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.terminal.desktop" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/applications") endif() # metadata file -# todo - validate file with `appstream-util validate-relax` -if(NOT ${SUNSHINE_BUILD_FLATPAK}) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.appdata.xml" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") -else() - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.metainfo.xml" - DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") -endif() +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_FQDN}.metainfo.xml" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/metainfo") diff --git a/cmake/prep/build_version.cmake b/cmake/prep/build_version.cmake index 5457fed1..e0d43380 100644 --- a/cmake/prep/build_version.cmake +++ b/cmake/prep/build_version.cmake @@ -54,3 +54,34 @@ else() MESSAGE(WARNING ": Git not found, cannot find git version") endif() endif() + +# set date variables +set(PROJECT_YEAR "1990") +set(PROJECT_MONTH "01") +set(PROJECT_DAY "01") + +# Extract year, month, and day +if(PROJECT_VERSION MATCHES "^([0-9]{4})[.]([0-9]{3,4})") + # First capture group is the year + set(PROJECT_YEAR "${CMAKE_MATCH_1}") + + # Second capture group is month/day + set(MONTH_DAY "${CMAKE_MATCH_2}") + string(LENGTH "${MONTH_DAY}" MONTH_DAY_LENGTH) + if(MONTH_DAY_LENGTH EQUAL 3) + string(SUBSTRING "${MONTH_DAY}" 0 1 PROJECT_MONTH) + string(SUBSTRING "${MONTH_DAY}" 1 2 PROJECT_DAY) + elseif(MONTH_DAY_LENGTH EQUAL 4) + string(SUBSTRING "${MONTH_DAY}" 0 2 PROJECT_MONTH) + string(SUBSTRING "${MONTH_DAY}" 2 2 PROJECT_DAY) + endif() + + # Ensure month is two digits + if(PROJECT_MONTH LESS 10 AND NOT PROJECT_MONTH MATCHES "^0") + set(PROJECT_MONTH "0${PROJECT_MONTH}") + endif() + # Ensure day is two digits + if(PROJECT_DAY LESS 10 AND NOT PROJECT_DAY MATCHES "^0") + set(PROJECT_DAY "0${PROJECT_DAY}") + endif() +endif() diff --git a/cmake/prep/special_package_configuration.cmake b/cmake/prep/special_package_configuration.cmake index 298c0226..74613523 100644 --- a/cmake/prep/special_package_configuration.cmake +++ b/cmake/prep/special_package_configuration.cmake @@ -12,19 +12,17 @@ elseif(UNIX) # configure the .desktop file set(SUNSHINE_DESKTOP_ICON "sunshine") if(${SUNSHINE_BUILD_APPIMAGE}) - configure_file(packaging/linux/AppImage/sunshine.desktop sunshine.desktop @ONLY) + configure_file(packaging/linux/AppImage/${PROJECT_FQDN}.desktop ${PROJECT_FQDN}.desktop @ONLY) elseif(${SUNSHINE_BUILD_FLATPAK}) set(SUNSHINE_DESKTOP_ICON "${PROJECT_FQDN}") - configure_file(packaging/linux/flatpak/sunshine.desktop sunshine.desktop @ONLY) - configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.metainfo.xml - ${PROJECT_FQDN}.metainfo.xml @ONLY) + configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.desktop ${PROJECT_FQDN}.desktop @ONLY) else() - configure_file(packaging/linux/sunshine.desktop sunshine.desktop @ONLY) - configure_file(packaging/linux/sunshine_terminal.desktop sunshine_terminal.desktop @ONLY) + configure_file(packaging/linux/${PROJECT_FQDN}.desktop ${PROJECT_FQDN}.desktop @ONLY) + configure_file(packaging/linux/${PROJECT_FQDN}.terminal.desktop ${PROJECT_FQDN}.terminal.desktop @ONLY) endif() # configure metadata file - configure_file(packaging/linux/sunshine.appdata.xml sunshine.appdata.xml @ONLY) + configure_file(packaging/linux/${PROJECT_FQDN}.metainfo.xml ${PROJECT_FQDN}.metainfo.xml @ONLY) # configure service configure_file(packaging/linux/sunshine.service.in sunshine.service @ONLY) @@ -38,8 +36,6 @@ elseif(UNIX) # configure the flatpak manifest if(${SUNSHINE_CONFIGURE_FLATPAK_MAN}) configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.yml ${PROJECT_FQDN}.yml @ONLY) - configure_file(packaging/linux/flatpak/${PROJECT_FQDN}.metainfo.xml - ${PROJECT_FQDN}.metainfo.xml @ONLY) file(COPY packaging/linux/flatpak/deps/ DESTINATION ${CMAKE_BINARY_DIR}) file(COPY packaging/linux/flatpak/modules DESTINATION ${CMAKE_BINARY_DIR}) file(COPY generated-sources.json DESTINATION ${CMAKE_BINARY_DIR}) diff --git a/packaging/linux/AppImage/sunshine.desktop b/packaging/linux/AppImage/dev.lizardbyte.app.Sunshine.desktop similarity index 86% rename from packaging/linux/AppImage/sunshine.desktop rename to packaging/linux/AppImage/dev.lizardbyte.app.Sunshine.desktop index 911735c8..91da7902 100644 --- a/packaging/linux/AppImage/sunshine.desktop +++ b/packaging/linux/AppImage/dev.lizardbyte.app.Sunshine.desktop @@ -1,13 +1,13 @@ [Desktop Entry] -Type=Application -Name=@PROJECT_NAME@ -Exec=sunshine -Version=1.0 +Categories=RemoteAccess;Network; Comment=@PROJECT_DESCRIPTION@ +Exec=sunshine Icon=sunshine Keywords=gamestream;stream;moonlight;remote play; -Categories=AudioVideo;Network;RemoteAccess; +Name=@PROJECT_NAME@ Terminal=true +Type=Application +Version=1.0 +X-AppImage-Arch=x86_64 X-AppImage-Name=sunshine X-AppImage-Version=@PROJECT_VERSION@ -X-AppImage-Arch=x86_64 diff --git a/packaging/linux/Arch/PKGBUILD b/packaging/linux/Arch/PKGBUILD index e8729163..17fc672a 100644 --- a/packaging/linux/Arch/PKGBUILD +++ b/packaging/linux/Arch/PKGBUILD @@ -36,7 +36,10 @@ depends=( ) makedepends=( + 'appstream' + 'appstream-glib' 'cmake' + 'desktop-file-utils' 'cuda' "gcc${_gcc_version}" 'git' @@ -86,6 +89,11 @@ build() { -D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \ -D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' + appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml" + appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml" + desktop-file-validate "build/dev.lizardbyte.app.Sunshine.desktop" + desktop-file-validate "build/dev.lizardbyte.app.Sunshine.terminal.desktop" + make -C build } diff --git a/packaging/linux/sunshine.desktop b/packaging/linux/dev.lizardbyte.app.Sunshine.desktop similarity index 71% rename from packaging/linux/sunshine.desktop rename to packaging/linux/dev.lizardbyte.app.Sunshine.desktop index bc8a995c..29252ae5 100644 --- a/packaging/linux/sunshine.desktop +++ b/packaging/linux/dev.lizardbyte.app.Sunshine.desktop @@ -1,15 +1,15 @@ [Desktop Entry] -Type=Application -Name=@PROJECT_NAME@ -Exec=/usr/bin/env systemctl start --u sunshine -Version=1.0 +Actions=RunInTerminal; +Categories=RemoteAccess;Network; Comment=@PROJECT_DESCRIPTION@ +Exec=/usr/bin/env systemctl start --u sunshine Icon=@SUNSHINE_DESKTOP_ICON@ Keywords=gamestream;stream;moonlight;remote play; -Categories=AudioVideo;Network;RemoteAccess; -Actions=RunInTerminal; +Name=@PROJECT_NAME@ +Type=Application +Version=1.0 [Desktop Action RunInTerminal] -Name=Run in Terminal +Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/@PROJECT_FQDN@.terminal.desktop Icon=application-x-executable -Exec=gio launch @CMAKE_INSTALL_FULL_DATAROOTDIR@/applications/sunshine_terminal.desktop +Name=Run in Terminal diff --git a/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.metainfo.xml b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml similarity index 65% rename from packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.metainfo.xml rename to packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml index fe5f9d76..6be35169 100644 --- a/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.metainfo.xml +++ b/packaging/linux/dev.lizardbyte.app.Sunshine.metainfo.xml @@ -1,8 +1,8 @@ - + @PROJECT_FQDN@ - @CMAKE_PROJECT_NAME@ + @PROJECT_NAME@ @PROJECT_BRIEF_DESCRIPTION@ CC0-1.0 @@ -15,39 +15,49 @@ gamepad - https://github.com/LizardByte/Sunshine/issues @PROJECT_HOMEPAGE_URL@ + https://github.com/LizardByte/Sunshine/issues + https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2troubleshooting.html + https://docs.lizardbyte.dev/projects/sunshine https://app.lizardbyte.dev/#Donate - https://app.lizardbyte.dev/support https://translate.lizardbyte.dev - https://docs.lizardbyte.dev - https://github.com/LizardByte/Sunshine + https://app.lizardbyte.dev/support

@PROJECT_LONG_DESCRIPTION@

-

NOTE: Sunshine requires additional installation steps.

+

NOTE: Sunshine requires additional installation steps (Flatpak).

flatpak run --command=additional-install.sh @PROJECT_FQDN@

NOTE: Sunshine uses a self-signed certificate. The web browser will report it as not secure, but it is safe.

-

NOTE: KMS Grab (Optional)

+

NOTE: KMS Grab (Flatpak)

sudo -i PULSE_SERVER=unix:/run/user/$(id -u $whoami)/pulse/native flatpak run @PROJECT_FQDN@

- + + +

+ See the full changelog on GitHub + + +

+
+
- LizardByte + + LizardByte + - https://app.lizardbyte.dev/Sunshine/assets/img/banners/AdobeStock_305732536_1920x1280.jpg - Sunshine + https://app.lizardbyte.dev/Sunshine/assets/img/screenshots/01-sunshine-welcome-page.png + Sunshine welcome page diff --git a/packaging/linux/sunshine_terminal.desktop b/packaging/linux/dev.lizardbyte.app.Sunshine.terminal.desktop similarity index 100% rename from packaging/linux/sunshine_terminal.desktop rename to packaging/linux/dev.lizardbyte.app.Sunshine.terminal.desktop diff --git a/packaging/linux/fedora/Sunshine.spec b/packaging/linux/fedora/Sunshine.spec index 3becff3b..1f7a8782 100644 --- a/packaging/linux/fedora/Sunshine.spec +++ b/packaging/linux/fedora/Sunshine.spec @@ -15,8 +15,11 @@ License: GPLv3-only URL: https://github.com/LizardByte/Sunshine Source0: tarball.tar.gz +BuildRequires: appstream # BuildRequires: boost-devel >= 1.86.0 BuildRequires: cmake >= 3.25.0 +BuildRequires: desktop-file-utils +BuildRequires: libappstream-glib BuildRequires: libayatana-appindicator3-devel BuildRequires: libcap-devel BuildRequires: libcurl-devel @@ -197,6 +200,11 @@ cmake "${cmake_args[@]}" make -j$(nproc) -C "%{_builddir}/Sunshine/build" %check +# validate the metainfo file +appstreamcli validate %{buildroot}%{_metainfodir}/*.metainfo.xml +appstream-util validate %{buildroot}%{_metainfodir}/*.metainfo.xml +desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop + # run tests cd %{_builddir}/Sunshine/build xvfb-run ./tests/test_sunshine @@ -252,14 +260,14 @@ rm -f /usr/lib/modules-load.d/uhid.conf %{_modulesloaddir}/uhid.conf # Desktop entries -%{_datadir}/applications/sunshine*.desktop +%{_datadir}/applications/*.desktop # Icons %{_datadir}/icons/hicolor/scalable/apps/sunshine.svg %{_datadir}/icons/hicolor/scalable/status/sunshine*.svg # Metainfo -%{_datadir}/metainfo/sunshine.appdata.xml +%{_datadir}/metainfo/*.metainfo.xml # Assets %{_datadir}/sunshine/** diff --git a/packaging/linux/flatpak/sunshine.desktop b/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.desktop similarity index 81% rename from packaging/linux/flatpak/sunshine.desktop rename to packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.desktop index eca745ef..a6ab9ea5 100644 --- a/packaging/linux/flatpak/sunshine.desktop +++ b/packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.desktop @@ -1,5 +1,5 @@ [Desktop Entry] -Categories=AudioVideo;Network;RemoteAccess; +Categories=RemoteAccess;Network; Comment=@PROJECT_DESCRIPTION@ Exec=sunshine.sh Icon=@SUNSHINE_DESKTOP_ICON@ diff --git a/packaging/linux/flatpak/exceptions.json b/packaging/linux/flatpak/exceptions.json index 957f7384..f341c260 100644 --- a/packaging/linux/flatpak/exceptions.json +++ b/packaging/linux/flatpak/exceptions.json @@ -1,6 +1,6 @@ { "dev.lizardbyte.app.Sunshine": [ - "appstream-missing-screenshots", + "appstream-external-screenshot-url", "appstream-screenshots-not-mirrored-in-ostree", "external-gitmodule-url-found", "finish-args-flatpak-spawn-access" diff --git a/packaging/linux/sunshine.appdata.xml b/packaging/linux/sunshine.appdata.xml deleted file mode 100644 index cb999d41..00000000 --- a/packaging/linux/sunshine.appdata.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - @PROJECT_NAME@ - CC0-1.0 - @PROJECT_LICENSE@ - @PROJECT_NAME@ - @CMAKE_PROJECT_HOMEPAGE_URL@ - @PROJECT_BRIEF_DESCRIPTION@ - -

- @PROJECT_LONG_DESCRIPTION@ -

-
- sunshine.desktop - - - https://app.lizardbyte.dev/Sunshine/assets/images/AdobeStock_305732536_1920x1280.jpg - Sunshine - - -
diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index 3b09eed5..4132c39d 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -138,9 +138,12 @@ function add_arch_deps() { function add_debian_based_deps() { dependencies+=( + "appstream" + "appstream-util" "bison" # required if we need to compile doxygen "build-essential" "cmake" + "desktop-file-utils" "doxygen" "flex" # required if we need to compile doxygen "gcc-${gcc_version}" @@ -201,13 +204,16 @@ function add_ubuntu_deps() { function add_fedora_deps() { dependencies+=( + "appstream" "cmake" + "desktop-file-utils" "doxygen" "gcc${gcc_version}" "gcc${gcc_version}-c++" "git" "graphviz" "libappindicator-gtk3-devel" + "libappstream-glib" "libcap-devel" "libcurl-devel" "libdrm-devel" @@ -469,6 +475,16 @@ function run_install() { echo "cmake args:" echo "${cmake_args[@]}" cmake "${cmake_args[@]}" + + # Run appstream validation, etc. + appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml" + appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml" + desktop-file-validate "build/dev.lizardbyte.app.Sunshine.desktop" + if [ "$appimage_build" == 0 ]; then + desktop-file-validate "build/dev.lizardbyte.app.Sunshine.terminal.desktop" + fi + + # Build the project ninja -C "build" # Create the package