From 8bbd64f0257f8240b453c0aa662c80bfc6e449bc Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Fri, 23 Aug 2024 00:55:56 +0800 Subject: [PATCH] Migrate installer to Apollo --- cmake/packaging/common.cmake | 6 +-- cmake/packaging/windows.cmake | 41 +++++++++++++----- src/entry_handler.cpp | 2 +- .../windows/drivers/sudovda/SudoVDA.inf | Bin 0 -> 3646 bytes .../windows/drivers/sudovda/code_signing.crt | Bin 0 -> 789 bytes .../windows/drivers/sudovda/install.bat | 25 +++++++++++ .../windows/drivers/sudovda/sudovda.cat | Bin 0 -> 2439 bytes .../windows/drivers/sudovda/uninstall.bat | 9 ++++ .../misc/autostart/autostart-service.bat | 2 +- .../misc/firewall/add-firewall-rule.bat | 2 +- .../misc/firewall/delete-firewall-rule.bat | 2 +- .../windows/misc/service/install-service.bat | 8 ++-- .../misc/service/uninstall-service.bat | 6 +-- tools/sunshinesvc.cpp | 2 +- vite.config.js | 1 + 15 files changed, 79 insertions(+), 27 deletions(-) create mode 100644 src_assets/windows/drivers/sudovda/SudoVDA.inf create mode 100644 src_assets/windows/drivers/sudovda/code_signing.crt create mode 100644 src_assets/windows/drivers/sudovda/install.bat create mode 100644 src_assets/windows/drivers/sudovda/sudovda.cat create mode 100644 src_assets/windows/drivers/sudovda/uninstall.bat diff --git a/cmake/packaging/common.cmake b/cmake/packaging/common.cmake index 7c76756c..5ef26b36 100644 --- a/cmake/packaging/common.cmake +++ b/cmake/packaging/common.cmake @@ -2,14 +2,14 @@ # common cpack options set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME}) -set(CPACK_PACKAGE_VENDOR "LizardByte") +set(CPACK_PACKAGE_VENDOR "SudoMaker") set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) set(CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cpack_artifacts) -set(CPACK_PACKAGE_CONTACT "https://app.lizardbyte.dev") +set(CPACK_PACKAGE_CONTACT "https://www.sudomaker.com") set(CPACK_PACKAGE_DESCRIPTION ${CMAKE_PROJECT_DESCRIPTION}) set(CPACK_PACKAGE_HOMEPAGE_URL ${CMAKE_PROJECT_HOMEPAGE_URL}) set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE) -set(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/sunshine.png) +set(CPACK_PACKAGE_ICON ${PROJECT_SOURCE_DIR}/apollo.png) set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}") set(CPACK_STRIP_FILES YES) diff --git a/cmake/packaging/windows.cmake b/cmake/packaging/windows.cmake index 77f3a893..01c2c1d8 100644 --- a/cmake/packaging/windows.cmake +++ b/cmake/packaging/windows.cmake @@ -14,6 +14,11 @@ install(TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio) install(TARGETS ddprobe RUNTIME DESTINATION "tools" COMPONENT application) install(TARGETS sunshinesvc RUNTIME DESTINATION "tools" COMPONENT application) +# Drivers +install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/drivers/sudovda" + DESTINATION "drivers" + COMPONENT sudovda) + # Mandatory scripts install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/" DESTINATION "scripts" @@ -62,8 +67,9 @@ set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS} IfSilent +2 0 - ExecShell 'open' 'https://sunshinestream.readthedocs.io/' + # ExecShell 'open' 'https://sunshinestream.readthedocs.io/' nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset' + nsExec::ExecToLog '\\\"$INSTDIR\\\\drivers\\\\sudovda\\\\install.bat\\\"' nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"' nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"' nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"' @@ -80,10 +86,15 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"' nsExec::ExecToLog '\\\"$INSTDIR\\\\sunshine.exe\\\" --restore-nvprefs-undo' MessageBox MB_YESNO|MB_ICONQUESTION \ - 'Do you want to remove Virtual Gamepad)?' \ + 'Do you want to remove Virtual Gamepad?' \ /SD IDNO IDNO NoGamepad nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-gamepad.bat\\\"'; skipped if no NoGamepad: + MessageBox MB_YESNO|MB_ICONQUESTION \ + 'Do you want to remove SudoVDA Virtual Display Driver?' \ + /SD IDNO IDNO NoSudoVDA + nsExec::ExecToLog '\\\"$INSTDIR\\\\drivers\\\\sudovda\\\\uninstall.bat\\\"'; skipped if no + NoSudoVDA: MessageBox MB_YESNO|MB_ICONQUESTION \ 'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \ /SD IDNO IDNO NoDelete @@ -95,11 +106,11 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS set(CPACK_NSIS_MODIFY_PATH "OFF") set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") # This will be shown on the installed apps Windows settings -set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe") +set(CPACK_NSIS_INSTALLED_ICON_NAME "sunshine.exe") set(CPACK_NSIS_CREATE_ICONS_EXTRA "${CPACK_NSIS_CREATE_ICONS_EXTRA} CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \ - '\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut' + '\$INSTDIR\\\\sunshine.exe' '--shortcut' ") set(CPACK_NSIS_DELETE_ICONS_EXTRA "${CPACK_NSIS_DELETE_ICONS_EXTRA} @@ -109,14 +120,14 @@ set(CPACK_NSIS_DELETE_ICONS_EXTRA # Checking for previous installed versions set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON") -set(CPACK_NSIS_HELP_LINK "https://sunshinestream.readthedocs.io/en/latest/about/installation.html") -set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}") -set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support") +# set(CPACK_NSIS_HELP_LINK "https://sunshinestream.readthedocs.io/en/latest/about/installation.html") +# set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}") +# set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support") -set(CPACK_NSIS_MENU_LINKS - "https://sunshinestream.readthedocs.io" "Sunshine documentation" - "https://app.lizardbyte.dev" "LizardByte Web Site" - "https://app.lizardbyte.dev/support" "LizardByte Support") +# set(CPACK_NSIS_MENU_LINKS +# "https://sunshinestream.readthedocs.io" "Sunshine documentation" +# "https://app.lizardbyte.dev" "LizardByte Web Site" +# "https://app.lizardbyte.dev/support" "LizardByte Support") set(CPACK_NSIS_MANIFEST_DPI_AWARE true) # Setting components groups and dependencies @@ -131,7 +142,7 @@ set(CPACK_COMPONENT_APPLICATION_DEPENDS assets) # service auto-start script set(CPACK_COMPONENT_AUTOSTART_DISPLAY_NAME "Launch on Startup") -set(CPACK_COMPONENT_AUTOSTART_DESCRIPTION "If enabled, launches Sunshine automatically on system startup.") +set(CPACK_COMPONENT_AUTOSTART_DESCRIPTION "If enabled, launches Apollo automatically on system startup.") set(CPACK_COMPONENT_AUTOSTART_GROUP "Core") # assets @@ -140,6 +151,12 @@ set(CPACK_COMPONENT_ASSETS_DESCRIPTION "Shaders, default box art, and web UI.") set(CPACK_COMPONENT_ASSETS_GROUP "Core") set(CPACK_COMPONENT_ASSETS_REQUIRED true) +# drivers +set(CPACK_COMPONENT_SUDOVDA_DISPLAY_NAME "SudoVDA") +set(CPACK_COMPONENT_SUDOVDA_DESCRIPTION "Driver required for Virtual Display to function.") +set(CPACK_COMPONENT_SUDOVDA_GROUP "Drivers") +set(CPACK_COMPONENT_SUDOVDA_REQUIRED true) + # audio tool set(CPACK_COMPONENT_AUDIO_DISPLAY_NAME "audio-info") set(CPACK_COMPONENT_AUDIO_DESCRIPTION "CLI tool providing information about sound devices.") diff --git a/src/entry_handler.cpp b/src/entry_handler.cpp index fb1ece2c..1c057c80 100644 --- a/src/entry_handler.cpp +++ b/src/entry_handler.cpp @@ -140,7 +140,7 @@ namespace service_ctrl { return; } - service_handle = OpenServiceA(scm_handle, "SunshineService", service_desired_access); + service_handle = OpenServiceA(scm_handle, "ApolloService", service_desired_access); if (!service_handle) { auto winerr = GetLastError(); BOOST_LOG(error) << "OpenService() failed: "sv << winerr; diff --git a/src_assets/windows/drivers/sudovda/SudoVDA.inf b/src_assets/windows/drivers/sudovda/SudoVDA.inf new file mode 100644 index 0000000000000000000000000000000000000000..f9753d4274627c977b1eab6bad62eb242f4cbc23 GIT binary patch literal 3646 zcmbuCZBJuG6vxkN6Tia^kwlYHX+c+Q`T{6)4T};UB)S@cy|5B$OWN*Mve~b${{C}1 z%-p*aSvQm3JDoYt&-b6dJNBu4VjU~&*j`&{WBbW^wq;Gbwvk;eZUv*?OKvZ1VpDF% z-2WC%582(?3r+@h6KKpi=~^q?9s~P|{}(oc!vy@Ut=MOF7C4CG9D0TQU?-fe1e_fk z0zYN-?bN^>BZPMq_&eUKuRYwN*O+dxWl6ya)GMPtfqf z{sd}uL0J~LfY%uN>_K4|Y%^W>;SCfo;4|Pk3m83kUBgQr$fc2vU!vhgcuLnzYw&Dx zvca>3b(;1Jdp!$u+>^_sbe}#&i!L!E4MsuI3C~9GqO>gGwwZCOLpE!Wk!ug_WX%EZ zWG`{bqw}1Y7~v_m-w?iq9bv~YC%@jqO2eCAt#szmEeos?N&lBuRhpC?$4H zH%J+MJ6+^U6}yS8hOC$`?wyAzMTkE@?z!zFTO-8y3fkYYQ~}&3v#_61H)Sb=Jf$X|kSXU_{1ecF& z;;CxQhcl-MVY8Rx{OEVCRp&$q|5s9NL&{COM?|sm zdU@2iw$+Iy_7CT?N~Fl^SJaFWdim@VA$?Y<@;O0k)gY%5r#$uI2^v*zH-hZD+^Awq z&`NXTEc_eRDCD~27LL+JD<>P2_-BeVc?_sBYcg;T=`D`ZPIGIF0rk1}dx&~)n~aTq zEW%_wfP%VE0o5_jGQ*tW_1B9WOL^+}@6&hg)hNwlLli!wU-v`&$ZpCV+3Dj~(n2$v zD0^3P*_Ta?FgteloRQt9{f1}g8Y{M z^#!7dJ5q|1enG#`w0#SNtm*XsJ3FLp{W~U)tAhTiKIs#3(qjz?PKieGS|fVAB1)A1jbF0eRRF)c-rDajjuP%D4M~lWGo+SxPsTxw^WX$ zdeNO{F<4gXnfr!99A>Cp80``4l7$`X$&!g>OS z9{9;OJTN+H zoBV|HMA?IFI*~`(D;E0pnQjqYK67{CLc5%L(|{WHIcq*8mGkyVJ@lAqCGq-VhMM3; er;n4pUm5>6`lr|C*MH%;mW#x!ve=?b_!R&od_4RB literal 0 HcmV?d00001 diff --git a/src_assets/windows/drivers/sudovda/install.bat b/src_assets/windows/drivers/sudovda/install.bat new file mode 100644 index 00000000..a7c6a702 --- /dev/null +++ b/src_assets/windows/drivers/sudovda/install.bat @@ -0,0 +1,25 @@ +@echo off + +pushd %~dp0 + +echo ================ +echo Installing cert for the SudoVDA driver... + +certutil -addstore -f root "code_signing.crt" +certutil -addstore -f TrustedPublisher "code_signing.crt" + +echo ================ +echo Removing the old driver... It's OK to show an error if you're installing the driver for the first time. + +nefconc.exe --remove-device-node --hardware-id root\sudomaker\sudovda --class-guid "4D36E968-E325-11CE-BFC1-08002BE10318" + +echo ================ +echo Installing the new driver... + +nefconc.exe --create-device-node --class-name Display --class-guid "4D36E968-E325-11CE-BFC1-08002BE10318" --hardware-id root\sudomaker\sudovda +nefconc.exe --install-driver --inf-path "SudoVDA.inf" + +echo ================ +echo Done! + +popd diff --git a/src_assets/windows/drivers/sudovda/sudovda.cat b/src_assets/windows/drivers/sudovda/sudovda.cat new file mode 100644 index 0000000000000000000000000000000000000000..92f9a4c1f44e24e384f096f25ec144d18d721815 GIT binary patch literal 2439 zcmc&#dsIw$9RJbb&g10Y402@lf&_!J@?#u&i8xo=l;I0&*uwC#wI#rVv2i8 zp9Z3aN=ZgMBpEAF1R*$3gU(o#;*Nx4IEv5!B=KlEV-g*~5t7G5q$D0lx#mMQojK@a zBM8pb$g7BauP5?2k~_oT2|QteSF`x|&OeO|0%fU$F( zy^K*}gFj+X1Sh;otti@cF%yGgE&QOU8MGU@DgKuRA zCHrxmgrsxfva(*p4_FvpeOS=1FY7%)NH(h+z*dgH|B|*czD7n7ou6@L-@bVVd>^qN z!0hq<%rC@84Z(LGQK_T`N~)ms$L6r9Ni~HgM!1q1g9EM;N{zOX5)g!f05BQYDjPZ^ zR$NIZCU6Jy!7ShktOt?Yq12#IenU=jh0|3~#30Hljv~_vijzU$Km2lvSj#{-h*R-> zpc?>E64Rx$L5t$UYbk~zD9R1-)H-vg?K&xtd1dvmTbq>J8dNTXMJb6cp$)a@*jyZA zGlj7cE1Xw}td=i>MjsT2;1hOmvJGz`W!gb|rD?4+zXl@_6V(GK0mMjzL+KU5L`ehz zRS#3PXnWDF9PRThnR3t|Rv~7I?6Rt+dL-u8nmI&Oxv>v87shtWd6GH8Ns5Yx6*Ws` zg){Uf)TDD{(&WWE@#rqi3y<33YP^WB=m)F?Af1%0F0H6=;uUpXOG-{MP$HFRBAWlgDE5FC;6=O*FCfW;A(PIEqoi zS`Z8aDMiQT8gdY10LL*@Z6nlH+GaQ#GU@8nW}wm3FbwJ{om#jiWRt4RF;u!WaXnlo z)iIKvP@MG=uyaiUR!ut>l*hqT8$flKY5)SHqw4QAnu~@x_P*XYKy%D4nyIsOf=7S9 zbK=cH_nX>Q+**a#XtHxfgQoq$q+1P=Q#SI0%^iKL((X(6qhSSQ3iGxpBhsGgrmkH+ zJ2SajYet0c$Z@t|4Rs0kyZkRjiDO>8MP&N7uO)RAKkbivnHX~2bmdG@Nv;5!_onr5 zilzU{EgR5`HCr?1=Y&Eξ58@bG~9m_@huxTSO-OO;1nTHTe+x#yGq*l=mRYukW> z_pxK^yE8i&msTrIS}ZufB_Ypqhh4dL(Voh%Jg1lqc0P%2xkq~zuhG~sqTPLugZ`6i zQRZ4@)1PI|er)sV!n^HL-wbH)=jZD=MAH}Aa*PQQxke3PJ+-3Ygs%+mm${;{%cWu! z9Yql~fl@l4|B+4%j9{s(dN}GMzfpumP(4(!b>R=6a5!Ot8!N6R59=GSG(TCoEumk; z%dLFUp5=M-k)MFZ&!{R(zNXq$idHza@v=+ZmzCWcn0ZWag;z{o9Da6LB`tCHt94~Q zp&kM=OVF|Q`gzAna$P@OLU{dgwI@U~bfEC^^Ryf3il!fBW~U7e<#yfk7(f4_aP5zZ z-1OFM9n|a%!$~UYJ&yg3Qa$~`gp4|*o^e_LI*b4vv literal 0 HcmV?d00001 diff --git a/src_assets/windows/drivers/sudovda/uninstall.bat b/src_assets/windows/drivers/sudovda/uninstall.bat new file mode 100644 index 00000000..107d6ffb --- /dev/null +++ b/src_assets/windows/drivers/sudovda/uninstall.bat @@ -0,0 +1,9 @@ +@echo off + +pushd %~dp0 + +nefconc.exe --remove-device-node --hardware-id root\sudomaker\sudovda --class-guid "4D36E968-E325-11CE-BFC1-08002BE10318" + +popd + +pause diff --git a/src_assets/windows/misc/autostart/autostart-service.bat b/src_assets/windows/misc/autostart/autostart-service.bat index 13c6b6bc..0f40c9db 100644 --- a/src_assets/windows/misc/autostart/autostart-service.bat +++ b/src_assets/windows/misc/autostart/autostart-service.bat @@ -1,4 +1,4 @@ @echo off rem Set the service to auto-start -sc config SunshineService start= auto +sc config ApolloService start= auto diff --git a/src_assets/windows/misc/firewall/add-firewall-rule.bat b/src_assets/windows/misc/firewall/add-firewall-rule.bat index 81d5dd92..7543ee5b 100644 --- a/src_assets/windows/misc/firewall/add-firewall-rule.bat +++ b/src_assets/windows/misc/firewall/add-firewall-rule.bat @@ -3,7 +3,7 @@ rem Get sunshine root directory for %%I in ("%~dp0\..") do set "ROOT_DIR=%%~fI" -set RULE_NAME=Sunshine +set RULE_NAME=Apollo set PROGRAM_BIN="%ROOT_DIR%\sunshine.exe" rem Add the rule diff --git a/src_assets/windows/misc/firewall/delete-firewall-rule.bat b/src_assets/windows/misc/firewall/delete-firewall-rule.bat index 3ab0d4e9..df73cf8a 100644 --- a/src_assets/windows/misc/firewall/delete-firewall-rule.bat +++ b/src_assets/windows/misc/firewall/delete-firewall-rule.bat @@ -1,6 +1,6 @@ @echo off -set RULE_NAME=Sunshine +set RULE_NAME=Apollo rem Delete the rule netsh advfirewall firewall delete rule name=%RULE_NAME% diff --git a/src_assets/windows/misc/service/install-service.bat b/src_assets/windows/misc/service/install-service.bat index 03ce6e62..e81803ab 100644 --- a/src_assets/windows/misc/service/install-service.bat +++ b/src_assets/windows/misc/service/install-service.bat @@ -3,7 +3,7 @@ rem Get sunshine root directory for %%I in ("%~dp0\..") do set "ROOT_DIR=%%~fI" -set SERVICE_NAME=SunshineService +set SERVICE_NAME=ApolloService set SERVICE_BIN="%ROOT_DIR%\tools\sunshinesvc.exe" rem Set service to demand start. It will be changed to auto later if the user selected that option. @@ -13,7 +13,7 @@ rem Remove the legacy SunshineSvc service net stop sunshinesvc sc delete sunshinesvc -rem Check if SunshineService already exists +rem Check if ApolloService already exists sc qc %SERVICE_NAME% > nul 2>&1 if %ERRORLEVEL%==0 ( rem Stop the existing service if running @@ -27,10 +27,10 @@ if %ERRORLEVEL%==0 ( ) rem Run the sc command to create/reconfigure the service -sc %SC_CMD% %SERVICE_NAME% binPath= %SERVICE_BIN% start= %SERVICE_START_TYPE% DisplayName= "Sunshine Service" +sc %SC_CMD% %SERVICE_NAME% binPath= %SERVICE_BIN% start= %SERVICE_START_TYPE% DisplayName= "Apollo Service" rem Set the description of the service -sc description %SERVICE_NAME% "Sunshine is a self-hosted game stream host for Moonlight." +sc description %SERVICE_NAME% "Apollo is a self-hosted game stream host for Moonlight." rem Start the new service net start %SERVICE_NAME% diff --git a/src_assets/windows/misc/service/uninstall-service.bat b/src_assets/windows/misc/service/uninstall-service.bat index 451ceb61..cf09b995 100644 --- a/src_assets/windows/misc/service/uninstall-service.bat +++ b/src_assets/windows/misc/service/uninstall-service.bat @@ -4,6 +4,6 @@ rem Stop and delete the legacy SunshineSvc service net stop sunshinesvc sc delete sunshinesvc -rem Stop and delete the new SunshineService service -net stop SunshineService -sc delete SunshineService +rem Stop and delete the new ApolloService service +net stop ApolloService +sc delete ApolloService diff --git a/tools/sunshinesvc.cpp b/tools/sunshinesvc.cpp index da0849e2..bb76f7f0 100644 --- a/tools/sunshinesvc.cpp +++ b/tools/sunshinesvc.cpp @@ -18,7 +18,7 @@ SERVICE_STATUS service_status; HANDLE stop_event; HANDLE session_change_event; -#define SERVICE_NAME "SunshineService" +#define SERVICE_NAME "ApolloService" DWORD WINAPI HandlerEx(DWORD dwControl, DWORD dwEventType, LPVOID lpEventData, LPVOID lpContext) { diff --git a/vite.config.js b/vite.config.js index 8732f1a0..9360af5a 100644 --- a/vite.config.js +++ b/vite.config.js @@ -43,6 +43,7 @@ export default defineConfig({ root: resolve(assetsSrcPath), build: { outDir: resolve(assetsDstPath), + emptyOutDir: true, rollupOptions: { input: { apps: resolve(assetsSrcPath, 'apps.html'),