Skip to content

Commit acd8e03

Browse files
authored
fix(sunshine): make cuda and unit tests optional (#52)
1 parent 9bdcdf0 commit acd8e03

File tree

7 files changed

+93
-31
lines changed

7 files changed

+93
-31
lines changed

.github/workflows/build-repo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
env:
2626
DISPLAY: ":1"
2727
CONTAINER_DIR: pkgbuilds
28+
_use_cuda: "true"
29+
_run_unit_tests: "true"
30+
_support_headless_testing: "true"
2831
strategy:
2932
fail-fast: false
3033
matrix:

.github/workflows/sync-aur.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ jobs:
121121
echo "Copying files from pacman-repo..."
122122
cp -r "../pkgbuilds/${PACKAGE}/." . # Copy all files including hidden ones (like .SRCINFO)
123123
124-
# copy .gitignore from workspace root
124+
# copy .gitignore-aur from workspace root
125125
cd "${GITHUB_WORKSPACE}"
126-
cp .gitignore "aur-${PACKAGE}/.gitignore"
126+
cp .gitignore-aur "aur-${PACKAGE}/.gitignore"
127127
128128
echo "Files copied successfully"
129129

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# ignore JetBrains IDE files
22
.idea/
3+
4+
# ignore build artifacts
5+
/pkgbuilds/*/*/
6+
/pkgbuilds/*/*.pkg.*

.gitignore-aur

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ignore build artifacts
2+
/*/
3+
/*.pkg.*

pkgbuilds/sunshine/.SRCINFO

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
pkgbase = sunshine
22
pkgdesc = Self-hosted game stream host for Moonlight
33
pkgver = 2025.628.4510
4-
pkgrel = 5
4+
pkgrel = 6
55
url = https://app.lizardbyte.dev/Sunshine
66
install = sunshine.install
77
arch = x86_64
@@ -10,8 +10,8 @@ pkgbase = sunshine
1010
makedepends = appstream
1111
makedepends = appstream-glib
1212
makedepends = cmake
13-
makedepends = desktop-file-utils
1413
makedepends = cuda
14+
makedepends = desktop-file-utils
1515
makedepends = gcc14
1616
makedepends = git
1717
makedepends = make
@@ -40,7 +40,6 @@ pkgbase = sunshine
4040
depends = which
4141
optdepends = cuda: Nvidia GPU encoding support
4242
optdepends = libva-mesa-driver: AMD GPU encoding support
43-
optdepends = xorg-server-xvfb: Virtual X server for headless testing
4443
source = sunshine::git+https://github.com/LizardByte/Sunshine.git#commit=65f14e1003f831e776c170621bd06d8292f65155
4544
sha256sums = SKIP
4645

pkgbuilds/sunshine/PKGBUILD

Lines changed: 78 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD
22
# Reference: https://wiki.archlinux.org/title/PKGBUILD
33

4+
## options
5+
: "${_run_unit_tests:=false}" # if set to true; unit tests will be executed post build; useful in CI
6+
: "${_support_headless_testing:=false}"
7+
: "${_use_cuda:=detect}" # nvenc
8+
9+
: "${_commit:=65f14e1003f831e776c170621bd06d8292f65155}"
10+
411
pkgname='sunshine'
512
pkgver=2025.628.4510
6-
pkgrel=5
13+
pkgrel=6
714
pkgdesc="Self-hosted game stream host for Moonlight"
815
arch=('x86_64' 'aarch64')
916
url=https://app.lizardbyte.dev/Sunshine
@@ -41,7 +48,6 @@ makedepends=(
4148
'appstream-glib'
4249
'cmake'
4350
'desktop-file-utils'
44-
'cuda'
4551
"gcc${_gcc_version}"
4652
'git'
4753
'make'
@@ -50,45 +56,87 @@ makedepends=(
5056
)
5157

5258
optdepends=(
53-
'cuda: Nvidia GPU encoding support'
5459
'libva-mesa-driver: AMD GPU encoding support'
55-
'xorg-server-xvfb: Virtual X server for headless testing'
5660
)
5761

5862
provides=()
5963
conflicts=()
6064

61-
source=("$pkgname::git+https://github.com/LizardByte/Sunshine.git#commit=65f14e1003f831e776c170621bd06d8292f65155")
65+
source=("$pkgname::git+https://github.com/LizardByte/Sunshine.git#commit=${_commit}")
6266
sha256sums=('SKIP')
6367

68+
# Options Handling
69+
if [[ "${_use_cuda::1}" == "d" ]] && pacman -Qi cuda &> /dev/null; then
70+
_use_cuda=true
71+
fi
72+
73+
if [[ "${_use_cuda::1}" == "t" ]]; then
74+
makedepends+=('cuda')
75+
optdepends+=(
76+
'cuda: Nvidia GPU encoding support'
77+
)
78+
fi
79+
80+
if [[ "${_support_headless_testing::1}" == "t" ]]; then
81+
optdepends+=(
82+
'xorg-server-xvfb: Virtual X server for headless testing'
83+
)
84+
fi
85+
86+
# Ensure makedepends, checkdepends, optdepends are sorted
87+
if [ -n "${makedepends+x}" ]; then
88+
mapfile -t tmp_array < <(printf '%s\n' "${makedepends[@]}" | sort)
89+
makedepends=("${tmp_array[@]}")
90+
unset tmp_array
91+
fi
92+
93+
if [ -n "${optdepends+x}" ]; then
94+
mapfile -t tmp_array < <(printf '%s\n' "${optdepends[@]}" | sort)
95+
optdepends=("${tmp_array[@]}")
96+
unset tmp_array
97+
fi
98+
6499
prepare() {
65100
cd "$pkgname"
66101
git submodule update --recursive --init
67102
}
68103

69104
build() {
70-
export BRANCH="master"
71-
export BUILD_VERSION="v2025.628.4510"
72-
export COMMIT="65f14e1003f831e776c170621bd06d8292f65155"
105+
export BRANCH="@GITHUB_BRANCH@"
106+
export BUILD_VERSION="@BUILD_VERSION@"
107+
export COMMIT="${_commit}"
73108

74109
export CC="gcc-${_gcc_version}"
75110
export CXX="g++-${_gcc_version}"
76111

77112
export CFLAGS="${CFLAGS/-Werror=format-security/}"
78113
export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"
79114

80-
cmake \
81-
-S "$pkgname" \
82-
-B build \
83-
-Wno-dev \
84-
-D BUILD_DOCS=OFF \
85-
-D BUILD_WERROR=ON \
86-
-D CMAKE_INSTALL_PREFIX=/usr \
87-
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
88-
-D SUNSHINE_ASSETS_DIR="share/sunshine" \
89-
-D SUNSHINE_PUBLISHER_NAME='LizardByte' \
90-
-D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \
91-
-D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
115+
export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
116+
117+
local _cmake_options=(
118+
-S "$pkgname"
119+
-B build
120+
-Wno-dev
121+
-D BUILD_DOCS=OFF
122+
-D BUILD_WERROR=ON
123+
-D CMAKE_INSTALL_PREFIX=/usr
124+
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine
125+
-D SUNSHINE_ASSETS_DIR="share/sunshine"
126+
-D SUNSHINE_PUBLISHER_NAME='LizardByte'
127+
-D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev'
128+
-D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
129+
)
130+
131+
if [[ "${_use_cuda::1}" != "t" ]]; then
132+
_cmake_options+=(-DSUNSHINE_ENABLE_CUDA=OFF -DCUDA_FAIL_ON_MISSING=OFF)
133+
fi
134+
135+
if [[ "${_run_unit_tests::1}" != "t" ]]; then
136+
_cmake_options+=(-DBUILD_TESTS=OFF)
137+
fi
138+
139+
cmake "${_cmake_options[@]}"
92140

93141
appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
94142
appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
@@ -99,13 +147,19 @@ build() {
99147
}
100148

101149
check() {
102-
export CC="gcc-${_gcc_version}"
103-
export CXX="g++-${_gcc_version}"
150+
cd "${srcdir}/build"
151+
./sunshine --version
152+
153+
if [[ "${_run_unit_tests::1}" == "t" ]]; then
154+
export CC="gcc-${_gcc_version}"
155+
export CXX="g++-${_gcc_version}"
104156

105-
cd "${srcdir}/build/tests"
106-
./test_sunshine --gtest_color=yes
157+
cd "${srcdir}/build/tests"
158+
./test_sunshine --gtest_color=yes
159+
fi
107160
}
108161

109162
package() {
163+
export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
110164
make -C build install DESTDIR="$pkgdir"
111165
}

pkgbuilds/sunshine/sunshine.install

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
do_setcap() {
2-
setcap cap_sys_admin+p $(readlink -f $(which sunshine))
2+
setcap cap_sys_admin+p $(readlink -f usr/bin/sunshine)
33
}
44

55
do_udev_reload() {
@@ -19,4 +19,3 @@ post_upgrade() {
1919
do_setcap
2020
do_udev_reload
2121
}
22-

0 commit comments

Comments
 (0)