Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial flatpak packaging #195

Merged
merged 5 commits into from
Jun 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 100 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,94 @@ jobs:
echo Within 'CMakeLists.txt' change "project(Sunshine [VERSION $cmakelists_version]" to "project(Sunshine [VERSION ${{ needs.check_changelog.outputs.next_version_bare }}]"
exit 1

build_linux_flatpak:
name: Linux Flatpak
runs-on: ubuntu-18.04
needs: check_changelog

steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
root-reserve-mb: 2048
swap-size-mb: 8192
remove-dotnet: 'true'
remove-android: 'true'
remove-haskell: 'true'

- name: Cache flatpak-builder
uses: actions/cache@v3
with:
path: ./build/.flatpak-builder/build
key: ${{ runner.os }}-flatpak-builder

- name: Checkout
uses: actions/checkout@v3

- name: Setup Dependencies Linux Flatpak
run: |
sudo add-apt-repository ppa:flatpak/stable -y
sudo apt-get update -y
sudo apt-get install -y \
cmake \
flatpak \
flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install flathub org.freedesktop.Platform//21.08 org.freedesktop.Sdk//21.08 -y

- name: Configure Flatpak Manifest
run: |
# variables for manifest
owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' )
repo=$(echo ${GITHUB_REPOSITORY#*/} | tr '[:upper:]' '[:lower:]' )
branch=${GITHUB_HEAD_REF}
commit=${{ github.event.pull_request.head.sha }}

# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
branch=branch=${{ github.ref_name }}
commit=${{ github.sha }}
else
echo "This is a PR event"
fi
echo "Owner: ${owner}"
echo "Repo: ${repo}"
echo "Branch: ${branch}"
echo "Commit: ${commit}"

mkdir -p build
mkdir -p artifacts

cd build
cmake -DGITHUB_OWNER=${owner} -DGITHUB_REPO=${repo} -DGITHUB_BRANCH=${branch} -DSUNSHINE_CONFIGURE_FLATPAK=ON -DSUNSHINE_CONFIGURE_ONLY=ON ..

# add the commit
echo " commit: ${commit}" >> ./com.github.sunshinestream.sunshine.yml

- name: Build Linux Flatpak
working-directory: build
run: |
sudo flatpak-builder build-dir com.github.sunshinestream.sunshine.yml
sudo flatpak-builder --repo=repo --force-clean build-dir com.github.sunshinestream.sunshine.yml
sudo flatpak build-bundle ./repo ../artifacts/sunshine.flatpak com.github.sunshinestream.sunshine

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: sunshine-linux-flatpak
path: artifacts/

- name: Create Release
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: SunshineStream/actions/create_release@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
next_version: ${{ needs.check_changelog.outputs.next_version }}
last_version: ${{ needs.check_changelog.outputs.last_version }}
release_body: ${{ needs.check_changelog.outputs.release_body }}

build_linux:
name: Linux
runs-on: ubuntu-20.04
Expand All @@ -61,19 +149,22 @@ jobs:
matrix:
include: # package these differently
- type: cpack
CMAKE_INSTALL_PREFIX: ''
SUNSHINE_ASSETS_DIR: '/usr/local/sunshine/assets'
SUNSHINE_CONFIG_DIR: '/usr/local/sunshine/config'
CMAKE_INSTALL_PREFIX: '/usr'
SUNSHINE_ASSETS_DIR: 'local/sunshine/assets'
SUNSHINE_CONFIG_DIR: 'local/sunshine/config'
EXTRA_ARGS: ''
- type: appimage
CMAKE_INSTALL_PREFIX: '/usr'
SUNSHINE_ASSETS_DIR: 'sunshine.AppImage.config'
SUNSHINE_CONFIG_DIR: 'sunshine.AppImage.home'
EXTRA_ARGS: '-DSUNSHINE_CONFIGURE_APPIMAGE=ON'

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Setup Dependencies Linux
run: |
sudo add-apt-repository ppa:savoury1/ffmpeg4 -y
Expand Down Expand Up @@ -144,7 +235,7 @@ jobs:
mkdir -p artifacts

cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ matrix.CMAKE_INSTALL_PREFIX }} -DSUNSHINE_ASSETS_DIR=${{ matrix.SUNSHINE_ASSETS_DIR }} -DSUNSHINE_CONFIG_DIR=${{ matrix.SUNSHINE_CONFIG_DIR }} -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine -DSUNSHINE_ENABLE_WAYLAND=ON -DSUNSHINE_ENABLE_X11=ON -DSUNSHINE_ENABLE_DRM=ON -DSUNSHINE_ENABLE_CUDA=ON ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ matrix.CMAKE_INSTALL_PREFIX }} -DSUNSHINE_ASSETS_DIR=${{ matrix.SUNSHINE_ASSETS_DIR }} -DSUNSHINE_CONFIG_DIR=${{ matrix.SUNSHINE_CONFIG_DIR }} -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine -DSUNSHINE_ENABLE_WAYLAND=ON -DSUNSHINE_ENABLE_X11=ON -DSUNSHINE_ENABLE_DRM=ON -DSUNSHINE_ENABLE_CUDA=ON ${{ matrix.EXTRA_ARGS }} ..
make -j ${nproc}

