diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f8c1c8d9..a6ee7c3b 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,6 +9,17 @@ on: workflow_dispatch: 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: name: Check Changelog runs-on: ubuntu-latest @@ -440,13 +451,6 @@ jobs: with: 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 run: | # install dependencies using homebrew @@ -457,37 +461,13 @@ jobs: - name: Build MacOS 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 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} - name: Package MacOS run: | - # remove cached artifacts - rm -r -f ./artifacts - mkdir artifacts - mkdir -p artifacts cd build @@ -501,9 +481,6 @@ jobs: cpack -G ZIP mv ./cpack_artifacts/Sunshine.zip ../artifacts/sunshine-macos-experimental-archive.zip - # move - mv Portfile ../artifacts/Portfile - - name: Upload Artifacts uses: actions/upload-artifact@v3 with: @@ -519,104 +496,7 @@ jobs: rm -f ./sunshine-macos-experimental-bundle.dmg rm -f ./sunshine-macos-experimental-archive.zip - - 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_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/ -# + # no artifacts to release currently # - name: Create Release # if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} # uses: SunshineStream/actions/create_release@master @@ -626,6 +506,217 @@ jobs: # last_version: ${{ needs.check_changelog.outputs.last_version }} # 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: name: Windows runs-on: windows-2019 diff --git a/CMakeLists.txt b/CMakeLists.txt index 02ddfadb..d86a7d9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,10 +5,14 @@ project(Sunshine VERSION 0.14.0 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_AUR "Configure files required for AUR." 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) 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") elseif(APPLE) 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(/usr/local/lib) 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_GROUP "Tools") endif() -if(UNIX) - # 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) - +if(APPLE) # TODO: bundle doesn't produce a valid .app use cpack -G DragNDrop set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}") 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") endif() -if(UNIX AND NOT APPLE) - install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}") +if(APPLE AND SUNSHINE_MACOS_PACKAGE) # TODO + 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(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") + install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets/" DESTINATION "${SUNSHINE_ASSETS_DIR}") + install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config/" DESTINATION "${SUNSHINE_CONFIG_DIR}") - # 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 + if(APPLE) + 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(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() include(CPack) diff --git a/README.rst b/README.rst index bc2e01e0..eaf4b4a5 100644 --- a/README.rst +++ b/README.rst @@ -6,19 +6,22 @@ SunshineStream has the full documentation hosted on `Read the Docs `_ or `BlackHole `_. @@ -397,7 +397,7 @@ Examples audio_sink = alsa_output.pci-0000_09_00.3.analog-stereo - MacOS + macOS .. code-block:: text audio_sink = BlackHole 2ch @@ -995,7 +995,7 @@ vt_software Description Force Video Toolbox to use software encoding. - .. Note:: This option only applies when using MacOS. + .. Note:: This option only applies when using macOS. **Choices** @@ -1025,7 +1025,7 @@ vt_realtime Description 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. @@ -1043,7 +1043,7 @@ vt_coder Description The entropy encoding to use. - .. Note:: This option only applies when using MacOS. + .. Note:: This option only applies when using macOS. **Choices** diff --git a/docs/source/about/installation.rst b/docs/source/about/installation.rst index 6609b429..cbe5aca3 100644 --- a/docs/source/about/installation.rst +++ b/docs/source/about/installation.rst @@ -9,8 +9,6 @@ Binaries Binaries of Sunshine are created for each release. They are available for Linux, and Windows. Binaries can be found in the `latest release`_. -.. Todo:: Create binary package(s) for MacOS. See `here `_. - .. Tip:: Some third party packages also exist. See :ref:`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. -MacOS +macOS ----- .. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/os:macos?logo=github&style=for-the-badge :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 #. Install `MacPorts `_ #. Update the Macports sources. diff --git a/docs/source/about/usage.rst b/docs/source/about/usage.rst index a591cca5..da835bdf 100644 --- a/docs/source/about/usage.rst +++ b/docs/source/about/usage.rst @@ -27,7 +27,7 @@ Usage list of applications that are started just before running a stream. This is the directory within the GitHub 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. #. 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 -MacOS +macOS ^^^^^ Sunshine can only access microphones on macOS due to system limitations. To stream system audio use `Soundflower `_ or diff --git a/docs/source/building/build.rst b/docs/source/building/build.rst index cd83cb14..a703959d 100644 --- a/docs/source/building/build.rst +++ b/docs/source/building/build.rst @@ -22,7 +22,7 @@ Compile See the section specific to your OS. - :ref:`Linux ` -- :ref:`MacOS ` +- :ref:`macOS ` - :ref:`Windows ` Remote Build diff --git a/docs/source/building/macos.rst b/docs/source/building/macos.rst index 51ae6b15..d20a5517 100644 --- a/docs/source/building/macos.rst +++ b/docs/source/building/macos.rst @@ -1,11 +1,11 @@ :github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/building/macos.rst -MacOS +macOS ===== Requirements ------------ -MacOS Big Sur and Xcode 12.5+ +macOS Big Sur and Xcode 12.5+ Use either `MacPorts `_ or `Homebrew `_ @@ -35,7 +35,7 @@ Build cmake .. 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. diff --git a/docs/source/troubleshooting/macos.rst b/docs/source/troubleshooting/macos.rst index 18ea9361..5a6ae658 100644 --- a/docs/source/troubleshooting/macos.rst +++ b/docs/source/troubleshooting/macos.rst @@ -1,6 +1,6 @@ :github_url: https://github.com/SunshineStream/Sunshine/tree/nightly/docs/source/troubleshooting/macos.rst -MacOS +macOS ===== If you get this error: @@ -12,3 +12,18 @@ If you get this error: .. code-block:: bash 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 diff --git a/packaging/macos/Portfile b/packaging/macos/Portfile index 36a7d476..061027e9 100644 --- a/packaging/macos/Portfile +++ b/packaging/macos/Portfile @@ -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 +# initial PR into macports: https://github.com/macports/macports-ports/pull/15143 + PortSystem 1.0 PortGroup cmake 1.1 PortGroup github 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@ version @PROJECT_VERSION@ +revision 0 categories multimedia emulators games platforms darwin license GPL-3 -maintainers {@SunshineStream sunshinestream} +maintainers @SunshineStream 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 + +git.url @GITHUB_CLONE_URL@ +git.branch @GITHUB_COMMIT@ + post-fetch { system -W ${worksrcpath} "${git.cmd} submodule update --init --recursive" } @@ -31,11 +37,9 @@ depends_lib port:avahi \ boost.version 1.76 -configure.args -DBOOST_ROOT=[boost::install_area] \ - -DSUNSHINE_ASSETS_DIR=${prefix}/etc/sunshine/assets \ - -DSUNSHINE_CONFIG_DIR=${prefix}/etc/sunshine/config - -cmake.out_of_source yes +configure.args -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DSUNSHINE_ASSETS_DIR=etc/sunshine/assets \ + -DSUNSHINE_CONFIG_DIR=etc/sunshine/config startupitem.create yes startupitem.executable "${prefix}/bin/{$name}" @@ -43,33 +47,38 @@ startupitem.location LaunchDaemons startupitem.name ${name} startupitem.netchange yes -# is this actually necessary? this should all be handled by CMakeLists -destroot { - # install assets - xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/assets - 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 +platform darwin { + if { ${os.major} < 20 } { + # See: https://github.com/SunshineStream/Sunshine/discussions/117#discussioncomment-2513494 + notes-append "Port is limited to software encoding, when used with macOS releases prior to Big Sur." + } } + +# 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 " +# if the file doesn't exist sunshine will copy the default config to that location +notes-append "Run @PROJECT_NAME@ by executing 'sunshine ', 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." diff --git a/src_assets/macos/misc/uninstall_pkg.sh b/src_assets/macos/misc/uninstall_pkg.sh new file mode 100644 index 00000000..7e136109 --- /dev/null +++ b/src_assets/macos/misc/uninstall_pkg.sh @@ -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..." diff --git a/sunshine/platform/common.h b/sunshine/platform/common.h index 4d1588a3..ef9a2cf6 100644 --- a/sunshine/platform/common.h +++ b/sunshine/platform/common.h @@ -161,7 +161,7 @@ struct sink_t { // Play on host PC 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 struct null_t { std::string stereo;