mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-10-30 03:45:14 +00:00
fix(packaging/Linux): ensure that uhid is loaded automatically (#2906)
Co-authored-by: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com>
This commit is contained in:
parent
6de97fdc18
commit
fd96aa0b36
@ -4,6 +4,7 @@
|
|||||||
# SYSTEMD_FOUND - system has systemd
|
# SYSTEMD_FOUND - system has systemd
|
||||||
# SYSTEMD_USER_UNIT_INSTALL_DIR - the systemd system unit install directory
|
# SYSTEMD_USER_UNIT_INSTALL_DIR - the systemd system unit install directory
|
||||||
# SYSTEMD_SYSTEM_UNIT_INSTALL_DIR - the systemd user unit install directory
|
# SYSTEMD_SYSTEM_UNIT_INSTALL_DIR - the systemd user unit install directory
|
||||||
|
# SYSTEMD_MODULES_LOAD_DIR - the systemd modules-load.d directory
|
||||||
|
|
||||||
IF (NOT WIN32)
|
IF (NOT WIN32)
|
||||||
|
|
||||||
@ -15,19 +16,20 @@ IF (NOT WIN32)
|
|||||||
if (SYSTEMD_FOUND)
|
if (SYSTEMD_FOUND)
|
||||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||||
--variable=systemduserunitdir systemd
|
--variable=systemduserunitdir systemd
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE SYSTEMD_USER_UNIT_INSTALL_DIR)
|
OUTPUT_VARIABLE SYSTEMD_USER_UNIT_INSTALL_DIR)
|
||||||
|
|
||||||
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_USER_UNIT_INSTALL_DIR
|
|
||||||
"${SYSTEMD_USER_UNIT_INSTALL_DIR}")
|
|
||||||
|
|
||||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||||
--variable=systemdsystemunitdir systemd
|
--variable=systemdsystemunitdir systemd
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE SYSTEMD_SYSTEM_UNIT_INSTALL_DIR)
|
OUTPUT_VARIABLE SYSTEMD_SYSTEM_UNIT_INSTALL_DIR)
|
||||||
|
|
||||||
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SYSTEM_UNIT_INSTALL_DIR
|
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||||
"${SYSTEMD_SYSTEM_UNIT_INSTALL_DIR}")
|
--variable=modules_load_dir systemd
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
OUTPUT_VARIABLE SYSTEMD_MODULES_LOAD_DIR)
|
||||||
|
|
||||||
mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR)
|
mark_as_advanced(SYSTEMD_USER_UNIT_INSTALL_DIR SYSTEMD_SYSTEM_UNIT_INSTALL_DIR SYSTEMD_MODULES_LOAD_DIR)
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,9 @@ if(NOT WIN32)
|
|||||||
|
|
||||||
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
|
||||||
--variable=udevdir udev
|
--variable=udevdir udev
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
OUTPUT_VARIABLE UDEV_RULES_INSTALL_DIR)
|
OUTPUT_VARIABLE UDEV_RULES_INSTALL_DIR)
|
||||||
|
|
||||||
string(REGEX REPLACE "[ \t\n]+" "" UDEV_RULES_INSTALL_DIR
|
|
||||||
"${UDEV_RULES_INSTALL_DIR}")
|
|
||||||
|
|
||||||
set(UDEV_RULES_INSTALL_DIR "${UDEV_RULES_INSTALL_DIR}/rules.d")
|
set(UDEV_RULES_INSTALL_DIR "${UDEV_RULES_INSTALL_DIR}/rules.d")
|
||||||
|
|
||||||
mark_as_advanced(UDEV_RULES_INSTALL_DIR)
|
mark_as_advanced(UDEV_RULES_INSTALL_DIR)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ file(CREATE_LINK "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets/shaders"
|
|||||||
if(${SUNSHINE_BUILD_APPIMAGE} OR ${SUNSHINE_BUILD_FLATPAK})
|
if(${SUNSHINE_BUILD_APPIMAGE} OR ${SUNSHINE_BUILD_FLATPAK})
|
||||||
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.rules"
|
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.rules"
|
||||||
DESTINATION "${SUNSHINE_ASSETS_DIR}/udev/rules.d")
|
DESTINATION "${SUNSHINE_ASSETS_DIR}/udev/rules.d")
|
||||||
|
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.conf"
|
||||||
|
DESTINATION "${SUNSHINE_ASSETS_DIR}/modules-load.d")
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
|
||||||
DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user")
|
DESTINATION "${SUNSHINE_ASSETS_DIR}/systemd/user")
|
||||||
else()
|
else()
|
||||||
@ -27,6 +29,8 @@ else()
|
|||||||
if(SYSTEMD_FOUND)
|
if(SYSTEMD_FOUND)
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service"
|
||||||
DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}")
|
DESTINATION "${SYSTEMD_USER_UNIT_INSTALL_DIR}")
|
||||||
|
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/60-sunshine.conf"
|
||||||
|
DESTINATION "${SYSTEMD_MODULES_LOAD_DIR}")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -47,6 +47,8 @@ function install() {
|
|||||||
# user input rules
|
# user input rules
|
||||||
# shellcheck disable=SC2002
|
# shellcheck disable=SC2002
|
||||||
cat "$SUNSHINE_SHARE_HERE/udev/rules.d/60-sunshine.rules" | sudo tee /etc/udev/rules.d/60-sunshine.rules
|
cat "$SUNSHINE_SHARE_HERE/udev/rules.d/60-sunshine.rules" | sudo tee /etc/udev/rules.d/60-sunshine.rules
|
||||||
|
cat "$SUNSHINE_SHARE_HERE/modules-load.d/60-sunshine.conf" | sudo tee /etc/modules-load.d/60-sunshine.conf
|
||||||
|
sudo modprobe uhid
|
||||||
sudo udevadm control --reload-rules
|
sudo udevadm control --reload-rules
|
||||||
sudo udevadm trigger --property-match=DEVNAME=/dev/uinput
|
sudo udevadm trigger --property-match=DEVNAME=/dev/uinput
|
||||||
sudo udevadm trigger --property-match=DEVNAME=/dev/uhid
|
sudo udevadm trigger --property-match=DEVNAME=/dev/uhid
|
||||||
@ -65,6 +67,9 @@ function remove() {
|
|||||||
# remove input rules
|
# remove input rules
|
||||||
sudo rm -f /etc/udev/rules.d/60-sunshine.rules
|
sudo rm -f /etc/udev/rules.d/60-sunshine.rules
|
||||||
|
|
||||||
|
# remove uhid module loading config
|
||||||
|
sudo rm -f /etc/modules-load.d/60-sunshine.conf
|
||||||
|
|
||||||
# remove service
|
# remove service
|
||||||
sudo rm -f ~/.config/systemd/user/sunshine.service
|
sudo rm -f ~/.config/systemd/user/sunshine.service
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,9 +13,11 @@ do_udev_reload() {
|
|||||||
post_install() {
|
post_install() {
|
||||||
do_setcap
|
do_setcap
|
||||||
do_udev_reload
|
do_udev_reload
|
||||||
|
modprobe uhid
|
||||||
}
|
}
|
||||||
|
|
||||||
post_upgrade() {
|
post_upgrade() {
|
||||||
do_setcap
|
do_setcap
|
||||||
do_udev_reload
|
do_udev_reload
|
||||||
|
modprobe uhid
|
||||||
}
|
}
|
||||||
|
|||||||
@ -211,15 +211,13 @@ xvfb-run ./tests/test_sunshine
|
|||||||
cd %{_builddir}/Sunshine/build
|
cd %{_builddir}/Sunshine/build
|
||||||
%make_install
|
%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 <<EOF
|
|
||||||
uhid
|
|
||||||
EOF
|
|
||||||
|
|
||||||
%post
|
%post
|
||||||
# Note: this is copied from the postinst script
|
# Note: this is copied from the postinst script
|
||||||
|
|
||||||
|
# Load uhid (DS5 emulation)
|
||||||
|
echo "Loading uhid kernel module for DS5 emulation."
|
||||||
|
modprobe uhid
|
||||||
|
|
||||||
# Check if we're in an rpm-ostree environment
|
# Check if we're in an rpm-ostree environment
|
||||||
if [ ! -x "$(command -v rpm-ostree)" ]; then
|
if [ ! -x "$(command -v rpm-ostree)" ]; then
|
||||||
echo "Not in an rpm-ostree environment, proceeding with post install steps."
|
echo "Not in an rpm-ostree environment, proceeding with post install steps."
|
||||||
@ -239,10 +237,6 @@ else
|
|||||||
echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes."
|
echo "rpm-ostree environment detected, skipping post install steps. Restart to apply the changes."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%preun
|
|
||||||
# Remove modules-load configuration
|
|
||||||
rm -f /usr/lib/modules-load.d/uhid.conf
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
# Executables
|
# Executables
|
||||||
%caps(cap_sys_admin+p) %{_bindir}/sunshine
|
%caps(cap_sys_admin+p) %{_bindir}/sunshine
|
||||||
@ -255,7 +249,7 @@ rm -f /usr/lib/modules-load.d/uhid.conf
|
|||||||
%{_udevrulesdir}/*-sunshine.rules
|
%{_udevrulesdir}/*-sunshine.rules
|
||||||
|
|
||||||
# Modules-load configuration
|
# Modules-load configuration
|
||||||
%{_modulesloaddir}/uhid.conf
|
%{_modulesloaddir}/*-sunshine.conf
|
||||||
|
|
||||||
# Desktop entries
|
# Desktop entries
|
||||||
%{_datadir}/applications/*.desktop
|
%{_datadir}/applications/*.desktop
|
||||||
|
|||||||
@ -6,6 +6,12 @@ cp "/app/share/sunshine/systemd/user/sunshine.service" "$HOME/.config/systemd/us
|
|||||||
echo "Sunshine User Service has been installed."
|
echo "Sunshine User Service has been installed."
|
||||||
echo "Use [systemctl --user enable sunshine] once to autostart Sunshine on login."
|
echo "Use [systemctl --user enable sunshine] once to autostart Sunshine on login."
|
||||||
|
|
||||||
|
# Load uhid (DS5 emulation)
|
||||||
|
UHID=$(cat /app/share/sunshine/modules-load.d/60-sunshine.conf)
|
||||||
|
echo "Enabling DS5 emulation."
|
||||||
|
flatpak-spawn --host pkexec sh -c "echo '$UHID' > /etc/modules-load.d/60-sunshine.conf"
|
||||||
|
flatpak-spawn --host pkexec modprobe uhid
|
||||||
|
|
||||||
# Udev rule
|
# Udev rule
|
||||||
UDEV=$(cat /app/share/sunshine/udev/rules.d/60-sunshine.rules)
|
UDEV=$(cat /app/share/sunshine/udev/rules.d/60-sunshine.rules)
|
||||||
echo "Configuring mouse permission."
|
echo "Configuring mouse permission."
|
||||||
|
|||||||
@ -6,6 +6,7 @@ rm "$HOME/.config/systemd/user/sunshine.service"
|
|||||||
systemctl --user daemon-reload
|
systemctl --user daemon-reload
|
||||||
echo "Sunshine User Service has been removed."
|
echo "Sunshine User Service has been removed."
|
||||||
|
|
||||||
# Udev rule
|
# Remove rules
|
||||||
|
flatpak-spawn --host pkexec sh -c "rm /etc/modules-load.d/60-sunshine.conf"
|
||||||
flatpak-spawn --host pkexec sh -c "rm /etc/udev/rules.d/60-sunshine.rules"
|
flatpak-spawn --host pkexec sh -c "rm /etc/udev/rules.d/60-sunshine.rules"
|
||||||
echo "Input rules removed. Restart computer to take effect."
|
echo "Input rules removed. Restart computer to take effect."
|
||||||
|
|||||||
2
src_assets/linux/misc/60-sunshine.conf
Normal file
2
src_assets/linux/misc/60-sunshine.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Sunshine needs uhid for DS5 emulation
|
||||||
|
uhid
|
||||||
@ -1,5 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Load uhid (DS5 emulation)
|
||||||
|
echo "Loading uhid kernel module for DS5 emulation."
|
||||||
|
modprobe uhid
|
||||||
|
|
||||||
# Check if we're in an rpm-ostree environment
|
# Check if we're in an rpm-ostree environment
|
||||||
if [ ! -x "$(command -v rpm-ostree)" ]; then
|
if [ ! -x "$(command -v rpm-ostree)" ]; then
|
||||||
echo "Not in an rpm-ostree environment, proceeding with post install steps."
|
echo "Not in an rpm-ostree environment, proceeding with post install steps."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user