Refactor assets and config directory

This commit is contained in:
ReenigneArcher 2022-05-11 21:31:31 -04:00
parent ca00949851
commit ed9e2c6dd0
68 changed files with 81 additions and 68 deletions

View File

@ -130,7 +130,7 @@ jobs:
mkdir -p build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_CONFIG_DIR=. -DSUNSHINE_DEFAULT_DIR=/etc/sunshine -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine -DSUNSHINE_ENABLE_WAYLAND=ON -DSUNSHINE_ENABLE_X11=ON -DSUNSHINE_ENABLE_DRM=ON -DSUNSHINE_ENABLE_CUDA=ON "../"
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=/usr/local/sunshine/.assets -DSUNSHINE_CONFIG_DIR=/usr/local/sunshine/config -DSUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine -DSUNSHINE_ENABLE_WAYLAND=ON -DSUNSHINE_ENABLE_X11=ON -DSUNSHINE_ENABLE_DRM=ON -DSUNSHINE_ENABLE_CUDA=ON ..
make -j ${nproc}
- name: Set AppImage Version
@ -228,7 +228,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_DEFAULT_DIR=/etc/sunshine ..
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=/usr/local/sunshine/.assets -DSUNSHINE_CONFIG_DIR=/usr/local/sunshine/config ..
make -j ${nproc}
- name: Package MacOS
@ -297,7 +297,7 @@ jobs:
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=assets -G "MinGW Makefiles" ..
cmake -DCMAKE_BUILD_TYPE=Release -DSUNSHINE_ASSETS_DIR=assets -DSUNSHINE_CONFIG_DIR=config -G "MinGW Makefiles" ..
mingw32-make -j2
- name: Package Windows

16
.gitignore vendored
View File

