diff --git a/.github/workflows/ci-copr.yml b/.github/workflows/ci-copr.yml new file mode 100644 index 00000000..ba3d14ff --- /dev/null +++ b/.github/workflows/ci-copr.yml @@ -0,0 +1,56 @@ +--- +name: CI Copr + +on: + pull_request: + branches: + - master + types: + - opened + - synchronize + - reopened + release: + types: + - prereleased + - released + workflow_dispatch: + +concurrency: + group: "${{ github.workflow }}-${{ github.ref }}" + cancel-in-progress: true + +jobs: + build: + name: Copr build + if: github.repository_owner == 'LizardByte' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get properties + run: | + # package name = repository name + package=${{ github.event.repository.name }} + copr_base="https://copr.fedorainfracloud.org/webhooks/custom-dir/lizardbyte" + + # release and released type + if [ "${{ github.event_name }}" = "release" ]; then + if [ "${{ github.event.action }}" = "prereleased" ]; then + COPR_PUSH_WEBHOOK="${copr_base}/beta/${{ secrets.COPR_BETA_WEBHOOK_TOKEN }}/${package}/" + elif [ "${{ github.event.action }}" = "released" ]; then + 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}/" + fi + + echo "COPR_PUSH_WEBHOOK=${COPR_PUSH_WEBHOOK}" >> $GITHUB_ENV + echo "COPR_PR_WEBHOOK=${COPR_PR_WEBHOOK}" >> $GITHUB_ENV + + - name: Build + run: | + curl https://raw.githubusercontent.com/praiskup/copr-ci-tooling/main/copr-gh-actions-submit > submit + + # if a PR number is added the script will use the PR webhook, otherwise it will use the push webhook + bash submit ${{ github.event.pull_request.number }} diff --git a/.github/workflows/update-flathub-repo.yml b/.github/workflows/update-flathub-repo.yml index 15580f23..b3e326c9 100644 --- a/.github/workflows/update-flathub-repo.yml +++ b/.github/workflows/update-flathub-repo.yml @@ -180,7 +180,7 @@ jobs: with: path: "flathub/${{ env.FLATHUB_PKG }}" token: ${{ secrets.GH_BOT_TOKEN }} - commit-message: Update ${{ env.FLATHUB_PKG }} to ${{ github.event.release.tag_name }} + commit-message: "chore: Update ${{ env.FLATHUB_PKG }} to ${{ github.event.release.tag_name }}" branch: bot/bump-${{ env.FLATHUB_PKG }}-${{ github.event.release.tag_name }} delete-branch: true title: "chore: Update ${{ env.FLATHUB_PKG }} to ${{ github.event.release.tag_name }}" diff --git a/.github/workflows/update-pacman-repo.yml b/.github/workflows/update-pacman-repo.yml index c95f7cda..92e14dc7 100644 --- a/.github/workflows/update-pacman-repo.yml +++ b/.github/workflows/update-pacman-repo.yml @@ -70,7 +70,7 @@ jobs: steps.check-label.outputs.hasTopic == 'true' && steps.check-release.outputs.isLatestRelease == 'true' run: | - echo "pkg_name=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT + echo "pkg_name=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT - name: Download release asset id: download @@ -97,7 +97,7 @@ jobs: add-paths: | pkgbuilds/* token: ${{ secrets.GH_BOT_TOKEN }} - commit-message: Update ${{ github.repository }} to ${{ github.event.release.tag_name }} + commit-message: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}" branch: bot/bump-${{ github.repository }}-${{ github.event.release.tag_name }} delete-branch: true title: "chore: Update ${{ github.repository }} to ${{ github.event.release.tag_name }}" diff --git a/DOCKER_README.md b/DOCKER_README.md index 0d9d1f4c..cbe977a3 100644 --- a/DOCKER_README.md +++ b/DOCKER_README.md @@ -26,8 +26,6 @@ Sunshine images are available with the following tag suffixes, based on their re - `archlinux` - `debian-bookworm` -- `fedora-39` -- `fedora-40` - `ubuntu-22.04` - `ubuntu-24.04` @@ -157,8 +155,6 @@ The architectures supported by these images are shown in the table below. |-----------------|--------------|---------------| | archlinux | ✅ | ❌ | | debian-bookworm | ✅ | ✅ | -| fedora-39 | ✅ | ❌ | -| fedora-40 | ✅ | ❌ | | ubuntu-22.04 | ✅ | ✅ | | ubuntu-24.04 | ✅ | ✅ | diff --git a/docker/fedora-39.dockerfile b/docker/fedora-39.dockerfile deleted file mode 100644 index 579eec9e..00000000 --- a/docker/fedora-39.dockerfile +++ /dev/null @@ -1,104 +0,0 @@ -# syntax=docker/dockerfile:1 -# artifacts: true -# platforms: linux/amd64 -# platforms_pr: linux/amd64 -# no-cache-filters: sunshine-base,artifacts,sunshine -ARG BASE=fedora -ARG TAG=39 -FROM ${BASE}:${TAG} AS sunshine-base - -FROM sunshine-base AS sunshine-build - -ARG BRANCH -ARG BUILD_VERSION -ARG COMMIT -# note: BUILD_VERSION may be blank - -ENV BRANCH=${BRANCH} -ENV BUILD_VERSION=${BUILD_VERSION} -ENV COMMIT=${COMMIT} - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# copy repository -WORKDIR /build/sunshine/ -COPY --link .. . - -# cmake and cpack -RUN <<_BUILD -#!/bin/bash -set -e -chmod +x ./scripts/linux_build.sh -./scripts/linux_build.sh \ - --publisher-name='LizardByte' \ - --publisher-website='https://app.lizardbyte.dev' \ - --publisher-issue-url='https://app.lizardbyte.dev/support' \ - --sudo-off -dnf clean all -rm -rf /var/cache/yum -_BUILD - -# run tests -WORKDIR /build/sunshine/build/tests -# hadolint ignore=SC1091 -RUN <<_TEST -#!/bin/bash -set -e -export DISPLAY=:1 -Xvfb ${DISPLAY} -screen 0 1024x768x24 & -./test_sunshine --gtest_color=yes -_TEST - -FROM scratch AS artifacts -ARG BASE -ARG TAG -ARG TARGETARCH -COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.rpm /sunshine-${BASE}-${TAG}-${TARGETARCH}.rpm - -FROM sunshine-base AS sunshine - -# copy deb from builder -COPY --link --from=artifacts /sunshine*.rpm /sunshine.rpm - -# install sunshine -RUN <<_INSTALL_SUNSHINE -#!/bin/bash -set -e -dnf -y update -dnf -y install /sunshine.rpm -dnf clean all -rm -rf /var/cache/yum -_INSTALL_SUNSHINE - -# network setup -EXPOSE 47984-47990/tcp -EXPOSE 48010 -EXPOSE 47998-48000/udp - -# setup user -ARG PGID=1000 -ENV PGID=${PGID} -ARG PUID=1000 -ENV PUID=${PUID} -ENV TZ="UTC" -ARG UNAME=lizard -ENV UNAME=${UNAME} - -ENV HOME=/home/$UNAME - -# setup user -RUN <<_SETUP_USER -#!/bin/bash -set -e -groupadd -f -g "${PGID}" "${UNAME}" -useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}" -mkdir -p ${HOME}/.config/sunshine -ln -s ${HOME}/.config/sunshine /config -chown -R ${UNAME} ${HOME} -_SETUP_USER - -USER ${UNAME} -WORKDIR ${HOME} - -# entrypoint -ENTRYPOINT ["/usr/bin/sunshine"] diff --git a/docker/fedora-40.dockerfile b/docker/fedora-40.dockerfile deleted file mode 100644 index fc6362d4..00000000 --- a/docker/fedora-40.dockerfile +++ /dev/null @@ -1,104 +0,0 @@ -# syntax=docker/dockerfile:1 -# artifacts: true -# platforms: linux/amd64 -# platforms_pr: linux/amd64 -# no-cache-filters: sunshine-base,artifacts,sunshine -ARG BASE=fedora -ARG TAG=40 -FROM ${BASE}:${TAG} AS sunshine-base - -FROM sunshine-base AS sunshine-build - -ARG BRANCH -ARG BUILD_VERSION -ARG COMMIT -# note: BUILD_VERSION may be blank - -ENV BRANCH=${BRANCH} -ENV BUILD_VERSION=${BUILD_VERSION} -ENV COMMIT=${COMMIT} - -SHELL ["/bin/bash", "-o", "pipefail", "-c"] - -# copy repository -WORKDIR /build/sunshine/ -COPY --link .. . - -# cmake and cpack -RUN <<_BUILD -#!/bin/bash -set -e -chmod +x ./scripts/linux_build.sh -./scripts/linux_build.sh \ - --publisher-name='LizardByte' \ - --publisher-website='https://app.lizardbyte.dev' \ - --publisher-issue-url='https://app.lizardbyte.dev/support' \ - --sudo-off -dnf clean all -rm -rf /var/cache/yum -_BUILD - -# run tests -WORKDIR /build/sunshine/build/tests -# hadolint ignore=SC1091 -RUN <<_TEST -#!/bin/bash -set -e -export DISPLAY=:1 -Xvfb ${DISPLAY} -screen 0 1024x768x24 & -./test_sunshine --gtest_color=yes -_TEST - -FROM scratch AS artifacts -ARG BASE -ARG TAG -ARG TARGETARCH -COPY --link --from=sunshine-build /build/sunshine/build/cpack_artifacts/Sunshine.rpm /sunshine-${BASE}-${TAG}-${TARGETARCH}.rpm - -FROM sunshine-base AS sunshine - -# copy deb from builder -COPY --link --from=artifacts /sunshine*.rpm /sunshine.rpm - -# install sunshine -RUN <<_INSTALL_SUNSHINE -#!/bin/bash -set -e -dnf -y update -dnf -y install /sunshine.rpm -dnf clean all -rm -rf /var/cache/yum -_INSTALL_SUNSHINE - -# network setup -EXPOSE 47984-47990/tcp -EXPOSE 48010 -EXPOSE 47998-48000/udp - -# setup user -ARG PGID=1000 -ENV PGID=${PGID} -ARG PUID=1000 -ENV PUID=${PUID} -ENV TZ="UTC" -ARG UNAME=lizard -ENV UNAME=${UNAME} - -ENV HOME=/home/$UNAME - -# setup user -RUN <<_SETUP_USER -#!/bin/bash -set -e -groupadd -f -g "${PGID}" "${UNAME}" -useradd -lm -d ${HOME} -s /bin/bash -g "${PGID}" -u "${PUID}" "${UNAME}" -mkdir -p ${HOME}/.config/sunshine -ln -s ${HOME}/.config/sunshine /config -chown -R ${UNAME} ${HOME} -_SETUP_USER - -USER ${UNAME} -WORKDIR ${HOME} - -# entrypoint -ENTRYPOINT ["/usr/bin/sunshine"] diff --git a/docs/getting_started.md b/docs/getting_started.md index 534aa5f2..02de66e3 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -54,28 +54,21 @@ CUDA is used for NVFBC capture. 12.0.0 - 525.60.13 + 525.60.13 50;52;60;61;62;70;72;75;80;86;87;89;90 sunshine-debian-bookworm-{arch}.deb - - 12.4.0 - sunshine-fedora-39-{arch}.rpm - 12.5.1 sunshine.pkg.tar.zst - 12.6.2 - 560.35.03 + 12.6.2 + 560.35.03 sunshine_{arch}.flatpak - n/a - n/a - n/a - sunshine-fedora-40-{arch}.rpm + Sunshine (copr) @@ -165,26 +158,27 @@ sudo apt remove sunshine ``` #### Fedora +@tip{The package name is case-sensitive.} + ##### Install -1. Add `rpmfusion` repositories. +1. Enable copr repository. ```bash - sudo dnf install \ - https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ - https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm - ``` -2. Download `sunshine-{distro}-{distro-version}-{arch}.rpm` and run the following command. - ```bash - sudo dnf install ./sunshine-{distro}-{distro-version}-{arch}.rpm + sudo dnf copr enable lizardbyte/stable ``` -@note{The `{distro-version}` is the version of the distro we built the package on. The `{arch}` is the -architecture of your operating system.} + or + ```bash + sudo dnf copr enable lizardbyte/beta + ``` -@tip{You can double-click the rpm file to see details about the package and begin installation.} +2. Install the package. + ```bash + sudo dnf install Sunshine + ``` ##### Uninstall ```bash -sudo dnf remove sunshine +sudo dnf remove Sunshine ``` #### Flatpak diff --git a/packaging/linux/fedora/copr-build.sh b/packaging/linux/fedora/copr-build.sh new file mode 100644 index 00000000..3aa8bb83 --- /dev/null +++ b/packaging/linux/fedora/copr-build.sh @@ -0,0 +1,62 @@ +#! /bin/sh -x + +# This file is not used directly in this repository. It should be uploaded to Copr whenever the file changes. +# Replicate to each package in "pulls", "beta", and "stable" Copr repositories + +set -e +resultdir="${COPR_RESULTDIR}" +git clone "https://github.com/${COPR_OWNER}/${COPR_PACKAGE}.git" --depth 1 +cd "${COPR_PACKAGE}" + +# optional part; drop if building against 'master' is enough +if test -z "$REVISION"; then + # the hook_payload file contains webhook JSON payload (copr creates it for + # us); it is created only if the build is triggered by Custom webhook. + if test -f "$resultdir"/hook_payload; then + git clone https://github.com/praiskup/copr-ci-tooling \ + "$resultdir/cct" --depth 1 + export PATH="$resultdir/cct:$PATH" + + echo "---" + cat "$resultdir"/hook_payload + echo "---" + + # use jq to get the pr_id from the hook_payload + PR=$(jq -r '.pr_id' "$resultdir"/hook_payload) + if [ -z "$PR" ]; then + BRANCH="master" + else + BRANCH="pr/${PR}" + fi + + copr-travis-checkout "$resultdir"/hook_payload + fi +else + git checkout "$REVISION" +fi + +# initialize the submodules +git submodule update --init --recursive + +# get the tag of this commit IF it has one +TAG=$(git tag --points-at HEAD | head -n1) +if [ -z "$TAG" ]; then + TAG="0.0.$PR" +fi +TAG=$(echo "$TAG" | sed 's/^v//') # remove v prefix from the tag +echo "TAG=$TAG" + +# get the commit +COMMIT=$(git rev-parse HEAD) +echo "COMMIT=$COMMIT" + +# move spec file to the correct location +mv packaging/linux/fedora/*.spec "${resultdir}" + +# use sed to replace these values in the spec file +sed -i "s|%global build_version 0|%global build_version ${TAG}|" "${resultdir}"/*.spec +sed -i "s|%global branch 0|%global branch ${BRANCH}|" "${resultdir}"/*.spec +sed -i "s|%global commit 0|%global commit ${COMMIT}|" "${resultdir}"/*.spec + +# create a tarball of the source code +tar -czf "${resultdir}/tarball.tar.gz" . diff --git a/packaging/linux/fedora/sunshine.spec b/packaging/linux/fedora/sunshine.spec new file mode 100644 index 00000000..a56287e4 --- /dev/null +++ b/packaging/linux/fedora/sunshine.spec @@ -0,0 +1,240 @@ +%global build_timestamp %(date +"%Y%m%d") + +# use sed to replace these values +%global build_version 0 +%global branch 0 +%global commit 0 + +%undefine _hardened_build + +Name: Sunshine +Version: %{build_version} +Summary: Self-hosted game stream host for Moonlight. +Release: 1%{?dist} +License: GPLv3-only +URL: https://github.com/LizardByte/Sunshine +Source0: tarball.tar.gz + +# BuildRequires: boost-devel >= 1.86.0 +BuildRequires: cmake >= 3.25.0 +BuildRequires: gcc +BuildRequires: gcc-c++ +BuildRequires: libayatana-appindicator3-devel +BuildRequires: libcap-devel +BuildRequires: libcurl-devel +BuildRequires: libdrm-devel +BuildRequires: libevdev-devel +BuildRequires: libgudev +BuildRequires: libnotify-devel +BuildRequires: libva-devel +BuildRequires: libvdpau-devel +BuildRequires: libX11-devel +BuildRequires: libxcb-devel +BuildRequires: libXcursor-devel +BuildRequires: libXfixes-devel +BuildRequires: libXi-devel +BuildRequires: libXinerama-devel +BuildRequires: libXrandr-devel +BuildRequires: libXtst-devel +BuildRequires: git +BuildRequires: mesa-libGL-devel +BuildRequires: miniupnpc-devel +BuildRequires: npm +BuildRequires: numactl-devel +BuildRequires: openssl-devel +BuildRequires: opus-devel +BuildRequires: pulseaudio-libs-devel +BuildRequires: rpm-build +BuildRequires: systemd-udev +BuildRequires: systemd-rpm-macros +%{?sysusers_requires_compat} +BuildRequires: wget +BuildRequires: which + +# for unit tests +BuildRequires: xorg-x11-server-Xvfb + +# Conditional BuildRequires for cuda-gcc based on Fedora version +%if 0%{?fedora} >= 40 +# this package conflicts with gcc on f39 +BuildRequires: cuda-gcc-c++ +%endif + +Requires: libcap >= 2.22 +Requires: libcurl >= 7.0 +Requires: libdrm > 2.4.97 +Requires: libevdev >= 1.5.6 +Requires: libopusenc >= 0.2.1 +Requires: libva >= 2.14.0 +Requires: libvdpau >= 1.5 +Requires: libwayland-client >= 1.20.0 +Requires: libX11 >= 1.7.3.1 +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 + +%description +Self-hosted game stream host for Moonlight. + +%prep +# extract tarball to current directory +mkdir -p %{_builddir}/Sunshine +tar -xzf %{SOURCE0} -C %{_builddir}/Sunshine + +# list directory +ls -a %{_builddir}/Sunshine + +# patches +%autopatch -p1 + +%build +# Detect the architecture and Fedora version +architecture=$(uname -m) +fedora_version=%{fedora} + +cuda_supported_architectures=("x86_64" "aarch64") + +# set cuda_version based on Fedora version +# these are the same right now, but leave this structure to make it easier to set different versions +if [ "$fedora_version" == 39 ]; then + cuda_version="12.6.2" + cuda_build="560.35.03" +else + cuda_version="12.6.2" + cuda_build="560.35.03" +fi + +# prepare CMAKE args +cmake_args=( + "-B=%{_builddir}/Sunshine/build" + "-G=Unix Makefiles" + "-S=." + "-DBUILD_DOCS=OFF" + "-DBUILD_WERROR=ON" + "-DCMAKE_BUILD_TYPE=Release" + "-DCMAKE_INSTALL_PREFIX=%{_prefix}" + "-DSUNSHINE_ASSETS_DIR=%{_datadir}/sunshine" + "-DSUNSHINE_EXECUTABLE_PATH=%{_bindir}/sunshine" + "-DSUNSHINE_ENABLE_WAYLAND=ON" + "-DSUNSHINE_ENABLE_X11=ON" + "-DSUNSHINE_ENABLE_DRM=ON" + "-DSUNSHINE_PUBLISHER_NAME=LizardByte" + "-DSUNSHINE_PUBLISHER_WEBSITE=https://app.lizardbyte.dev" + "-DSUNSHINE_PUBLISHER_ISSUE_URL=https://app.lizardbyte.dev/support" +) + +function install_cuda() { + # check if we need to install cuda + if [ -f "%{_builddir}/cuda/bin/nvcc" ]; then + echo "cuda already installed" + return + fi + + if [ "$fedora_version" -ge 40 ]; then + # update environment variables for CUDA, necessary when using cuda-gcc-c++ + export NVCC_PREPEND_FLAGS='-ccbin /usr/bin/cuda' + export PATH=/usr/bin/cuda:"%{_builddir}/cuda/bin:${PATH}" + export LD_LIBRARY_PATH="%{_builddir}/cuda/lib64:${LD_LIBRARY_PATH}" + fi + + local cuda_prefix="https://developer.download.nvidia.com/compute/cuda/" + local cuda_suffix="" + if [ "$architecture" == "aarch64" ]; then + local cuda_suffix="_sbsa" + fi + + 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" + chmod a+x "%{_builddir}/cuda.run" + "%{_builddir}/cuda.run" \ + --no-drm \ + --no-man-page \ + --no-opengl-libs \ + --override \ + --silent \ + --toolkit \ + --toolkitpath="%{_builddir}/cuda" + rm "%{_builddir}/cuda.run" +} + +# we need to clear these flags to avoid linkage errors with cuda-gcc-c++ +export CFLAGS="" +export CXXFLAGS="" +export FFLAGS="" +export FCFLAGS="" +export LDFLAGS="" + +if [ -n "$cuda_version" ] && [[ " ${cuda_supported_architectures[@]} " =~ " ${architecture} " ]]; then + install_cuda + cmake_args+=("-DSUNSHINE_ENABLE_CUDA=ON") + cmake_args+=("-DCMAKE_CUDA_COMPILER:PATH=%{_builddir}/cuda/bin/nvcc") +fi + +# cmake +cd %{_builddir}/Sunshine +echo "cmake args:" +echo "${cmake_args[@]}" +cmake "${cmake_args[@]}" +make -j$(nproc) -C "%{_builddir}/Sunshine/build" + +%check +# run tests +cd %{_builddir}/Sunshine/build +xvfb-run ./tests/test_sunshine + +%install +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 <