Skip to content

Commit

Permalink
ci(flatpak): add flatpak builder lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Jul 3, 2024
1 parent c92e4f2 commit c53b29c
Show file tree
Hide file tree
Showing 10 changed files with 58 additions and 38 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ jobs:
matrix: ${{ steps.flatpak_matrix.outputs.matrix }}

build_linux_flatpak:
env:
APP_ID: dev.lizardbyte.app.Sunshine
name: Linux Flatpak
runs-on: ubuntu-22.04
needs: [setup_release, setup_flatpak_matrix]
Expand Down Expand Up @@ -157,20 +159,30 @@ jobs:
-DSUNSHINE_CONFIGURE_ONLY=ON \
..
- name: Debug Manifest
working-directory: build
run: |
cat ${APP_ID}.yml
- name: Lint Manifest
working-directory: build
run: |
flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest ${APP_ID}.yml
- name: Build Linux Flatpak
working-directory: build
run: |
sudo su $(whoami) -c 'flatpak run org.flatpak.Builder --arch=${{ matrix.arch }} --repo=repo --force-clean \
--stop-at=cuda build-sunshine dev.lizardbyte.sunshine.yml'
sudo su $(whoami) -c "flatpak run org.flatpak.Builder --arch=${{ matrix.arch }} --repo=repo --force-clean \
--stop-at=cuda build-sunshine ${APP_ID}.yml"
cp -r .flatpak-builder copy-of-flatpak-builder
sudo su $(whoami) -c 'flatpak run org.flatpak.Builder --arch=${{ matrix.arch }} --repo=repo --force-clean \
build-sunshine dev.lizardbyte.sunshine.yml'
sudo su $(whoami) -c "flatpak run org.flatpak.Builder --arch=${{ matrix.arch }} --repo=repo --force-clean \
build-sunshine ${APP_ID}.yml"
rm -rf .flatpak-builder
mv copy-of-flatpak-builder .flatpak-builder
sudo su $(whoami) -c 'flatpak build-bundle --arch=${{ matrix.arch }} ./repo \
../artifacts/sunshine_${{ matrix.arch }}.flatpak dev.lizardbyte.sunshine'
sudo su $(whoami) -c 'flatpak build-bundle --runtime --arch=${{ matrix.arch }} ./repo \
../artifacts/sunshine_debug_${{ matrix.arch }}.flatpak dev.lizardbyte.sunshine.Debug'
sudo su $(whoami) -c "flatpak build-bundle --arch=${{ matrix.arch }} ./repo \
../artifacts/sunshine_${{ matrix.arch }}.flatpak ${APP_ID}"
sudo su $(whoami) -c "flatpak build-bundle --runtime --arch=${{ matrix.arch }} ./repo \
../artifacts/sunshine_debug_${{ matrix.arch }}.flatpak ${APP_ID}.Debug"
- name: Upload Artifacts
uses: actions/upload-artifact@v4
Expand Down
8 changes: 8 additions & 0 deletions cmake/prep/init.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ elseif (UNIX)
if(NOT DEFINED SUNSHINE_EXECUTABLE_PATH)
set(SUNSHINE_EXECUTABLE_PATH "sunshine")
endif()

if(SUNSHINE_BUILD_FLATPAK)
set(SUNSHINE_SERVICE_START_COMMAND "ExecStart=flatpak run dev.lizardbyte.app.Sunshine")
set(SUNSHINE_SERVICE_STOP_COMMAND "ExecStop=flatpak kill dev.lizardbyte.app.Sunshine")
else()
set(SUNSHINE_SERVICE_START_COMMAND "ExecStart=${SUNSHINE_EXECUTABLE_PATH}")
set(SUNSHINE_SERVICE_STOP_COMMAND "")
endif()
endif ()
2 changes: 1 addition & 1 deletion cmake/prep/special_package_configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ elseif(UNIX)

# configure the flatpak manifest
if(${SUNSHINE_CONFIGURE_FLATPAK_MAN})
configure_file(packaging/linux/flatpak/dev.lizardbyte.sunshine.yml dev.lizardbyte.sunshine.yml @ONLY)
configure_file(packaging/linux/flatpak/dev.lizardbyte.app.Sunshine.yml dev.lizardbyte.app.Sunshine.yml @ONLY)
file(COPY packaging/linux/flatpak/deps/ DESTINATION ${CMAKE_BINARY_DIR})
file(COPY packaging/linux/flatpak/modules DESTINATION ${CMAKE_BINARY_DIR})
endif()
Expand Down
16 changes: 8 additions & 8 deletions docs/source/about/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,25 @@ Install
Additional installation (required)
.. code-block:: bash
flatpak run --command=additional-install.sh dev.lizardbyte.sunshine
flatpak run --command=additional-install.sh dev.lizardbyte.app.Sunshine
Start:
X11 and NVFBC capture (X11 Only)
.. code-block:: bash
flatpak run dev.lizardbyte.sunshine
flatpak run dev.lizardbyte.app.Sunshine
KMS capture (Wayland & X11)
.. code-block:: bash
sudo -i PULSE_SERVER=unix:$(pactl info | awk '/Server String/{print$3}') \
flatpak run dev.lizardbyte.sunshine
flatpak run dev.lizardbyte.app.Sunshine
Uninstall:
.. code-block:: bash
flatpak run --command=remove-additional-install.sh dev.lizardbyte.sunshine
flatpak uninstall --delete-data dev.lizardbyte.sunshine
flatpak run --command=remove-additional-install.sh dev.lizardbyte.app.Sunshine
flatpak uninstall --delete-data dev.lizardbyte.app.Sunshine
.. tab:: Homebrew