@ -10,14 +10,14 @@ cmake-build*
.idea
# Extra FontAwesome files
/assets/web/fonts/fontawesome-free-web/css/*.css
!/assets/web/fonts/fontawesome-free-web/css/*min.css
/assets/web/fonts/fontawesome-free-web/js/
/assets/web/fonts/fontawesome-free-web/less/
/assets/web/fonts/fontawesome-free-web/metadata/
/assets/web/fonts/fontawesome-free-web/scss/
/assets/web/fonts/fontawesome-free-web/sprites/
/assets/web/fonts/fontawesome-free-web/svgs/
/src_assets/common/assets/web/fonts/fontawesome-free-web/css/*.css
!/src_assets/common/assets/web/fonts/fontawesome-free-web/css/*min.css
/src_assets/common/assets/web/fonts/fontawesome-free-web/js/
/src_assets/common/assets/web/fonts/fontawesome-free-web/less/
/src_assets/common/assets/web/fonts/fontawesome-free-web/metadata/
/src_assets/common/assets/web/fonts/fontawesome-free-web/scss/
/src_assets/common/assets/web/fonts/fontawesome-free-web/sprites/
/src_assets/common/assets/web/fonts/fontawesome-free-web/svgs/
# Translations
*.mo

View File

@ -147,6 +147,8 @@ elseif(APPLE)
set(PLATFORM_INCLUDE_DIRS
${Boost_INCLUDE_DIR})
set(APPLE_PLIST_FILE ${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets/Info.plist)
set(PLATFORM_TARGET_FILES
sunshine/platform/macos/av_audio.h
sunshine/platform/macos/av_audio.m
@ -163,7 +165,7 @@ elseif(APPLE)
sunshine/platform/macos/publish.cpp
sunshine/platform/macos/TPCircularBuffer/TPCircularBuffer.c
sunshine/platform/macos/TPCircularBuffer/TPCircularBuffer.h
${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mac/Info.plist)
${APPLE_PLIST_FILE})
else()
add_compile_definitions(SUNSHINE_PLATFORM="linux")
@ -389,16 +391,14 @@ else()
list(APPEND SUNSHINE_COMPILE_OPTIONS -O3)
endif()
set(SUNSHINE_SOURCE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src_assets")
if(NOT SUNSHINE_ASSETS_DIR)
set(SUNSHINE_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/assets")
set(SUNSHINE_ASSETS_DIR "${CMAKE_CURRENT_BINARY_DIR}/.assets")
endif()
if(NOT SUNSHINE_CONFIG_DIR)
set(SUNSHINE_CONFIG_DIR "${SUNSHINE_ASSETS_DIR}")
endif()
if(NOT SUNSHINE_DEFAULT_DIR)
set(SUNSHINE_DEFAULT_DIR "${SUNSHINE_ASSETS_DIR}")
set(SUNSHINE_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}/config")
endif()
list(APPEND CBS_EXTERNAL_LIBRARIES
@ -421,7 +421,6 @@ endif()
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR}")
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_CONFIG_DIR="${SUNSHINE_CONFIG_DIR}")
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_DEFAULT_DIR="${SUNSHINE_DEFAULT_DIR}")
list(APPEND SUNSHINE_DEFINITIONS APPS_JSON="apps.json")
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
target_link_libraries(sunshine ${SUNSHINE_EXTERNAL_LIBRARIES} ${EXTRA_LIBS})
@ -437,7 +436,7 @@ if(NOT DEFINED CMAKE_CUDA_STANDARD)
endif()
if(APPLE)
target_link_options(sunshine PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/assets/assets_mac/Info.plist)
target_link_options(sunshine PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${APPLE_PLIST_FILE})
endif()
foreach(flag IN LISTS SUNSHINE_COMPILE_OPTIONS)
@ -472,8 +471,11 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
install(TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio)
install(TARGETS sunshinesvc RUNTIME DESTINATION "tools" COMPONENT sunshinesvc)
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_common/" DESTINATION "${SUNSHINE_CONFIG_DIR}" COMPONENT assets)
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_windows/" DESTINATION "${SUNSHINE_CONFIG_DIR}" COMPONENT assets)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets" DESTINATION "${SUNSHINE_ASSETS_DIR}" COMPONENT assets)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/assets" DESTINATION "${SUNSHINE_ASSETS_DIR}" COMPONENT assets)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config" DESTINATION "${SUNSHINE_CONFIG_DIR}" COMPONENT config)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/config" DESTINATION "${SUNSHINE_CONFIG_DIR}" COMPONENT config)
# set(CPACK_NSIS_MUI_HEADERIMAGE "") # TODO: image should be 150x57 bmp
@ -513,6 +515,12 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
set(CPACK_COMPONENT_ASSETS_GROUP "${CMAKE_PROJECT_NAME}")
set(CPACK_COMPONENT_ASSETS_REQUIRED true)
# config
set(CPACK_COMPONENT_ASSETS_DISPLAY_NAME "Config")
set(CPACK_COMPONENT_ASSETS_DESCRIPTION "Default config files.")
set(CPACK_COMPONENT_ASSETS_GROUP "${CMAKE_PROJECT_NAME}")
set(CPACK_COMPONENT_ASSETS_REQUIRED true)
# audio tool
set(CPACK_COMPONENT_AUDIO_DISPLAY_NAME "audio-info.exe")
set(CPACK_COMPONENT_AUDIO_DESCRIPTION "CLI tool that allows you to get information about sound devices.")
@ -528,13 +536,23 @@ if(WIN32) # see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.h
set(CPACK_COMPONENT_SUNSHINESVC_DESCRIPTION "CLI tool that allows you to enable/disable the Sunshine service.")
set(CPACK_COMPONENT_SUNSHINESVC_GROUP "Tools")
endif()
if(UNIX)
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/assets" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/common/config" DESTINATION "${SUNSHINE_CONFIG_DIR}")
# Installation destination dir
set(CPACK_SET_DESTDIR true)
set(CMAKE_INSTALL_PREFIX "/usr/local/sunshine/")
endif()
if(APPLE) # TODO: test
set(prefix "${CMAKE_PROJECT_NAME}.app/Contents")
set(INSTALL_RUNTIME_DIR "${prefix}/MacOS")
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_common/" DESTINATION "${INSTALL_RUNTIME_DIR}")
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_mac/" DESTINATION "${INSTALL_RUNTIME_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/assets" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/macos/config" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(TARGETS sunshine
BUNDLE DESTINATION . COMPONENT Runtime
@ -542,26 +560,27 @@ if(APPLE) # TODO: test
# TODO: bundle doesn't produce a valid .app use cpack -G DragNDrop
set(CPACK_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/assets_mac/Info.plist")
set(CPACK_BUNDLE_PLIST "${APPLE_PLIST_FILE}")
set(CPACK_BUNDLE_ICON "${PROJECT_SOURCE_DIR}/sunshine.icns")
# Portfile
configure_file(Portfile.in Portfile @ONLY)
endif()
if(UNIX AND NOT APPLE)
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_common/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(DIRECTORY "${SUNSHINE_ASSETS_DIR}/assets_linux/" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/assets" DESTINATION "${SUNSHINE_ASSETS_DIR}")
install(FILES "${SUNSHINE_ASSETS_DIR}/linux-misc/85-sunshine-rules.rules" DESTINATION "/etc/udev/rules.d")
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/config" DESTINATION "${SUNSHINE_CONFIG_DIR}")
install(FILES "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/misc/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")
# 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")
"${SUNSHINE_SOURCE_ASSETS_DIR}/linux/deb/preinst;${SUNSHINE_SOURCE_ASSETS_DIR}/linux/deb/postinst;${SUNSHINE_SOURCE_ASSETS_DIR}/linux/deb/conffiles")
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/deb/preinst")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${SUNSHINE_SOURCE_ASSETS_DIR}/linux/deb/postinst")
# Dependencies
set(CPACK_DEB_COMPONENT_INSTALL ON)
@ -569,10 +588,6 @@ if(UNIX AND NOT APPLE)
set(CPACK_RPM_PACKAGE_REQUIRES "libssl==1.1, libavdevice>=58, libboost-thread>=1.67.0, libboost-filesystem>=1.67.0, libboost-log>=1.67.0, libpulse>=0, libopus>=0, libxcb-shm>=0, libxcb-xfixes>=0, libxtst>=0, libevdev>=2.0, libdrm>=2.0, libcap>=2.0")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF) # This should automatically figure out dependencies, doesn't work with the current config
# Installation destination dir
set(CPACK_SET_DESTDIR true)
set(CMAKE_INSTALL_PREFIX "/etc/sunshine")
# AppImage desktop file
configure_file(sunshine.desktop.in sunshine.desktop @ONLY)
endif()

View File

@ -31,21 +31,19 @@ depends_lib port:avahi \
boost.version 1.76
configure.args -DBOOST_ROOT=[boost::install_area] \
-DSUNSHINE_ASSETS_DIR=${worksrcpath}/assets
-DSUNSHINE_DEFAULT_DIR=${prefix}/etc/sunshine
-DSUNSHINE_ASSETS_DIR=${prefix}/usr/local/sunshine/.assets
-DSUNSHINE_CONFIG_DIR=${prefix}/usr/local/sunshine/config
cmake.out_of_source yes
destroot {
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}
xinstall ${worksrcpath}/assets/assets_mac/apps.json ${destroot}${prefix}/etc/${name}
xinstall ${worksrcpath}/assets/assets_common/box.png ${destroot}${prefix}/etc/${name}
xinstall ${worksrcpath}/assets/assets_common/sunshine.conf ${destroot}${prefix}/etc/${name}
xinstall -d -m 755 ${destroot}${prefix}/usr/local/${name}/.assets
xinstall {*}[glob ${worksrcpath}/src_assets/common/assets/*] ${destroot}${prefix}/usr/local/${name}/.assets
xinstall {*}[glob ${worksrcpath}/src_assets/macos/assets/*] ${destroot}${prefix}/usr/local/${name}/.assets
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/web
xinstall {*}[glob ${worksrcpath}/assets/assets_common/web/*.html] ${destroot}${prefix}/etc/${name}/web
xinstall -d -m 755 ${destroot}${prefix}/etc/${name}/web/third_party
xinstall {*}[glob ${worksrcpath}/assets/assets_common/web/third_party/*] ${destroot}${prefix}/etc/${name}/web/third_party
xinstall -d -m 755 ${destroot}${prefix}/usr/local/${name}/config
xinstall {*}[glob ${worksrcpath}/src_assets/common/config/*] ${destroot}${prefix}/usr/local/${name}/config
xinstall {*}[glob ${worksrcpath}/src_assets/macos/config/*] ${destroot}${prefix}/usr/local/${name}/config
xinstall ${workpath}/build/${name} ${destroot}${prefix}/bin
}

View File

@ -1,2 +0,0 @@
/etc/sunshine/sunshine.conf
/etc/sunshine/apps.json

View File

@ -1,9 +0,0 @@
#!/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.json ]; then
cp /etc/sunshine/apps.json /etc/sunshine/apps.json.old
fi

View File

@ -27,7 +27,7 @@ AppImage
.. image:: https://img.shields.io/github/issues/sunshinestream/sunshine/pkg:appimage?logo=github&style=for-the-badge
:alt: GitHub issues by-label
The current compatibility of the AppImage is shown below.
The current known compatibility of the AppImage is shown below.
- [✖] Debian oldstable (buster)
- [✔] Debian stable (bullseye)

View File

Before

Width:  |  Height:  |  Size: 998 B

After

Width:  |  Height:  |  Size: 998 B

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,2 @@
/usr/local/sunshine/config/sunshine.conf
/usr/local/sunshine/config/apps.json

View File

@ -12,25 +12,25 @@ else
echo "Warning: /etc/group not found"
fi
if [ -f /etc/sunshine/sunshine.conf.old ]; then
if [ -f /usr/local/sunshine/config/sunshine.conf.old ]; then
echo "Restoring old sunshine.conf"
mv /etc/sunshine/sunshine.conf.old /etc/sunshine/sunshine.conf
mv /usr/local/sunshine/config/sunshine.conf.old /usr/local/sunshine/config/sunshine.conf
fi
if [ -f /etc/sunshine/apps.json.old ]; then
if [ -f /usr/local/sunshine/config/apps.json.old ]; then
echo "Restoring old apps.json"
mv /etc/sunshine/apps.json.old /etc/sunshine/apps.json
mv /usr/local/sunshine/config/apps.json.old /usr/local/sunshine/config/apps.json
fi
# Update permissions on config files for Web Manager
if [ -f /etc/sunshine/apps.json ]; then
if [ -f /usr/local/sunshine/config/apps.json ]; then
echo "chmod 666 /etc/sunshine/apps.json"
chmod 666 /etc/sunshine/apps.json
chmod 666 /usr/local/sunshine/config/apps.json
fi
if [ -f /etc/sunshine/sunshine.conf ]; then
if [ -f /usr/local/sunshine/config/sunshine.conf ]; then
echo "chmod 666 /etc/sunshine/sunshine.conf"
chmod 666 /etc/sunshine/sunshine.conf
chmod 666 /usr/local/sunshine/config/sunshine.conf
fi
# Ensure Sunshine can grab images from KMS

View File

@ -0,0 +1,9 @@
#!/bin/sh
#Store backup for old config files to prevent it from being overwritten
if [ -f /usr/local/sunshine/config/sunshine.conf ]; then
cp /usr/local/sunshine/config/sunshine.conf /usr/local/sunshine/config/sunshine.conf.old
fi
if [ -f /usr/local/sunshine/config/apps.json ]; then
cp /usr/local/sunshine/config/apps.json /usr/local/sunshine/config/apps.json.old
fi

View File

@ -20,7 +20,7 @@ using namespace std::literals;
#define PRIVATE_KEY_FILE CA_DIR "/cakey.pem"
#define CERTIFICATE_FILE CA_DIR "/cacert.pem"
#define APPS_JSON_PATH SUNSHINE_CONFIG_DIR "/" APPS_JSON
#define APPS_JSON_PATH SUNSHINE_CONFIG_DIR "/apps.json"
namespace config {
namespace nv {
@ -695,7 +695,7 @@ int apply_flags(const char *line) {
void apply_config(std::unordered_map<std::string, std::string> &&vars) {
if(!fs::exists(stream.file_apps.c_str())) {
fs::copy_file(SUNSHINE_DEFAULT_DIR "/" APPS_JSON, stream.file_apps);
fs::copy_file(SUNSHINE_CONFIG_DIR "/apps.json", stream.file_apps);
}
for(auto &[name, val] : vars) {
@ -906,7 +906,7 @@ int parse(int argc, char *argv[]) {
}
if(!fs::exists(sunshine.config_file)) {
fs::copy_file(SUNSHINE_DEFAULT_DIR "/sunshine.conf", sunshine.config_file);
fs::copy_file(SUNSHINE_CONFIG_DIR "/sunshine.conf", sunshine.config_file);
}
auto vars = parse_config(read_file(sunshine.config_file.c_str()));