Merge pull request #204 from SunshineStream/macports-improvements

Macports improvements
This commit is contained in:
ReenigneArcher 2022-06-29 19:44:46 -04:00 committed by GitHub
commit 1415c8b200
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 446 additions and 243 deletions

View File

@ -9,6 +9,17 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
github_env:
name: GitHub Env Debug
runs-on: ubuntu-latest
steps:
- name: Dump github context
run: echo "$GITHUB_CONTEXT"
shell: bash
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
check_changelog: check_changelog:
name: Check Changelog name: Check Changelog
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -440,13 +451,6 @@ jobs:
with: with:
submodules: recursive submodules: recursive
# this is for the macports job
- name: Cache Artifacts
uses: actions/cache@v3
with:
path: artifacts
key: ${{ runner.os }}-artifacts
- name: Setup Dependencies MacOS - name: Setup Dependencies MacOS
run: | run: |
# install dependencies using homebrew # install dependencies using homebrew
@ -457,37 +461,13 @@ jobs:
- name: Build MacOS - name: Build MacOS
run: | run: |
# variables for Portfile
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 build mkdir build
cd build cd build
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 .. cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DSUNSHINE_ASSETS_DIR=local/sunshine/assets -DSUNSHINE_CONFIG_DIR=local/sunshine/config ..
make -j ${nproc} make -j ${nproc}
- name: Package MacOS - name: Package MacOS
run: | run: |
# remove cached artifacts
rm -r -f ./artifacts
mkdir artifacts
mkdir -p artifacts mkdir -p artifacts
cd build cd build
@ -501,9 +481,6 @@ jobs:
cpack -G ZIP cpack -G ZIP
mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos-experimental-archive.zip mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos-experimental-archive.zip
# move
mv Portfile ../artifacts/Portfile
- name: Upload Artifacts - name: Upload Artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
@ -519,104 +496,7 @@ jobs:
rm -f ./sunshine-macos-experimental-bundle.dmg rm -f ./sunshine-macos-experimental-bundle.dmg
rm -f ./sunshine-macos-experimental-archive.zip rm -f ./sunshine-macos-experimental-archive.zip
- name: Create Release # no artifacts to release currently
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_mac_port:
# name: Macports
# runs-on: macos-11
# needs: [check_changelog, build_mac]
#
# steps:
# - name: Cache Artifacts
# uses: actions/cache@v3
# with:
# path: artifacts
# key: ${{ runner.os }}-artifacts
#
# - name: Setup Macports
# run : |
# # update paths for macports
# echo "/opt/local/sbin" >> $GITHUB_PATH
# echo "/opt/local/bin" >> $GITHUB_PATH
#
# # Set OpenSSL 1.1 as default
# # rm -rf /usr/local/opt/openssl
# # rm -rf /usr/local/bin/openssl
# # ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o/bin/openssl /usr/local/bin/openssl
# # ln -sf /usr/local/Cellar/openssl@1.1/1.1.1o /usr/local/opt/openssl
#
# # download and extract macports
# curl -O https://distfiles.macports.org/MacPorts/MacPorts-2.7.2.tar.bz2
# tar xf MacPorts-2.7.2.tar.bz2
#
# # build macports
# cd MacPorts-2.7.2
# ./configure
# make
# sudo make install
# cd ../
# rm -rf MacPorts-2.7.2*
#
# - name: Configure Macports
# run: |
# # update sources
# sudo port -v selfupdate
#
# # use custom sources
# sudo chmod 777 /opt/local/etc/macports/sources.conf
# echo file://$(echo ~)/ports > /opt/local/etc/macports/sources.conf
# echo rsync://rsync.macports.org/macports/release/tarballs/ports.tar [default] >> /opt/local/etc/macports/sources.conf
# sudo chmod 644 /opt/local/etc/macports/sources.conf
#
# # setup custom port
# mkdir -p ~/ports/multimedia/sunshine
#
# # copy configured Portfile
# mv ./artifacts/Portfile ~/ports/multimedia/sunshine/
#
# # remove remaining cached artifacts
# rm -r -f ./artifacts
# mkdir artifacts
#
# # index the ports
# cd ~/ports
# portindex
#
# - name: Build
# run: |
# # build port
# sudo port install sunshine \
# || cat /opt/local/var/macports/logs/_Users_runner_ports_multimedia_sunshine/Sunshine/main.log \
# && exit 1
#
# # create packages
# sudo port dmg sunshine
# sudo port pkg sunshine
#
# # move
# mv $(port work sunshine)/Sunshine*.dmg ./artifacts/sunshine.dmg
# mv $(port work sunshine)/Sunshine*.ppkg ./artifacts/sunshine.pkg
#
# # testing only
# # ls ~/ports/multimedia/sunshine
# # cat ~/ports/multimedia/sunshine/Portfile
# # cat /opt/local/etc/macports/sources.conf
# # cat ~/ports/Portindex
# # port search sunshine
#
# - name: Upload Artifacts
# uses: actions/upload-artifact@v3
# with:
# name: sunshine-macports
# path: artifacts/
#
# - name: Create Release # - name: Create Release
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
# uses: SunshineStream/actions/create_release@master # uses: SunshineStream/actions/create_release@master
@ -626,6 +506,217 @@ jobs:
# last_version: ${{ needs.check_changelog.outputs.last_version }} # last_version: ${{ needs.check_changelog.outputs.last_version }}
# release_body: ${{ needs.check_changelog.outputs.release_body }} # release_body: ${{ needs.check_changelog.outputs.release_body }}
build_mac_port:
name: Macports
needs: check_changelog
runs-on: macos-11
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# os: [ macos-10.15, macos-11, macos-12 ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout ports
uses: actions/checkout@v3
with:
repository: macports/macports-ports
fetch-depth: 64
path: ports
- name: Checkout mpbb
uses: actions/checkout@v3
with:
repository: macports/mpbb
path: mpbb
- name: Setup Dependencies Macports
run: |
# install dependencies using homebrew
brew install cmake
- name: Configure Portfile
run: |
# variables for Portfile
branch=${GITHUB_HEAD_REF}
# check the branch variable
if [ -z "$branch" ]
then
echo "This is a PUSH event"
commit=${{ github.sha }}
clone_url=${{ github.event.repository.clone_url }}
else
echo "This is a PR event"
commit=${{ github.event.pull_request.head.sha }}
clone_url=${{ github.event.pull_request.head.repo.clone_url }}
fi
echo "Commit: ${commit}"
echo "Clone URL: ${clone_url}"
mkdir build
cd build
cmake -DGITHUB_COMMIT=${commit} -DGITHUB_CLONE_URL=${clone_url} -DSUNSHINE_CONFIGURE_PORTFILE=ON -DSUNSHINE_CONFIGURE_ONLY=ON ..
cd ..
# copy Portfile to artifacts
mkdir -p artifacts
cp -f ./build/Portfile ./artifacts/
# copy Portfile to ports
mkdir -p ./ports/multimedia/Sunshine
cp -f ./build/Portfile ./ports/multimedia/Sunshine/Portfile
# testing
cat ./artifacts/Portfile
- name: Bootstrap MacPorts
run: |
. ports/.github/workflows/bootstrap.sh
# Add getopt, mpbb and the MacPorts paths to $PATH for the subsequent steps.
echo "/opt/mports/bin" >> $GITHUB_PATH
echo "${PWD}/mpbb" >> $GITHUB_PATH
echo "/opt/local/bin" >> $GITHUB_PATH
echo "/opt/local/sbin" >> $GITHUB_PATH
- name: Determine list of subports
id: subportlist
run: |
set -eu
port=Sunshine
subportlist=""
echo "Listing subports for Sunshine"
new_subports=$(mpbb \
--work-dir /tmp/mpbb \
list-subports \
--archive-site= \
--archive-site-private= \
--include-deps=no \
"$port" \
| tr '\n' ' ')
for subport in $new_subports; do
echo "$subport"
subportlist="$subportlist $subport"
done
echo "::set-output name=subportlist::${subportlist}"
- name: Run port lint for all subports
run: |
set -eu
fail=0
for subport in $subportlist; do
echo "::group::${subport}"
path=$(port file "$subport")
messagetype="warning"
if ! messages=$(port -q lint "$subport" 2>&1); then
messagetype="error"
fail=1
fi
if [ -n "$messages" ]; then
echo "$messages"
# See https://github.com/actions/toolkit/issues/193#issuecomment-605394935
encoded_messages="port lint ${subport}:%0A"
encoded_messages+="$(echo "${messages}" | sed -E 's/$/%0A/g' | tr -d '\n')"
echo "::${messagetype} file=${path#${PWD}/ports/},line=1,col=1::${encoded_messages}"
fi
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
- name: Build subports
run: |
set -eu
fail=0
for subport in $subportlist; do
workdir="/tmp/mpbb/$subport"
mkdir -p "$workdir/logs"
touch "$workdir/logs/dependencies-progress.txt"
echo "::group::Cleaning up between ports"
sudo mpbb --work-dir "$workdir" cleanup
echo "::endgroup::"
echo "::group::Installing dependencies for ${subport}"
sudo mpbb \
--work-dir "$workdir" \
install-dependencies \
"$subport" >"$workdir/logs/install-dependencies.log" 2>&1 &
deps_pid=$!
tail -f "$workdir/logs/dependencies-progress.txt" 2>/dev/null &
tail_pid=$!
set +e
wait "$deps_pid"
deps_exit=$?
set -e
kill "$tail_pid" || true
if [ "$deps_exit" -ne 0 ]; then
echo "::endgroup::"
echo "::error::Failed to install dependencies for ${subport}"
fail=1
continue
fi
echo "::endgroup::"
echo "::group::Installing ${subport}"
set +e
sudo mpbb \
--work-dir "$workdir" \
install-port \
--source \
"$subport"
install_exit=$?
set -e
if [ "$install_exit" -ne 0 ]; then
echo "::endgroup::"
echo "::error::Failed to install ${subport}"
fail=1
continue
fi
echo "::endgroup::"
done
exit "$fail"
env:
subportlist: ${{ steps.subportlist.outputs.subportlist }}
- name: Package
run: |
# create packages
sudo port pkg sunshine
sudo port dmg sunshine
work=$(port work sunshine)
echo "Sunshine port work directory: ${work}"
# move components out of port work directory
sudo mv ${work}/Sunshine*component.pkg /tmp/
# copy artifacts
sudo mv ${work}/Sunshine*.pkg ./artifacts/sunshine.pkg
sudo mv ${work}/Sunshine*.dmg ./artifacts/sunshine.dmg
# move components back
# sudo mv /tmp/Sunshine*component.pkg ${work}/
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: sunshine-macports
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_win: build_win:
name: Windows name: Windows
runs-on: windows-2019 runs-on: windows-2019