- name: Package Linux - CPACK
Expand Down Expand Up @@ -276,22 +367,25 @@ jobs:
owner=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]' )
repo=$(echo ${GITHUB_REPOSITORY#*/} | tr '[:upper:]' '[:lower:]' )
branch=${GITHUB_HEAD_REF}
commit=${{ github.event.pull_request.head.sha }}

# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
branch=${GITHUB_BASE_REF}
branch=branch=${{ github.ref_name }}
commit=${{ github.sha }}
else
echo "This is a PR event"
fi
echo "Owner: ${owner}"
echo "Repo: ${repo}"
echo "Branch: ${branch}"
echo "Commit: ${commit}"

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=/usr/local/sunshine/assets -DSUNSHINE_CONFIG_DIR=/usr/local/sunshine/config -DGITHUB_OWNER=${owner} -DGITHUB_REPO=${repo} -DGITHUB_BRANCH=${branch} ..
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DSUNSHINE_ASSETS_DIR=local/sunshine/assets -DSUNSHINE_CONFIG_DIR=local/sunshine/config -DGITHUB_OWNER=${owner} -DGITHUB_REPO=${repo} -DGITHUB_BRANCH=${branch} -DSUNSHINE_CONFIGURE_PORTFILE=ON ..
make -j ${nproc}

- name: Package MacOS
Expand Down
35 changes: 26 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ project(Sunshine VERSION 0.14.0
HOMEPAGE_URL "https://sunshinestream.github.io"
)

option(SUNSHINE_CONFIGURE_APPIMAGE "Configure files required for AppImage." OFF)
option(SUNSHINE_CONFIGURE_FLATPAK "Configure files required for Flatpak." OFF)
option(SUNSHINE_CONFIGURE_PORTFILE "Configure MacOS Portfile." OFF)
option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)

if(${SUNSHINE_CONFIGURE_APPIMAGE})
configure_file(packaging/linux/sunshine.desktop sunshine.desktop @ONLY)
elseif(${SUNSHINE_CONFIGURE_FLATPAK})
configure_file(packaging/linux/flatpak/com.github.sunshinestream.sunshine.yml com.github.sunshinestream.sunshine.yml @ONLY)
elseif(${SUNSHINE_CONFIGURE_PORTFILE})
configure_file(packaging/macos/Portfile Portfile @ONLY)
endif()

# return if configure only is set
if(${SUNSHINE_CONFIGURE_ONLY})
return()
endif()

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(SUNSHINE_SOURCE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src_assets")

Expand Down Expand Up @@ -401,6 +419,11 @@ if(NOT SUNSHINE_CONFIG_DIR)
set(SUNSHINE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/config")
endif()

if(UNIX AND CMAKE_INSTALL_PREFIX AND NOT ${SUNSHINE_CONFIGURE_APPIMAGE})
set(SUNSHINE_ASSETS_DIR "${CMAKE_INSTALL_PREFIX}/${SUNSHINE_ASSETS_DIR}")
set(SUNSHINE_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/${SUNSHINE_CONFIG_DIR}")
endif()

list(APPEND CBS_EXTERNAL_LIBRARIES
cbs)

Expand All @@ -415,7 +438,7 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES
${OPENSSL_LIBRARIES}
${PLATFORM_LIBRARIES})

if (NOT WIN32)
if(NOT WIN32)
list(APPEND SUNSHINE_EXTERNAL_LIBRARIES Boost::log)
endif()

Expand Down Expand Up @@ -562,9 +585,6 @@ if(APPLE) # TODO: test
set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}")
set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns")
# set(CPACK_BUNDLE_STARTUP_COMMAND "${INSTALL_RUNTIME_DIR}/sunshine")

# Portfile
configure_file(Portfile.in Portfile @ONLY)
endif()
if(UNIX AND NOT APPLE)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
Expand All @@ -573,8 +593,8 @@ if(UNIX AND NOT APPLE)

install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine-rules.rules" DESTINATION "/etc/udev/rules.d")

install(TARGETS sunshine RUNTIME DESTINATION "/usr/bin")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "/usr/lib/systemd/user")
install(TARGETS sunshine RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/user")

# Pre and post install
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
Expand All @@ -587,9 +607,6 @@ if(UNIX AND NOT APPLE)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "openssl, libavdevice58, libboost-thread1.67.0 | libboost-thread1.71.0 | libboost-thread1.74.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0 | libboost-filesystem1.74.0, libboost-log1.67.0 | libboost-log1.71.0 | libboost-log1.74.0, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2")
set(CPACK_RPM_PACKAGE_REQUIRES "openssl >= 1.1, libavdevice >= 4.3, boost-thread >= 1.67.0, boost-filesystem >= 1.67.0, boost-log >= 1.67.0, pulseaudio-libs >= 10.0, libopusenc >= 0.2.1, libxcb >= 1.13, libXtst >= 1.2.3, libevdev >= 1.5.6, libdrm >= 2.4.97, libcap >= 2.22")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # This should automatically figure out dependencies, doesn't work with the current config

# AppImage desktop file
configure_file(sunshine.desktop.in sunshine.desktop @ONLY)
endif()

include(CPack)
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

Overview
========
SunshineStream has the full documentation hosted on `Read the Docs <http://sunshinestream.readthedocs.io/>`_.

About
-----
Expand Down
36 changes: 28 additions & 8 deletions docs/source/about/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AppImage
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/pkg:appimage?logo=github&style=for-the-badge
:alt: GitHub issues by-label

The current known compatibility of the AppImage is shown below.
According to AppImageLint the AppImage can run on the following distros.

- [✖] Debian oldstable (buster)
- [✔] Debian stable (bullseye)
Expand All @@ -42,11 +42,11 @@ The current known compatibility of the AppImage is shown below.
- [✖] Ubuntu trusty
- [✖] CentOS 7

#. Download and extract ``sunshine-appimage.zip`` to your home directory.
#. Download ``sunshine-appimage.zip`` and extract the contents to your home directory.

Debian Packages
^^^^^^^^^^^^^^^
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/os:linux:debian?logo=github&style=for-the-badge
Debian Package
^^^^^^^^^^^^^^
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/pkg:deb?logo=github&style=for-the-badge
:alt: GitHub issues by-label

#. Download ``sunshine.deb`` and run the following code.
Expand All @@ -57,9 +57,29 @@ Debian Packages

.. Tip:: You can double click the deb file to see details about the package and begin installation.

Red Hat Packages
^^^^^^^^^^^^^^^^
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/os:linux:fedora?logo=github&style=for-the-badge
Flatpak Package
^^^^^^^^^^^^^^^
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/pkg:flatpak?logo=github&style=for-the-badge
:alt: GitHub issues by-label

.. Todo:: This package needs to have CUDA added.

#. Install `Flatpak <https://flatpak.org/setup/>`_ as required.
#. Download ``sunshine.flatpak`` and run the following code.

System level (recommended)
.. code-block:: bash

flatpak install --system sunshine.flatpak

User level
.. code-block:: bash

flatpak install --user sunshine.flatpak

RPM Package
^^^^^^^^^^^
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/pkg:rpm?logo=github&style=for-the-badge
:alt: GitHub issues by-label

#. Add `rpmfusion` repositories by running the following code.
Expand Down
Loading