Merge remote-tracking branch 'sunshine/master'

This commit is contained in:
Yukino Song
2025-09-27 00:37:24 +08:00
104 changed files with 3939 additions and 898 deletions

View File

@@ -47,6 +47,8 @@ function install() {
# user input rules
# shellcheck disable=SC2002
cat "$SUNSHINE_SHARE_HERE/udev/rules.d/60-sunshine.rules" | sudo tee /etc/udev/rules.d/60-sunshine.rules
cat "$SUNSHINE_SHARE_HERE/modules-load.d/60-sunshine.conf" | sudo tee /etc/modules-load.d/60-sunshine.conf
sudo modprobe uhid
sudo udevadm control --reload-rules
sudo udevadm trigger --property-match=DEVNAME=/dev/uinput
sudo udevadm trigger --property-match=DEVNAME=/dev/uhid
@@ -65,6 +67,9 @@ function remove() {
# remove input rules
sudo rm -f /etc/udev/rules.d/60-sunshine.rules
# remove uhid module loading config
sudo rm -f /etc/modules-load.d/60-sunshine.conf
# remove service
sudo rm -f ~/.config/systemd/user/sunshine.service
}

View File

@@ -1,6 +1,13 @@
# Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD
# Reference: https://wiki.archlinux.org/title/PKGBUILD
## options
: "${_run_unit_tests:=false}" # if set to true; unit tests will be executed post build; useful in CI
: "${_support_headless_testing:=false}"
: "${_use_cuda:=detect}" # nvenc
: "${_commit:=@GITHUB_COMMIT@}"
pkgname='sunshine'
pkgver=@PROJECT_VERSION@@SUNSHINE_SUB_VERSION@
pkgrel=1
@@ -33,6 +40,7 @@ depends=(
'openssl'
'opus'
'udev'
'which'
)
makedepends=(
@@ -40,7 +48,6 @@ makedepends=(
'appstream-glib'
'cmake'
'desktop-file-utils'
'cuda'
"gcc${_gcc_version}"
'git'
'make'
@@ -49,17 +56,45 @@ makedepends=(
)
optdepends=(
'cuda: Nvidia GPU encoding support'
'libva-mesa-driver: AMD GPU encoding support'
'xorg-server-xvfb: Virtual X server for headless testing'
)
provides=()
conflicts=()
source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=@GITHUB_COMMIT@")
source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=${_commit}")
sha256sums=('SKIP')
# Options Handling
if [[ "${_use_cuda::1}" == "d" ]] && pacman -Qi cuda &> /dev/null; then
_use_cuda=true
fi
if [[ "${_use_cuda::1}" == "t" ]]; then
optdepends+=(
'cuda: Nvidia GPU encoding support'
)
fi
if [[ "${_support_headless_testing::1}" == "t" ]]; then
optdepends+=(
'xorg-server-xvfb: Virtual X server for headless testing'
)
fi
# Ensure makedepends, checkdepends, optdepends are sorted
if [ -n "${makedepends+x}" ]; then
mapfile -t tmp_array < <(printf '%s\n' "${makedepends[@]}" | sort)
makedepends=("${tmp_array[@]}")
unset tmp_array
fi
if [ -n "${optdepends+x}" ]; then
mapfile -t tmp_array < <(printf '%s\n' "${optdepends[@]}" | sort)
optdepends=("${tmp_array[@]}")
unset tmp_array
fi
prepare() {
cd "$pkgname"
git submodule update --recursive --init
@@ -68,7 +103,7 @@ prepare() {
build() {
export BRANCH="@GITHUB_BRANCH@"
export BUILD_VERSION="@BUILD_VERSION@"
export COMMIT="@GITHUB_COMMIT@"
export COMMIT="${_commit}"
export CC="gcc-${_gcc_version}"
export CXX="g++-${_gcc_version}"
@@ -76,18 +111,41 @@ build() {
export CFLAGS="${CFLAGS/-Werror=format-security/}"
export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"
cmake \
-S "$pkgname" \
-B build \
-Wno-dev \
-D BUILD_DOCS=OFF \
-D BUILD_WERROR=ON \
-D CMAKE_INSTALL_PREFIX=/usr \
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
-D SUNSHINE_ASSETS_DIR="share/sunshine" \
-D SUNSHINE_PUBLISHER_NAME='LizardByte' \
-D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \
-D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
local _cmake_options=(
-S "$pkgname"
-B build
-Wno-dev
-D BUILD_DOCS=OFF
-D BUILD_WERROR=ON
-D CMAKE_INSTALL_PREFIX=/usr
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine
-D SUNSHINE_ASSETS_DIR="share/sunshine"
-D SUNSHINE_PUBLISHER_NAME='LizardByte'
-D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev'
-D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
)
if [[ "${_use_cuda::1}" != "t" ]]; then
_cmake_options+=(-DSUNSHINE_ENABLE_CUDA=OFF -DCUDA_FAIL_ON_MISSING=OFF)
else
# If cuda has just been installed, its variables will not be available in the environment
# therefore, set them manually to the expected values on Arch Linux
if [ -z "${CUDA_PATH:-}" ] && pacman -Qi cuda &> /dev/null; then
local _cuda_gcc_version
_cuda_gcc_version="$(LC_ALL=C pacman -Si cuda | grep -Pom1 '^Depends On\s*:.*\bgcc\K[0-9]+\b')"
export CUDA_PATH=/opt/cuda
export NVCC_CCBIN="/usr/bin/g++-${_cuda_gcc_version}"
fi
fi
if [[ "${_run_unit_tests::1}" != "t" ]]; then
_cmake_options+=(-DBUILD_TESTS=OFF)
fi
cmake "${_cmake_options[@]}"
appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
@@ -98,13 +156,19 @@ build() {
}
check() {
export CC="gcc-${_gcc_version}"
export CXX="g++-${_gcc_version}"
cd "${srcdir}/build"
./sunshine --version
cd "${srcdir}/build/tests"
./test_sunshine --gtest_color=yes
if [[ "${_run_unit_tests::1}" == "t" ]]; then
export CC="gcc-${_gcc_version}"
export CXX="g++-${_gcc_version}"
cd "${srcdir}/build/tests"
./test_sunshine --gtest_color=yes
fi
}
package() {
export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
make -C build install DESTDIR="$pkgdir"
}

View File

@@ -1,5 +1,5 @@
do_setcap() {
setcap cap_sys_admin+p $(readlink -f $(which sunshine))
setcap cap_sys_admin+p $(readlink -f usr/bin/sunshine)
}
do_udev_reload() {
@@ -13,10 +13,11 @@ do_udev_reload() {
post_install() {
do_setcap
do_udev_reload
modprobe uhid
}
post_upgrade() {
do_setcap
do_udev_reload
modprobe uhid
}

View File

@@ -56,22 +56,23 @@ BuildRequires: which
BuildRequires: xorg-x11-server-Xvfb
# Conditional BuildRequires for cuda-gcc based on Fedora version
%if 0%{?fedora} >= 40 && 0%{?fedora} <= 41
%if 0%{?fedora} <= 41
BuildRequires: gcc13
BuildRequires: gcc13-c++
%global gcc_version 13
%global cuda_version 12.6.3
%global cuda_build 560.35.05
%global cuda_version 12.9.1
%global cuda_build 575.57.08
%elif %{?fedora} >= 42
BuildRequires: gcc14
BuildRequires: gcc14-c++
%global gcc_version 14
%global cuda_version 12.8.1
%global cuda_build 570.124.06
%global cuda_version 12.9.1
%global cuda_build 575.57.08
%endif
%global cuda_dir %{_builddir}/cuda
Requires: libayatana-appindicator3 >= 0.5.3
Requires: libcap >= 2.22
Requires: libcurl >= 7.0
Requires: libdrm > 2.4.97
@@ -84,7 +85,7 @@ Requires: miniupnpc >= 2.2.4
Requires: numactl-libs >= 2.0.14
Requires: openssl >= 3.0.2
Requires: pulseaudio-libs >= 10.0
Requires: libayatana-appindicator3 >= 0.5.3
Requires: which >= 2.21
%description
Self-hosted game stream host for Moonlight.
@@ -171,7 +172,7 @@ function install_cuda() {
--backup \
--directory="%{cuda_dir}" \
--verbose \
< "%{_builddir}/Sunshine/packaging/linux/fedora/patches/f42/${architecture}/01-math_functions.patch"
< "%{_builddir}/Sunshine/packaging/linux/patches/${architecture}/01-math_functions.patch"
fi
}
@@ -210,15 +211,13 @@ xvfb-run ./tests/test_sunshine
cd %{_builddir}/Sunshine/build
%make_install
# Add modules-load configuration
# load the uhid module in initramfs even if it doesn't detect the module as being used during dracut
# which must be run every time a new kernel is installed
install -D -m 0644 /dev/stdin %{buildroot}/usr/lib/modules-load.d/uhid.conf <<EOF
uhid
EOF
%post
# Note: this is copied from the postinst script
# Load uhid (DS5 emulation)
echo "Loading uhid kernel module for DS5 emulation."
modprobe uhid
# Check if we're in an rpm-ostree environment
if [ ! -x "$(command -v rpm-ostree)" ]; then
echo "Not in an rpm-ostree environment, proceeding with post install steps."
@@ -238,10 +237,6 @@ else
echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes."
fi
%preun
# Remove modules-load configuration
rm -f /usr/lib/modules-load.d/uhid.conf
%files
# Executables
%caps(cap_sys_admin+p) %{_bindir}/sunshine
@@ -254,7 +249,7 @@ rm -f /usr/lib/modules-load.d/uhid.conf
%{_udevrulesdir}/*-sunshine.rules
# Modules-load configuration
%{_modulesloaddir}/uhid.conf
%{_modulesloaddir}/*-sunshine.conf
# Desktop entries
%{_datadir}/applications/*.desktop

View File

@@ -19,8 +19,8 @@
"only-arches": [
"x86_64"
],
"url": "https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.35.03_linux.run",
"sha256": "3729a89cb58f7ca6a46719cff110d6292aec7577585a8d71340f0dbac54fb237",
"url": "https://developer.download.nvidia.com/compute/cuda/12.9.1/local_installers/cuda_12.9.1_575.57.08_linux.run",
"sha256": "0f6d806ddd87230d2adbe8a6006a9d20144fdbda9de2d6acc677daa5d036417a",
"dest-filename": "cuda.run"
},
{
@@ -28,8 +28,8 @@
"only-arches": [
"aarch64"
],
"url": "https://developer.download.nvidia.com/compute/cuda/12.6.2/local_installers/cuda_12.6.2_560.35.03_linux_sbsa.run",
"sha256": "2249408848b705c18b9eadfb5161b52e4e36fcc5753647329cce93db141e5466",
"url": "https://developer.download.nvidia.com/compute/cuda/12.9.1/local_installers/cuda_12.9.1_575.57.08_linux_sbsa.run",
"sha256": "64f47ab791a76b6889702425e0755385f5fa216c5a9f061875c7deed5f08cdb6",
"dest-filename": "cuda.run"
}
]

View File

@@ -2,6 +2,7 @@
"name": "miniupnpc",
"buildsystem": "cmake-ninja",
"builddir": true,
"subdir": "miniupnpc",
"config-opts": [
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DUPNPC_BUILD_STATIC=OFF",
@@ -11,15 +12,16 @@
],
"sources": [
{
"url": "https://miniupnp.tuxfamily.org/files/miniupnpc-2.3.3.tar.gz",
"sha256": "d52a0afa614ad6c088cc9ddff1ae7d29c8c595ac5fdd321170a05f41e634bd1a",
"type": "git",
"url": "https://github.com/miniupnp/miniupnp.git",
"tag": "miniupnpc_2_3_3",
"commit": "bf4215a7574f88aa55859db9db00e3ae58cf42d6",
"x-checker-data": {
"type": "anitya",
"project-id": 1986,
"stable-only": true,
"url-template": "https://miniupnp.tuxfamily.org/files/miniupnpc-$version.tar.gz"
},
"type": "archive"
"tag-template": "miniupnpc_${version0}_${version1}_${version2}"
}
}
],
"cleanup": [

View File

@@ -6,6 +6,12 @@ cp "/app/share/sunshine/systemd/user/sunshine.service" "$HOME/.config/systemd/us
echo "Sunshine User Service has been installed."
echo "Use [systemctl --user enable sunshine] once to autostart Sunshine on login."
# Load uhid (DS5 emulation)
UHID=$(cat /app/share/sunshine/modules-load.d/60-sunshine.conf)
echo "Enabling DS5 emulation."
flatpak-spawn --host pkexec sh -c "echo '$UHID' > /etc/modules-load.d/60-sunshine.conf"
flatpak-spawn --host pkexec modprobe uhid
# Udev rule
UDEV=$(cat /app/share/sunshine/udev/rules.d/60-sunshine.rules)
echo "Configuring mouse permission."

View File

@@ -6,6 +6,7 @@ rm "$HOME/.config/systemd/user/sunshine.service"
systemctl --user daemon-reload
echo "Sunshine User Service has been removed."
# Udev rule
# Remove rules
flatpak-spawn --host pkexec sh -c "rm /etc/modules-load.d/60-sunshine.conf"
flatpak-spawn --host pkexec sh -c "rm /etc/udev/rules.d/60-sunshine.rules"
echo "Input rules removed. Restart computer to take effect."