View File

@ -5,10 +5,14 @@ project(Sunshine VERSION 0.14.0
HOMEPAGE_URL "https://sunshinestream.github.io" HOMEPAGE_URL "https://sunshinestream.github.io"
) )
set(PROJECT_LONG_DESCRIPTION "Sunshine is a self hosted, low latency, cloud gaming solution with support for AMD, \
Intel, and Nvidia GPUs. It is an open source implementation of NVIDIA's GameStream, as used by the NVIDIA Shield. \
Connect to Sunshine from any Moonlight client, available for nearly any device imaginable.")
option(SUNSHINE_CONFIGURE_APPIMAGE "Configure files required for AppImage." OFF) option(SUNSHINE_CONFIGURE_APPIMAGE "Configure files required for AppImage." OFF)
option(SUNSHINE_CONFIGURE_AUR "Configure files required for AUR." OFF) option(SUNSHINE_CONFIGURE_AUR "Configure files required for AUR." OFF)
option(SUNSHINE_CONFIGURE_FLATPAK "Configure files required for Flatpak." OFF) option(SUNSHINE_CONFIGURE_FLATPAK "Configure files required for Flatpak." OFF)
option(SUNSHINE_CONFIGURE_PORTFILE "Configure MacOS Portfile." OFF) option(SUNSHINE_CONFIGURE_PORTFILE "Configure macOS Portfile." OFF)
option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF) option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF)
if(${SUNSHINE_CONFIGURE_APPIMAGE}) if(${SUNSHINE_CONFIGURE_APPIMAGE})
@ -150,6 +154,9 @@ if(WIN32)
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess") set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp PROPERTIES COMPILE_FLAGS "-Wno-unknown-pragmas -Wno-misleading-indentation -Wno-class-memaccess")
elseif(APPLE) elseif(APPLE)
add_compile_definitions(SUNSHINE_PLATFORM="macos") add_compile_definitions(SUNSHINE_PLATFORM="macos")
option(SUNSHINE_MACOS_PACKAGE "Should only be used when creating a MACOS package/dmg." OFF)
link_directories(/opt/local/lib) link_directories(/opt/local/lib)
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK) ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
@ -559,57 +566,64 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
set(CPACK_COMPONENT_SUNSHINESVC_DESCRIPTION "CLI tool that allows you to enable/disable the Sunshine service.") set(CPACK_COMPONENT_SUNSHINESVC_DESCRIPTION "CLI tool that allows you to enable/disable the Sunshine service.")
set(CPACK_COMPONENT_SUNSHINESVC_GROUP "Tools") set(CPACK_COMPONENT_SUNSHINESVC_GROUP "Tools")
endif() endif()
if(UNIX) if(APPLE)
# Installation destination dir
set(CPACK_SET_DESTDIR true)
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local/sunshine")
endif()
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
endif()
if(APPLE) # TODO: test
set(prefix "${CMAKE_PROJECT_NAME}.app/Contents")
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(TARGETS sunshine
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR} COMPONENT Runtime)
# TODO: bundle doesn't produce a valid .app use cpack -G DragNDrop # TODO: bundle doesn't produce a valid .app use cpack -G DragNDrop
set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}") set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}")
set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns") set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns")
# set(CPACK_BUNDLE_STARTUP_COMMAND "${INSTALL_RUNTIME_DIR}/sunshine") # set(CPACK_BUNDLE_STARTUP_COMMAND "${INSTALL_RUNTIME_DIR}/sunshine")
endif() endif()
if(UNIX AND NOT APPLE) if(APPLE AND SUNSHINE_MACOS_PACKAGE) # TODO
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}") set(prefix "${CMAKE_PROJECT_NAME}.app/Contents")
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}") install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules" DESTINATION "${CMAKE_INSTALL_LIBDIR}/udev/rules.d") install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(TARGETS sunshine
BUNDLE DESTINATION . COMPONENT Runtime
RUNTIME DESTINATION ${INSTALL_RUNTIME_DIR} COMPONENT Runtime)
elseif(UNIX)
# Installation destination dir
set(CPACK_SET_DESTDIR true)
if(NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local/sunshine")
endif()
install(TARGETS sunshine RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") 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 install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
"${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/preinst;${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst;${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/conffiles")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/preinst")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst")
# Dependencies if(APPLE)
set(CPACK_DEB_COMPONENT_INSTALL ON) install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
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") install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
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 install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/misc/uninstall_pkg.sh" DESTINATION "${SUNSHINE_ASSETS_DIR}")
else()
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/85-sunshine.rules" DESTINATION "${CMAKE_INSTALL_LIBDIR}/udev/rules.d")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/user")
# Pre and post install
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/preinst"
"${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst"
"${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/conffiles")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/preinst")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/postinst")
# Dependencies
set(CPACK_DEB_COMPONENT_INSTALL ON)
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
endif()
endif() endif()
include(CPack) include(CPack)

