Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Moving to cpack in order to unify installers across all platforms #139

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
WIP: Moving to cpack in order to unify installers across all platforms
  • Loading branch information
ABeltramo committed Apr 30, 2022
commit c4977b5393e6a266467bb9261b7866f6384cd798
62 changes: 60 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,6 @@ else()
if(NOT DEFINED SUNSHINE_EXECUTABLE_PATH)
set(SUNSHINE_EXECUTABLE_PATH "sunshine")
endif()
configure_file(gen-deb.in gen-deb @ONLY)
configure_file(gen-rpm.in gen-rpm @ONLY)
configure_file(sunshine.desktop.in sunshine.desktop @ONLY)
configure_file(sunshine.service.in sunshine.service @ONLY)
endif()
Expand Down Expand Up @@ -448,3 +446,63 @@ foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
endforeach()

target_compile_options(sunshine PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${SUNSHINE_COMPILE_OPTIONS}>;$<$<COMPILE_LANGUAGE:CUDA>:${SUNSHINE_COMPILE_OPTIONS_CUDA};-std=c++17>)

#############
# CPACK
####

# Add all assets dependencies
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/web" DESTINATION ".")
install(FILES "${SUNSHINE_ASSETS_DIR}/sunshine.conf" DESTINATION ".")
if(WIN32) # TODO: test
install(TARGETS sunshine RUNTIME DESTINATION ".")

install(FILES "${SUNSHINE_ASSETS_DIR}/apps_windows.json" DESTINATION ".")
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/shaders/directx" DESTINATION "shaders")
endif()
if(APPLE) # TODO: test
install(TARGETS sunshine RUNTIME DESTINATION ".")

install(FILES "${SUNSHINE_ASSETS_DIR}/apps_mac.json" DESTINATION ".")
# TODO: info.plist ??
endif()
if(UNIX AND NOT APPLE)
install(FILES "${SUNSHINE_ASSETS_DIR}/apps_linux.json" DESTINATION ".")
install(FILES "${SUNSHINE_ASSETS_DIR}/85-sunshine-rules.rules" DESTINATION "/etc/udev/rules.d")
install(TARGETS sunshine RUNTIME DESTINATION "/usr/bin")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sunshine.service" DESTINATION "/usr/lib/systemd/user")
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/shaders/opengl" DESTINATION "shaders")

# Pre and post install
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
"${SUNSHINE_ASSETS_DIR}/linux-deb/preinst;${SUNSHINE_ASSETS_DIR}/linux-deb/postinst;${SUNSHINE_ASSETS_DIR}/linux-deb/conffiles")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${SUNSHINE_ASSETS_DIR}/linux-deb/preinst")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${SUNSHINE_ASSETS_DIR}/linux-deb/postinst")
endif()

# Common options
set(CPACK_PACKAGE_NAME "SunshineStream")
set(CPACK_PACKAGE_VENDOR "CMake.org")
set(CPACK_PACKAGE_CONTACT "https://github.com/SunshineStream/Sunshine")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "https://github.com/SunshineStream/Sunshine")
set(CPACK_PACKAGE_DESCRIPTION "Gamestream host for Moonlight")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/SunshineStream/Sunshine")
set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE)
set(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/sunshine.png)
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
set(CPACK_STRIP_FILES YES)

# Installation destination dir
if(NOT WIN32)
set(CPACK_SET_DESTDIR true)
endif()
if(UNIX AND NOT APPLE)
set(CMAKE_INSTALL_PREFIX "/etc/sunshine")
endif()

## DEB
set(CPACK_DEB_COMPONENT_INSTALL ON)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libssl1.1, libavdevice58, libboost-thread1.67.0 | libboost-thread1.71.0 | libboost-thread1.74.0, libboost-filesystem1.67.0 | libboost-filesystem1.71.0 | libboost-filesystem1.74.0, libboost-log1.67.0 | libboost-log1.71.0 | libboost-log1.74.0, libpulse0, libopus0, libxcb-shm0, libxcb-xfixes0, libxtst6, libevdev2, libdrm2, libcap2")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)

include(CPack)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new line at end of files

2 changes: 2 additions & 0 deletions assets/linux-deb/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/etc/sunshine/sunshine.conf
/etc/sunshine/apps_linux.json
41 changes: 41 additions & 0 deletions assets/linux-deb/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

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 $(readlink -f /usr/bin/sunshine)
fi
9 changes: 9 additions & 0 deletions assets/linux-deb/preinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#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
123 changes: 0 additions & 123 deletions gen-deb.in

This file was deleted.

Loading