fix(packaging/Arch): make cuda and unit tests optional (#4254)

This commit is contained in:
Andrew Moore
2025-09-14 12:11:32 +09:30
committed by GitHub
parent 25e1d415d2
commit 5490ca3a56
3 changed files with 81 additions and 23 deletions

View File

@@ -30,6 +30,11 @@ ENV BUILD_VERSION=${BUILD_VERSION}
ENV COMMIT=${COMMIT} ENV COMMIT=${COMMIT}
ENV CLONE_URL=${CLONE_URL} ENV CLONE_URL=${CLONE_URL}
# PKGBUILD options
ENV _use_cuda=true
ENV _run_unit_tests=true
ENV _support_headless_testing=true
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN <<_SETUP RUN <<_SETUP

View File

@@ -1,6 +1,13 @@
# Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD # Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD
# Reference: https://wiki.archlinux.org/title/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' pkgname='sunshine'
pkgver=@PROJECT_VERSION@@SUNSHINE_SUB_VERSION@ pkgver=@PROJECT_VERSION@@SUNSHINE_SUB_VERSION@
pkgrel=1 pkgrel=1
@@ -41,7 +48,6 @@ makedepends=(
'appstream-glib' 'appstream-glib'
'cmake' 'cmake'
'desktop-file-utils' 'desktop-file-utils'
'cuda'
"gcc${_gcc_version}" "gcc${_gcc_version}"
'git' 'git'
'make' 'make'
@@ -50,17 +56,46 @@ makedepends=(
) )
optdepends=( optdepends=(
'cuda: Nvidia GPU encoding support'
'libva-mesa-driver: AMD GPU encoding support' 'libva-mesa-driver: AMD GPU encoding support'
'xorg-server-xvfb: Virtual X server for headless testing'
) )
provides=() provides=()
conflicts=() conflicts=()
source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=@GITHUB_COMMIT@") source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=${_commit}")
sha256sums=('SKIP') 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
makedepends+=('cuda')
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() { prepare() {
cd "$pkgname" cd "$pkgname"
git submodule update --recursive --init git submodule update --recursive --init
@@ -69,7 +104,7 @@ prepare() {
build() { build() {
export BRANCH="@GITHUB_BRANCH@" export BRANCH="@GITHUB_BRANCH@"
export BUILD_VERSION="@BUILD_VERSION@" export BUILD_VERSION="@BUILD_VERSION@"
export COMMIT="@GITHUB_COMMIT@" export COMMIT="${_commit}"
export CC="gcc-${_gcc_version}" export CC="gcc-${_gcc_version}"
export CXX="g++-${_gcc_version}" export CXX="g++-${_gcc_version}"
@@ -77,18 +112,31 @@ build() {
export CFLAGS="${CFLAGS/-Werror=format-security/}" export CFLAGS="${CFLAGS/-Werror=format-security/}"
export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}" export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"
cmake \ export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
-S "$pkgname" \
-B build \ local _cmake_options=(
-Wno-dev \ -S "$pkgname"
-D BUILD_DOCS=OFF \ -B build
-D BUILD_WERROR=ON \ -Wno-dev
-D CMAKE_INSTALL_PREFIX=/usr \ -D BUILD_DOCS=OFF
-D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \ -D BUILD_WERROR=ON
-D SUNSHINE_ASSETS_DIR="share/sunshine" \ -D CMAKE_INSTALL_PREFIX=/usr
-D SUNSHINE_PUBLISHER_NAME='LizardByte' \ -D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine
-D SUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \ -D SUNSHINE_ASSETS_DIR="share/sunshine"
-D SUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' -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)
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" appstreamcli validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml" appstream-util validate "build/dev.lizardbyte.app.Sunshine.metainfo.xml"
@@ -99,13 +147,19 @@ build() {
} }
check() { check() {
export CC="gcc-${_gcc_version}" cd "${srcdir}/build"
export CXX="g++-${_gcc_version}" ./sunshine --version
cd "${srcdir}/build/tests" if [[ "${_run_unit_tests::1}" == "t" ]]; then
./test_sunshine --gtest_color=yes export CC="gcc-${_gcc_version}"
export CXX="g++-${_gcc_version}"
cd "${srcdir}/build/tests"
./test_sunshine --gtest_color=yes
fi
} }
package() { package() {
export MAKEFLAGS="${MAKEFLAGS:--j$(nproc)}"
make -C build install DESTDIR="$pkgdir" make -C build install DESTDIR="$pkgdir"
} }

View File

@@ -1,5 +1,5 @@
do_setcap() { do_setcap() {
setcap cap_sys_admin+p $(readlink -f $(which sunshine)) setcap cap_sys_admin+p $(readlink -f usr/bin/sunshine)
} }
do_udev_reload() { do_udev_reload() {
@@ -19,4 +19,3 @@ post_upgrade() {
do_setcap do_setcap
do_udev_reload do_udev_reload
} }