View File

@ -6,19 +6,22 @@ SunshineStream has the full documentation hosted on `Read the Docs <http://sunsh
About About
----- -----
Sunshine is a Game stream host for Moonlight. It is an open source version of GeForce Experience (GFE). Sunshine is a Game stream host for Moonlight.
Sunshine is a self hosted, low latency, cloud gaming solution with support for AMD, Intel, and Nvidia gpus.
It is an open source implementation of NVIDIA's GameStream, as used by the NVIDIA Shield.
Connect to Sunshine from any Moonlight client, available for nearly any device imaginable.
These are the advantages of Sunshine over GFE. These are the advantages of Sunshine over GeForce Experience.
- FOSS (Free and Open Source Software) - FOSS (Free and Open Source Software)
- Multi-platform - Multi-platform
- Linux (deb, rpm, and AppImage packages) - Linux
- MacOS (Portfile) - macOS
- Windows (portable binary) - Windows
- Pair over web ui - Pair over web ui
- Supports AMD and Nvidia GPUs for encoding - Supports AMD, Intel, and Nvidia GPUs for encoding
- Supports software encoding - Supports software encoding
- Supports streaming to multiple clients - Supports streaming to multiple clients
- Web UI for configuration - Web UI for configuration

View File

@ -24,7 +24,7 @@ location by modifying the configuration file.
Linux-aur /usr/share/sunshine/config/ Linux-aur /usr/share/sunshine/config/
Linux-deb /usr/local/sunshine/config/ Linux-deb /usr/local/sunshine/config/
Linux-rpm /usr/local/sunshine/config/ Linux-rpm /usr/local/sunshine/config/
MacOS /usr/local/sunshine/config/ macOS /usr/local/sunshine/config/
Windows ./config/ Windows ./config/
========= =========== ========= ===========
@ -227,7 +227,7 @@ Description
To be supported by Sunshine, it needs to have at the very minimum: To be supported by Sunshine, it needs to have at the very minimum:
``VAProfileH264High : VAEntrypointEncSlice`` ``VAProfileH264High : VAEntrypointEncSlice``
.. Todo:: MacOS .. Todo:: macOS
Windows Windows
.. code-block:: batch .. code-block:: batch
@ -243,7 +243,7 @@ Examples
adapter_name = /dev/dri/renderD128 adapter_name = /dev/dri/renderD128
.. Todo:: MacOS .. Todo:: macOS
Windows Windows
.. code-block:: text .. code-block:: text
@ -267,7 +267,7 @@ Description
You need to use the value before the colon in the output, e.g. ``0``. You need to use the value before the colon in the output, e.g. ``0``.
.. Todo:: MacOS .. Todo:: macOS
Windows Windows
.. code-block:: batch .. code-block:: batch
@ -283,7 +283,7 @@ Examples
output_name = 0 output_name = 0
.. Todo:: MacOS .. Todo:: macOS
Windows Windows
.. code-block:: text .. code-block:: text
@ -378,8 +378,8 @@ Description
# in some causes you'd need to use the `Sink` device, if `Source` doesn't work, so try: # in some causes you'd need to use the `Sink` device, if `Source` doesn't work, so try:
pactl info | grep Sink pactl info | grep Sink
MacOS macOS
Sunshine can only access microphones on MacOS due to system limitations. To stream system audio use Sunshine can only access microphones on macOS due to system limitations. To stream system audio use
`Soundflower <https://github.com/mattingalls/Soundflower>`_ or `Soundflower <https://github.com/mattingalls/Soundflower>`_ or
`BlackHole <https://github.com/ExistentialAudio/BlackHole>`_. `BlackHole <https://github.com/ExistentialAudio/BlackHole>`_.
@ -397,7 +397,7 @@ Examples
audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo
MacOS macOS
.. code-block:: text .. code-block:: text
audio_sink = BlackHole 2ch audio_sink = BlackHole 2ch
@ -995,7 +995,7 @@ vt_software
Description Description
Force Video Toolbox to use software encoding. Force Video Toolbox to use software encoding.
.. Note:: This option only applies when using MacOS. .. Note:: This option only applies when using macOS.
**Choices** **Choices**
@ -1025,7 +1025,7 @@ vt_realtime
Description Description
Realtime encoding. Realtime encoding.
.. Note:: This option only applies when using MacOS. .. Note:: This option only applies when using macOS.
.. Warning:: Disabling realtime encoding might result in a delayed frame encoding or frame drop. .. Warning:: Disabling realtime encoding might result in a delayed frame encoding or frame drop.
@ -1043,7 +1043,7 @@ vt_coder
Description Description
The entropy encoding to use. The entropy encoding to use.
.. Note:: This option only applies when using MacOS. .. Note:: This option only applies when using macOS.
**Choices** **Choices**