Expand Down Expand Up @@ -253,7 +253,7 @@ Install
Restart=on-failure
RestartSec=5s
#Flatpak Only
#ExecStop=flatpak kill dev.lizardbyte.sunshine
#ExecStop=flatpak kill dev.lizardbyte.app.Sunshine
[Install]
WantedBy=graphical-session.target
Expand All @@ -268,7 +268,7 @@ Install
deb /usr/bin/sunshine ✔
rpm /usr/bin/sunshine ✔
AppImage ~/sunshine.AppImage ✔
Flatpak flatpak run dev.lizardbyte.sunshine
Flatpak flatpak run dev.lizardbyte.app.Sunshine
======== ============================================== ===============

**Start once**
Expand Down Expand Up @@ -504,7 +504,7 @@ To get a list of available arguments run the following:

.. code-block:: bash
flatpak run --command=sunshine dev.lizardbyte.Sunshine --help
flatpak run --command=sunshine dev.lizardbyte.app.Sunshine --help
Shortcuts
---------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/troubleshooting/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If you forgot your credentials to the web UI, try this.

.. code-block:: bash
flatpak run --command=sunshine dev.lizardbyte.Sunshine --creds {new-username} {new-password}
flatpak run --command=sunshine dev.lizardbyte.app.Sunshine --creds {new-username} {new-password}
Web UI Access
Expand Down
11 changes: 11 additions & 0 deletions packaging/linux/flatpak/apps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"env": {
"PATH": "$(PATH):$(HOME)/.local/bin"
},
"apps": [
{
"name": "Desktop",
"image-path": "desktop.png"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
app-id: dev.lizardbyte.sunshine
app-id: dev.lizardbyte.app.Sunshine
runtime: org.freedesktop.Platform
runtime-version: "22.08"
sdk: org.freedesktop.Sdk
Expand All @@ -17,9 +17,8 @@ finish-args:
- --share=network # access network
- --socket=pulseaudio # play sounds using pulseaudio
- --socket=wayland # show windows using Wayland
- --socket=x11 # show windows using X11
- --socket=fallback-x11 # show windows using X11
- --system-talk-name=org.freedesktop.Avahi # talk to avahi on the system bus
- --talk-name=org.freedesktop.Flatpak # talk to flatpak on the session bus

cleanup:
- /include
Expand Down Expand Up @@ -194,7 +193,7 @@ modules:
stable-only: true

- name: miniupnpc
buildsystem: cmake
buildsystem: cmake-ninja
config-opts:
- -DUPNPC_BUILD_SAMPLE=OFF
- -DUPNPC_BUILD_SHARED=ON
Expand Down Expand Up @@ -258,7 +257,7 @@ modules:

- name: sunshine
disabled: false
buildsystem: cmake
buildsystem: cmake-ninja
no-make-install: false
builddir: true
build-options:
Expand All @@ -277,7 +276,6 @@ modules:
- -DBUILD_DOCS=OFF
- -DBUILD_WERROR=ON
- -DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=/app
- -DCMAKE_CUDA_COMPILER=/app/cuda/bin/nvcc
- -DSUNSHINE_ASSETS_DIR=share/sunshine
- -DSUNSHINE_EXECUTABLE_PATH=/app/bin/sunshine
Expand All @@ -289,20 +287,10 @@ modules:
sources:
- type: git
url: "@GITHUB_CLONE_URL@"
branch: "@GITHUB_BRANCH@"
commit: "@GITHUB_COMMIT@"
post-install:
# use `sed` to update apps.json with prefixes required for flatpak
# -r (regex)
# -z (handle new lines) https://linuxhint.com/sed-replace-newline-with-space
# `/gm` global and multiline
- sed -r -z -i -e
's/("((do)|(undo)|(cmd)|(detached))"\s*:\s*\[?\n*\s*")(.*")/\1flatpak-spawn --host \7/gm'
/app/share/sunshine/apps.json
- sed -i
's%/app/bin/sunshine%flatpak run dev.lizardbyte.sunshine\nExecStop=flatpak kill dev.lizardbyte.sunshine%g'
/app/share/sunshine/systemd/user/sunshine.service
- install -D $FLATPAK_BUILDER_BUILDDIR/packaging/linux/flatpak/scripts/* /app/bin
- install -D $FLATPAK_BUILDER_BUILDDIR/packaging/linux/flatpak/apps.json /app/share/sunshine/apps.json
run-tests: true
test-rule: "" # empty to disable
test-commands:
Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/flatpak/sunshine.desktop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[Desktop Entry]
Type=Application
Name=@PROJECT_NAME@
Exec=flatpak run dev.lizardbyte.sunshine
Exec=flatpak run dev.lizardbyte.app.Sunshine
Version=1.0
Comment=@PROJECT_DESCRIPTION@
Icon=sunshine
Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/flatpak/sunshine_kms.desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Desktop Entry]
Name=@PROJECT_NAME@ (KMS)
Exec=sudo -i PULSE_SERVER=unix:$(pactl info | awk '/Server String/{print$3}') flatpak run dev.lizardbyte.sunshine
Exec=sudo -i PULSE_SERVER=unix:$(pactl info | awk '/Server String/{print$3}') flatpak run dev.lizardbyte.app.Sunshine
Terminal=true
Type=Application
NoDisplay=true
3 changes: 2 additions & 1 deletion packaging/linux/sunshine.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=@SUNSHINE_EXECUTABLE_PATH@
@SUNSHINE_SERVICE_START_COMMAND@
@SUNSHINE_SERVICE_STOP_COMMAND@
Restart=on-failure
RestartSec=5s

Expand Down

0 comments on commit c53b29c

Please sign in to comment.