mirror of
https://github.com/LizardByte/Sunshine.git
synced 2024-11-17 08:09:50 +00:00
a6921fffad
- Add gen-rpm - Package rpm in CI testing and releases - Remove fedora 33 from testing (end of life) - Update arguments for `build_private.sh` and `build_sunshine.sh` Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
180 lines
5.4 KiB
Bash
Executable File
180 lines
5.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Export filepaths
|
|
export BUILDDIR=@CMAKE_CURRENT_SOURCE_DIR@/build
|
|
export BUILDROOT=~/rpmbuild/
|
|
export RPMSRC=~/rpmbuild/SOURCES
|
|
export RPMSPEC=~/rpmbuild/SPECS
|
|
export RPMBUILD=~/rpmbuild/BUILD
|
|
|
|
# Check for Docker switch
|
|
if [ "$1" == "-d" ]; then
|
|
export DOCKERSTATUS=TRUE
|
|
else
|
|
export DOCKERSTATUS=FALSE
|
|
fi
|
|
|
|
# Check if user's rpmbuild folder is there, if so, temoprairly rename it.
|
|
if [ -d ~/rpmbuild ]; then
|
|
echo "Backing up rpmbuild"
|
|
~/rpmbuild ~/rpmbuild.bkp
|
|
export RPMBUILDEXISTS=TRUE
|
|
else
|
|
export RPMBUILDEXISTS=FALSE
|
|
fi
|
|
|
|
# Create rpmbuild folder structure
|
|
mkdir ~/rpmbuild
|
|
mkdir ~/rpmbuild/BUILD
|
|
mkdir ~/rpmbuild/BUILDROOT
|
|
mkdir ~/rpmbuild/RPMS
|
|
mkdir ~/rpmbuild/SOURCES
|
|
mkdir ~/rpmbuild/SPECS
|
|
mkdir ~/rpmbuild/SRPMS
|
|
|
|
# Create sunshine .spec file with preinstall and postinstall scripts
|
|
cat << 'EOF' > $RPMSPEC/sunshine.spec
|
|
Name: sunshine
|
|
Version: @PROJECT_VERSION@
|
|
Release: 1%{?dist}
|
|
Summary: An NVIDIA Gamestream-compatible hosting server
|
|
BuildArch: x86_64
|
|
|
|
License: GPLv3
|
|
URL: https://github.com/SunshineStream/Sunshine
|
|
Source0: sunshine-@PROJECT_VERSION@_bin.tar.gz
|
|
|
|
Requires: systemd
|
|
|
|
%description
|
|
An NVIDIA Gamestream-compatible hosting server
|
|
|
|
%pre
|
|
#!/bin/sh
|
|
|
|
# Sunshine Pre-Install Script
|
|
# Store backup for old config files to prevent it from being overwritten
|
|
if [ -f /etc/sunshine/sunshine.conf ]; then
|
|
cp /etc/sunshine/sunshine.conf /etc/sunshine/sunshine.conf.old
|
|
fi
|
|
|
|
if [ -f /etc/sunshine/apps_linux.json ]; then
|
|
cp /etc/sunshine/apps_linux.json /etc/sunshine/apps_linux.json.old
|
|
fi
|
|
|
|
%post
|
|
#!/bin/sh
|
|
|
|
# Sunshine Post-Install Script
|
|
export GROUP_INPUT=input
|
|
|
|
if [ -f /etc/group ]; then
|
|
if ! grep -q $GROUP_INPUT /etc/group; then
|
|
echo "Creating group $GROUP_INPUT"
|
|
|
|
groupadd $GROUP_INPUT
|
|
fi
|
|
else
|
|
echo "Warning: /etc/group not found"
|
|
fi
|
|
|
|
if [ -f /etc/sunshine/sunshine.conf.old ]; then
|
|
echo "Restoring old sunshine.conf"
|
|
mv /etc/sunshine/sunshine.conf.old /etc/sunshine/sunshine.conf
|
|
fi
|
|
|
|
if [ -f /etc/sunshine/apps_linux.json.old ]; then
|
|
echo "Restoring old apps_linux.json"
|
|
mv /etc/sunshine/apps_linux.json.old /etc/sunshine/apps_linux.json
|
|
fi
|
|
|
|
# Update permissions on config files for Web Manager
|
|
if [ -f /etc/sunshine/apps_linux.json ]; then
|
|
echo "chmod 666 /etc/sunshine/apps_linux.json"
|
|
chmod 666 /etc/sunshine/apps_linux.json
|
|
fi
|
|
|
|
if [ -f /etc/sunshine/sunshine.conf ]; then
|
|
echo "chmod 666 /etc/sunshine/sunshine.conf"
|
|
chmod 666 /etc/sunshine/sunshine.conf
|
|
fi
|
|
|
|
# Ensure Sunshine can grab images from KMS
|
|
path_to_setcap=$(which setcap)
|
|
if [ -x "$path_to_setcap" ] ; then
|
|
echo "$path_to_setcap cap_sys_admin+p /usr/bin/sunshine"
|
|
$path_to_setcap cap_sys_admin+p /usr/bin/sunshine
|
|
fi
|
|
|
|
%prep
|
|
%setup -q
|
|
|
|
%install
|
|
rm -rf $RPM_BUILD_ROOT
|
|
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
|
|
mkdir -p $RPM_BUILD_ROOT/etc/sunshine
|
|
mkdir -p $RPM_BUILD_ROOT/usr/lib/systemd/user
|
|
mkdir -p $RPM_BUILD_ROOT/usr/share/applications
|
|
mkdir -p $RPM_BUILD_ROOT/etc/udev/rules.d
|
|
|
|
cp sunshine $RPM_BUILD_ROOT/%{_bindir}/sunshine
|
|
cp sunshine.conf $RPM_BUILD_ROOT/etc/sunshine/sunshine.conf
|
|
cp apps_linux.json $RPM_BUILD_ROOT/etc/sunshine/apps_linux.json
|
|
cp sunshine.service $RPM_BUILD_ROOT/usr/lib/systemd/user/sunshine.service
|
|
cp sunshine.desktop $RPM_BUILD_ROOT/usr/share/applications/sunshine.desktop
|
|
cp 85-sunshine-rules.rules $RPM_BUILD_ROOT/etc/udev/rules.d/85-sunshine-rules.rules
|
|
|
|
%clean
|
|
rm -rf $RPM_BUILD_ROOT
|
|
|
|
%files
|
|
%{_bindir}/sunshine
|
|
/usr/lib/systemd/user/sunshine.service
|
|
/etc/sunshine/sunshine.conf
|
|
/etc/sunshine/apps_linux.json
|
|
/usr/share/applications/sunshine.desktop
|
|
/etc/udev/rules.d/85-sunshine-rules.rules
|
|
|
|
%changelog
|
|
* Sat Mar 12 2022 h <65380846+thatsysadmin@users.noreply.github.com>
|
|
- Initial packaging of Sunshine.
|
|
EOF
|
|
|
|
# Copy over sunshine binary and supplemental files into rpmbuild/BUILD/
|
|
mkdir genrpm
|
|
mkdir genrpm/sunshine-@PROJECT_VERSION@
|
|
cp sunshine-@PROJECT_VERSION@ genrpm/sunshine-@PROJECT_VERSION@/sunshine
|
|
cp sunshine.service genrpm/sunshine-@PROJECT_VERSION@/sunshine.service
|
|
cp sunshine.desktop genrpm/sunshine-@PROJECT_VERSION@/sunshine.desktop
|
|
cp @CMAKE_CURRENT_SOURCE_DIR@/assets/sunshine.conf genrpm/sunshine-@PROJECT_VERSION@/sunshine.conf
|
|
cp @CMAKE_CURRENT_SOURCE_DIR@/assets/apps_linux.json genrpm/sunshine-@PROJECT_VERSION@/apps_linux.json
|
|
cp @CMAKE_CURRENT_SOURCE_DIR@/assets/85-sunshine-rules.rules genrpm/sunshine-@PROJECT_VERSION@/85-sunshine-rules.rules
|
|
cd genrpm
|
|
|
|
# tarball everything as if it was a source file for rpmbuild
|
|
tar --create --file sunshine-@PROJECT_VERSION@_bin.tar.gz sunshine-@PROJECT_VERSION@/
|
|
cp sunshine-@PROJECT_VERSION@_bin.tar.gz ~/rpmbuild/SOURCES
|
|
|
|
# Use rpmbuild to build the RPM package.
|
|
rpmbuild -bb $RPMSPEC/sunshine.spec
|
|
|
|
# Check if running in a CT
|
|
if [ "$DOCKERSTATUS" == "FALSE" ]; then
|
|
# Move the completed RPM into the cmake build folder
|
|
mv ~/rpmbuild/RPMS/x86_64/sunshine-@PROJECT_VERSION@-1.fc*.x86_64.rpm @CMAKE_CURRENT_BINARY_DIR@/
|
|
echo "Moving completed RPM package into CMake build folder."
|
|
elif [ "$DOCKERSTATUS" == "TRUE" ]; then
|
|
# Move into pickup location
|
|
mkdir -p /root/sunshine-build/package-rpm/
|
|
mv ~/rpmbuild/RPMS/x86_64/sunshine-@PROJECT_VERSION@-1.fc*.x86_64.rpm /root/sunshine-build/package-rpm/sunshine.rpm
|
|
echo "Moving completed RPM package for pickup."
|
|
fi
|
|
|
|
# Clean up; delete the rpmbuild folder we created and move back the original one
|
|
if [ "$RPMBUILDEXISTS" == "TRUE" ]; then
|
|
echo "Removing and replacing original rpmbuild folder."
|
|
rm -rf ~/rpmbuild
|
|
mv ~/rpmbuild.bkp ~/rpmbuild
|
|
fi
|
|
exit 0
|