View File

@ -9,8 +9,6 @@ Binaries
Binaries of Sunshine are created for each release. They are available for Linux, and Windows. Binaries of Sunshine are created for each release. They are available for Linux, and Windows.
Binaries can be found in the `latest release`_. Binaries can be found in the `latest release`_.
.. Todo:: Create binary package(s) for MacOS. See `here <https://github.com/SunshineStream/Sunshine/issues/61>`_.
.. Tip:: Some third party packages also exist. See .. Tip:: Some third party packages also exist. See
:ref:`Third Party Packages <about/third_party_packages:third party packages>`. :ref:`Third Party Packages <about/third_party_packages:third party packages>`.
@ -107,11 +105,16 @@ RPM Package
.. Tip:: You can double click the rpm file to see details about the package and begin installation. .. Tip:: You can double click the rpm file to see details about the package and begin installation.
MacOS macOS
----- -----
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/os:macos?logo=github&style=for-the-badge .. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/os:macos?logo=github&style=for-the-badge
:alt: GitHub issues by-label :alt: GitHub issues by-label
pkg
.. Warning:: The `pkg` does not include runtime dependencies and should be considered experimental.
#. Download the ``sunshine.pkg`` file and install it as normal.
Portfile Portfile
#. Install `MacPorts <https://www.macports.org>`_ #. Install `MacPorts <https://www.macports.org>`_
#. Update the Macports sources. #. Update the Macports sources.

