From 756d2e19b2d8d67298dfd5068319e421a036909b Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Sun, 6 Oct 2024 19:09:20 -0400 Subject: [PATCH] build(fedora): fix version variables and skip post on rpm-ostree (#3265) --- .github/workflows/ci-copr.yml | 7 ++++- packaging/linux/fedora/sunshine.spec | 35 +++++++++++++++++++----- src_assets/linux/misc/postinst | 41 +++++++++++++++++++--------- 3 files changed, 62 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-copr.yml b/.github/workflows/ci-copr.yml index ba3d14ff788..782246f6aad 100644 --- a/.github/workflows/ci-copr.yml +++ b/.github/workflows/ci-copr.yml @@ -29,6 +29,8 @@ jobs: uses: actions/checkout@v4 - name: Get properties + env: + COPR_PR_WH_KEY: "05fc9b07-a19b-4f83-89b2-ae1e7e0b5282" run: | # package name = repository name package=${{ github.event.repository.name }} @@ -42,12 +44,15 @@ jobs: COPR_PUSH_WEBHOOK="${copr_base}/stable/${{ secrets.COPR_STABLE_WEBHOOK_TOKEN }}/${package}/" fi elif [ "${{ github.event_name }}" = "pull_request" ]; then - COPR_PR_WEBHOOK="${copr_base}/pulls:pr:${{github.event.number}}/${{vars.COPR_PR_WEBHOOK_TOKEN}}/${package}/" + COPR_PR_WEBHOOK="${copr_base}/pulls:pr:${{github.event.number}}/${{env.COPR_PR_WH_KEY}}/${package}/" fi echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}" >> $GITHUB_ENV echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}" >> $GITHUB_ENV + echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}" + echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}" + - name: Build run: | curl https://raw.githubusercontent.com/praiskup/copr-ci-tooling/main/copr-gh-actions-submit > submit diff --git a/packaging/linux/fedora/sunshine.spec b/packaging/linux/fedora/sunshine.spec index a56287e4bb5..e17e213bb36 100644 --- a/packaging/linux/fedora/sunshine.spec +++ b/packaging/linux/fedora/sunshine.spec @@ -147,7 +147,12 @@ function install_cuda() { local url="${cuda_prefix}${cuda_version}/local_installers/cuda_${cuda_version}_${cuda_build}_linux${cuda_suffix}.run" echo "cuda url: ${url}" - wget "$url" --progress=bar:force:noscroll -q -O "%{_builddir}/cuda.run" + wget \ + "$url" \ + --progress=bar:force:noscroll \ + --retry-connrefused \ + --tries=3 \ + -q -O "%{_builddir}/cuda.run" chmod a+x "%{_builddir}/cuda.run" "%{_builddir}/cuda.run" \ --no-drm \ @@ -173,6 +178,11 @@ if [ -n "$cuda_version" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${ar cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{_builddir}/cuda/bin/nvcc") fi +# setup the version +export BRANCH=%{branch} +export BUILD_VERSION=v%{build_version} +export COMMIT=%{commit} + # cmake cd %{_builddir}/Sunshine echo "cmake args:" @@ -198,12 +208,23 @@ EOF %post # Note: this is copied from the postinst script -# Trigger udev rule reload for /dev/uinput and /dev/uhid -path_to_udevadm=$(which udevadm) -if [ -x "$path_to_udevadm" ] ; then - $path_to_udevadm control --reload-rules - $path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput - $path_to_udevadm trigger --property-match=DEVNAME=/dev/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." + + # Trigger udev rule reload for /dev/uinput and /dev/uhid + path_to_udevadm=$(which udevadm) + if [ -x "$path_to_udevadm" ]; then + echo "Reloading udev rules." + $path_to_udevadm control --reload-rules + $path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput + $path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid + echo "Udev rules reloaded successfully." + else + echo "error: udevadm not found or not executable." + fi +else + echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes." fi %preun diff --git a/src_assets/linux/misc/postinst b/src_assets/linux/misc/postinst index 47deb784ce4..262dd8bce14 100644 --- a/src_assets/linux/misc/postinst +++ b/src_assets/linux/misc/postinst @@ -1,17 +1,32 @@ #!/bin/sh -# Ensure Sunshine can grab images from KMS -path_to_setcap=$(which setcap) -path_to_sunshine=$(readlink -f $(which sunshine)) -if [ -x "$path_to_setcap" ] ; then - echo "$path_to_setcap cap_sys_admin+p $path_to_sunshine" - $path_to_setcap cap_sys_admin+p $path_to_sunshine -fi +# 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." + + # Ensure Sunshine can grab images from KMS + path_to_setcap=$(which setcap) + path_to_sunshine=$(readlink -f "$(which sunshine)") + if [ -x "$path_to_setcap" ] ; then + echo "Setting CAP_SYS_ADMIN capability on Sunshine binary." + echo "$path_to_setcap cap_sys_admin+p $path_to_sunshine" + $path_to_setcap cap_sys_admin+p $path_to_sunshine + echo "CAP_SYS_ADMIN capability set on Sunshine binary." + else + echo "error: setcap not found or not executable." + fi -# Trigger udev rule reload for /dev/uinput and /dev/uhid -path_to_udevadm=$(which udevadm) -if [ -x "$path_to_udevadm" ] ; then - $path_to_udevadm control --reload-rules - $path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput - $path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid + # Trigger udev rule reload for /dev/uinput and /dev/uhid + path_to_udevadm=$(which udevadm) + if [ -x "$path_to_udevadm" ] ; then + echo "Reloading udev rules." + $path_to_udevadm control --reload-rules + $path_to_udevadm trigger --property-match=DEVNAME=/dev/uinput + $path_to_udevadm trigger --property-match=DEVNAME=/dev/uhid + echo "Udev rules reloaded successfully." + else + echo "error: udevadm not found or not executable." + fi +else + echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes." fi