View File

@ -27,7 +27,7 @@ Usage
list of applications that are started just before running a stream. This is the directory within the GitHub list of applications that are started just before running a stream. This is the directory within the GitHub
repo. repo.
.. Attention:: Application list is not fully supported on MacOS .. Attention:: Application list is not fully supported on macOS
#. In Moonlight, you may need to add the PC manually. #. In Moonlight, you may need to add the PC manually.
#. When Moonlight request you insert the correct pin on sunshine: #. When Moonlight request you insert the correct pin on sunshine:
@ -138,7 +138,7 @@ Sunshine needs access to `uinput` to create mouse and gamepad events.
sudo reboot now sudo reboot now
MacOS macOS
^^^^^ ^^^^^
Sunshine can only access microphones on macOS due to system limitations. To stream system audio use Sunshine can only access microphones on macOS due to system limitations. To stream system audio use
`Soundflower <https://github.com/mattingalls/Soundflower>`_ or `Soundflower <https://github.com/mattingalls/Soundflower>`_ or

View File

@ -22,7 +22,7 @@ Compile
See the section specific to your OS. See the section specific to your OS.
- :ref:`Linux <building/linux:linux>` - :ref:`Linux <building/linux:linux>`
- :ref:`MacOS <building/macos:macos>` - :ref:`macOS <building/macos:macos>`
- :ref:`Windows <building/windows:windows>` - :ref:`Windows <building/windows:windows>`
Remote Build Remote Build

View File

@ -1,11 +1,11 @@
:github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/building/macos.rst :github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/building/macos.rst
MacOS macOS
===== =====
Requirements Requirements
------------ ------------
MacOS Big Sur and Xcode 12.5+ macOS Big Sur and Xcode 12.5+
Use either `MacPorts <https://www.macports.org>`_ or `Homebrew <https://brew.sh>`_ Use either `MacPorts <https://www.macports.org>`_ or `Homebrew <https://brew.sh>`_
@ -35,7 +35,7 @@ Build
cmake .. cmake ..
make -j ${nproc} make -j ${nproc}
cpack -G DragNDrop # optionally, create a MacOS dmg package cpack -G DragNDrop # optionally, create a macOS dmg package
If cmake fails complaining to find Boost, try to set the path explicitly. If cmake fails complaining to find Boost, try to set the path explicitly.

View File

@ -1,6 +1,6 @@
:github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/troubleshooting/macos.rst :github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/troubleshooting/macos.rst
MacOS macOS
===== =====
If you get this error: If you get this error:
@ -12,3 +12,18 @@ If you get this error:
.. code-block:: bash .. code-block:: bash
launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist launchctl load -w /Library/LaunchAgents/org.freedesktop.dbus-session.plist
Uninstall:
- pkg
.. code-block:: bash
sudo chmod +x /opt/local/etc/sunshine/assets/uninstall_pkg.sh
sudo /opt/local/etc/sunshine/assets/uninstall_pkg.sh
- Portfile
.. code-block:: bash
sudo port uninstall Sunshine

View File

@ -1,26 +1,32 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4 # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# initial PR into macports: https://github.com/macports/macports-ports/pull/15143
PortSystem 1.0 PortSystem 1.0
PortGroup cmake 1.1 PortGroup cmake 1.1
PortGroup github 1.0 PortGroup github 1.0
PortGroup boost 1.0 PortGroup boost 1.0
# bump revision when changes are made to this file
revision 1
github.setup @GITHUB_OWNER@ @GITHUB_REPO@ @GITHUB_BRANCH@
name @PROJECT_NAME@ name @PROJECT_NAME@
version @PROJECT_VERSION@ version @PROJECT_VERSION@
revision 0
categories multimedia emulators games categories multimedia emulators games
platforms darwin platforms darwin
license GPL-3 license GPL-3
maintainers {@SunshineStream sunshinestream} maintainers @SunshineStream
description @PROJECT_DESCRIPTION@ description @PROJECT_DESCRIPTION@
long_description {*}${description}
homepage @PROJECT_HOMEPAGE_URL@
master_sites https://github.com/@GITHUB_OWNER@/@GITHUB_REPO@/releases
# long_description will not be split into multiple lines as it's configured by CMakeLists
long_description @PROJECT_LONG_DESCRIPTION@
homepage @PROJECT_HOMEPAGE_URL@
master_sites https://github.com/sunshinestream/sunshine/releases
compiler.cxx_standard 2017
fetch.type git fetch.type git
git.url @GITHUB_CLONE_URL@
git.branch @GITHUB_COMMIT@
post-fetch { post-fetch {
system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive" system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive"
} }
@ -31,11 +37,9 @@ depends_lib port:avahi \
boost.version 1.76 boost.version 1.76
configure.args -DBOOST_ROOT=[boost::install_area] \ configure.args -DCMAKE_INSTALL_PREFIX=${prefix} \
-DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine/assets \ -DSUNSHINE_ASSETS_DIR=etc/sunshine/assets \
-DSUNSHINE_CONFIG_DIR=${prefix}/etc/sunshine/config -DSUNSHINE_CONFIG_DIR=etc/sunshine/config
cmake.out_of_source yes
startupitem.create yes startupitem.create yes
startupitem.executable "${prefix}/bin/{$name}" startupitem.executable "${prefix}/bin/{$name}"
@ -43,33 +47,38 @@ startupitem.location LaunchDaemons
startupitem.name ${name} startupitem.name ${name}
startupitem.netchange yes startupitem.netchange yes
# is this actually necessary? this should all be handled by CMakeLists platform darwin {
destroot { if { ${os.major} < 20 } {
# install assets # See: https://github.com/SunshineStream/Sunshine/discussions/117#discussioncomment-2513494
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets notes-append "Port is limited to software encoding, when used with macOS releases prior to Big Sur."
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/*.*] ${destroot}${prefix}/etc/${name}/assets }
xinstall {*}[glob ${worksrcpath}/src_assets/macos/assets/*.*] ${destroot}${prefix}/etc/${name}/assets
# install web assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/*.*] ${destroot}${prefix}/etc/${name}/assets/web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/css/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/css
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/fonts/fontawesome-free-web/webfonts/*.*] ${destroot}${prefix}/etc/${name}/assets/web/fonts/fontawesome-free-web/webfonts
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets/web/third_party
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/images/*.*] ${destroot}${prefix}/etc/${name}/assets/web/images
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/web/third_party/*.*] ${destroot}${prefix}/etc/${name}/assets/web/third_party
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/config
# install sunshine.conf
xinstall {*}[glob ${worksrcpath}/src_assets/common/config/*.*] ${destroot}${prefix}/etc/${name}/config
# install apps.json
xinstall {*}[glob ${worksrcpath}/src_assets/macos/config/*.*] ${destroot}${prefix}/etc/${name}/config
# install the binary
xinstall ${workpath}/build/${name} ${destroot}${prefix}/bin
} }
# destroot not required as cmake install directive handles moving files
# # Rename files in `destroot`
# post-destroot {
# file rename ${destroot}${prefix}/etc/${name}/config/sunshine.conf ${destroot}${prefix}/etc/${name}/config/sunshine.conf.sample
# file rename ${destroot}${prefix}/etc/${name}/config/apps.json ${destroot}${prefix}/etc/${name}/config/apps.json.sample
# }
# # Don't overwrite existing preference files
# post-activate {
# if {![file exists ${prefix}/etc/${name}/config/sunshine.conf]} {
# file copy ${destroot}${prefix}/etc/${name}/config/sunshine.conf.sample \
# ${prefix}/etc/${name}/config/sunshine.conf
# }
# if {![file exists ${prefix}/etc/${name}/config/apps.json]} {
# file copy ${destroot}${prefix}/etc/${name}/config/apps.json.sample \
# ${prefix}/etc/${name}/config/apps.json
# }
# }
# disabled not overwriting config files... these are the default config files required by Sunshine
# this did not work with pkg created by macports
# we should always install the default files and user should start sunshine like "sunshine <path to user config file>"
# if the file doesn't exist sunshine will copy the default config to that location
notes-append "Run @PROJECT_NAME@ by executing 'sunshine <path to user config>', e.g. 'sunshine ~/sunshine.conf' "
notes-append "The config file will be created if it doesn't exist."
notes-append "It is recommended to set a location for the apps file in the config."
notes-append "See our documentation at 'https://sunshinestream.readthedocs.io/en/v@PROJECT_VERSION@/' for further info."

View File

@ -0,0 +1,68 @@
#!/bin/bash -e
set -e
package_name=org.macports.Sunshine
echo "Removing files now..."
FILES=$(pkgutil --files $package_name --only-files)
remove_config=True
remove_apps=True
for file in ${FILES}; do
file="/$file"
remove_current=True
if [[ $file == *sunshine.conf ]]; then
if [[ $remove_config == True ]]; then
while true; do
read -p -r "Do you wish to remove 'sunshine.conf'?" yn
case $yn in
[Yy]* ) echo "removing: $file"; rm -f "$file"; break;;
[Nn]* ) remove_config=False; remove_current=False; break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
fi
if [[ $file == *apps.json ]]; then
if [[ $remove_apps == True ]]; then
while true; do
read -p -r "Do you wish to remove 'apps.conf'?" yn
case $yn in
[Yy]* ) echo "removing: $file"; rm -f "$file"; break;;
[Nn]* ) remove_apps=False; remove_current=False; break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
fi
if [[ $remove_current == True ]]; then
echo "removing: $file"
rm -f "$file"
fi
done
echo "Removing directories now..."
DIRECTORIES=$(pkgutil --files org.macports.Sunshine --only-dirs)
for dir in ${DIRECTORIES}; do
dir="/$dir"
echo "Checking if empty directory: $dir"
# check if directory is empty... could just use ${DIRECTORIES} here if pkgutils added the `/` prefix
empty_dir=$(find "$dir" -depth 0 -type d -empty)
# remove the directory if it is empty
if [[ $empty_dir != "" ]]; then # prevent the loop from running and failing if no directories found
for i in "${empty_dir}"; do # don't split words as we already know this will be a single directory
echo "Removing empty directory: ${i}"
rmdir "${i}"
done
fi
done
echo "Forgetting Sunshine..."
pkgutil --forget $package_name
echo "Sunshine has been uninstalled..."

View File

@ -161,7 +161,7 @@ struct sink_t {
// Play on host PC // Play on host PC
std::string host; std::string host;
// On MacOS and Windows, it is not possible to create a virtual sink // On macOS and Windows, it is not possible to create a virtual sink
// Therefore, it is optional // Therefore, it is optional
struct null_t { struct null_t {
std::string stereo; std::string stereo;