|
|
|
|
|
!searchparse /noerrors /file ..\..\lib\common\utils.py 'VERSION = ' VERSION |
|
|
|
|
|
!define PRODUCT_NAME "cabernet" |
|
!define PRODUCT_VERSION ${VERSION} |
|
!define PRODUCT_PUBLISHER "rocky4546" |
|
!define PRODUCT_WEB_SITE "https://github.com/cabernetwork/cabernet" |
|
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\tvh_main.py" |
|
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" |
|
!define PRODUCT_UNINST_ROOT_KEY "HKLM" |
|
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir" |
|
|
|
|
|
!define MULTIUSER_EXECUTIONLEVEL Highest |
|
!define MULTIUSER_INSTALLMODE_INSTDIR "${PRODUCT_NAME}" |
|
!define MULTIUSER_MUI |
|
!define MULTIUSER_INSTALLMODE_COMMANDLINE |
|
!define MULTIUSER_INSTALLMODE_FUNCTION onMultiUserModeChanged |
|
|
|
|
|
!addplugindir '.\Plugins\inetc\Plugins\x86-unicode' |
|
|
|
!include "MUI.nsh" |
|
!include "MultiUser.nsh" |
|
!include "MUI2.nsh" |
|
!include nsDialogs.nsh |
|
!include "TvhLib.nsh" |
|
|
|
|
|
!define MUI_ABORTWARNING |
|
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" |
|
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" |
|
|
|
|
|
!insertmacro MUI_PAGE_WELCOME |
|
|
|
|
|
!insertmacro MULTIUSER_PAGE_INSTALLMODE |
|
|
|
|
|
|
|
!insertmacro MUI_PAGE_LICENSE "../../LICENSE" |
|
|
|
!insertmacro MUI_PAGE_DIRECTORY |
|
|
|
Page custom DataFolderPage DataFolderPageLeave |
|
|
|
!define MUI_PAGE_CUSTOMFUNCTION_PRE TestPython |
|
!insertmacro MUI_PAGE_COMPONENTS |
|
|
|
var ICONS_GROUP |
|
!define MUI_STARTMENUPAGE_NODISABLE |
|
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "${PRODUCT_NAME}" |
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}" |
|
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}" |
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}" |
|
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP |
|
|
|
!insertmacro MUI_PAGE_INSTFILES |
|
|
|
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt" |
|
!insertmacro MUI_PAGE_FINISH |
|
|
|
|
|
!insertmacro MUI_UNPAGE_INSTFILES |
|
|
|
|
|
!insertmacro MUI_LANGUAGE "English" |
|
|
|
|
|
|
|
|
|
Name "${PRODUCT_NAME}-${PRODUCT_VERSION}" |
|
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe" |
|
InstallDir "$PROGRAMFILES64\${PRODUCT_NAME}" |
|
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" "" |
|
ShowInstDetails show |
|
ShowUnInstDetails show |
|
|
|
Section "Install Python3" SEC01 |
|
SetOutPath "$INSTDIR" |
|
SetOverwrite ifnewer |
|
inetc::get /BANNER "Python3 download in progress..." \ |
|
"https://www.python.org/ftp/python/3.9.5/python-3.9.5-amd64.exe" \ |
|
"$TEMP\python.exe" /END |
|
Pop $0 |
|
StrCmp $0 "OK" dlok |
|
MessageBox MB_OK|MB_ICONEXCLAMATION "ERROR::HTTP Download Error while trying to download Python, $\r$\n\ |
|
$0$\r$\n\ |
|
Click OK to abort installation" /SD IDOK |
|
Abort |
|
dlok: |
|
|
|
nsExec::ExecToStack $pythoninstall |
|
Pop $0 |
|
Pop $1 |
|
IntCmp $0 0 PythonDone |
|
MessageBox MB_OK "Python not installed status:$0, Aborting" |
|
Abort |
|
PythonDone: |
|
|
|
DELETE "$TEMP\python.exe" |
|
|
|
Call TestPythonSilent |
|
${If} $pythonpath == "" |
|
MessageBox MB_OK "Please restart the installer to pick up the python installation, Aborting" |
|
Abort |
|
${EndIf} |
|
|
|
SectionEnd |
|
|
|
Function ClearPythonInstallFlag |
|
SectionSetFlags ${SEC01} 0 |
|
FunctionEnd |
|
|
|
Section "MainSection" SEC02 |
|
SetOutPath "$INSTDIR" |
|
SetOverwrite ifnewer |
|
Call AddFiles |
|
Call UpdateConfig |
|
|
|
|
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
|
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP" |
|
SetOutPath "$INSTDIR" |
|
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\cabernet.lnk" "$INSTDIR\tvh_main.py" |
|
SetOutPath "$INSTDIR" |
|
|
|
!insertmacro MUI_STARTMENU_WRITE_END |
|
SectionEnd |
|
|
|
Section "Windows Service" SEC03 |
|
SetOutPath "$INSTDIR" |
|
SetOverwrite ifnewer |
|
Call InstallService |
|
SectionEnd |
|
|
|
Section "Install FFMPEG" SEC04 |
|
SetOutPath "$INSTDIR" |
|
SetOverwrite ifnewer |
|
inetc::get /BANNER "FFMPEG download in progress..." \ |
|
"https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip" \ |
|
"$TEMP\ffmpeg.zip" /END |
|
Pop $0 |
|
StrCmp $0 "OK" dlok |
|
MessageBox MB_OK|MB_ICONEXCLAMATION "ERROR::HTTP Download Error while trying to download FFMPEG, $\r$\n\ |
|
$0$\r$\n\ |
|
Click OK to abort installation" /SD IDOK |
|
Abort |
|
dlok: |
|
StrCpy $cmd 'powershell expand-archive \"$TEMP\ffmpeg.zip\" \"$TEMP\ffmpeg\"' |
|
nsExec::ExecToStack '$cmd' |
|
Pop $0 |
|
Pop $1 |
|
|
|
|
|
StrCpy $subfolder "$TEMP\ffmpeg\ffmpeg*.*" |
|
Call GetSubfolder |
|
StrCmp $subfolder "" empty |
|
CopyFiles "$TEMP\ffmpeg\$subfolder\bin\*.exe" "$INSTDIR\ffmpeg\bin" |
|
CopyFiles "$TEMP\ffmpeg\$subfolder\LICENSE" "$INSTDIR\ffmpeg" |
|
CopyFiles "$TEMP\ffmpeg\$subfolder\README.txt" "$INSTDIR\ffmpeg" |
|
|
|
empty: |
|
DELETE "$TEMP\ffmpeg.zip" |
|
RMDIR /r "$TEMP\ffmpeg\*.*" |
|
RMDIR "$TEMP\ffmpeg" |
|
SetOutPath "$INSTDIR" |
|
SectionEnd |
|
|
|
|
|
|
|
Section -AdditionalIcons |
|
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
|
WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}" |
|
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" |
|
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninst.exe" |
|
!insertmacro MUI_STARTMENU_WRITE_END |
|
SectionEnd |
|
|
|
|
|
Section -Post |
|
WriteUninstaller "$INSTDIR\uninst.exe" |
|
WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\main.py" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\main.py" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" |
|
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" |
|
SectionEnd |
|
|
|
|
|
|
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN |
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Installs python for all users. Required for the Windows Service" |
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Installs the base app" |
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "Adds a Windows Service using nssm." |
|
!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Installs ffmpeg in app folder. Currently required for most providers" |
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END |
|
|
|
Function onMultiUserModeChanged |
|
${If} $MultiUser.InstallMode == "CurrentUser" |
|
StrCpy $INSTDIR "$LocalAppdata\Programs\${MULTIUSER_INSTALLMODE_INSTDIR}" |
|
StrCpy $pythoninstall '$TEMP\python.exe InstallAllUsers=0 PrependPath=1' |
|
SectionSetFlags ${SEC03} 16 |
|
${Else} |
|
StrCpy $INSTDIR "$PROGRAMFILES64\${PRODUCT_NAME}" |
|
StrCpy $pythoninstall '$TEMP\python.exe InstallAllUsers=1 PrependPath=1' |
|
SectionSetFlags ${SEC03} 1 |
|
${EndIf} |
|
FunctionEnd |
|
|
|
|
|
Function .onInit |
|
StrCpy $DataFolder "C:\Windows\system32\config\systemprofile\Documents\cabernet" |
|
!insertmacro MULTIUSER_INIT |
|
SectionSetFlags ${SEC02} 17 |
|
|
|
SectionSetFlags ${SEC04} 1 |
|
FunctionEnd |
|
|
|
|
|
Function un.onInit |
|
Var /GLOBAL remove_all |
|
!insertmacro MULTIUSER_UNINIT |
|
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name)?" IDYES +2 |
|
Abort |
|
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to remove all data and plugins?" IDYES true2 |
|
StrCpy $remove_all "0" |
|
Goto end2 |
|
true2: |
|
StrCpy $remove_all "1" |
|
end2: |
|
FunctionEnd |
|
|
|
|
|
Function un.onUninstSuccess |
|
HideWindow |
|
MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." |
|
FunctionEnd |
|
|
|
|
|
Section Uninstall |
|
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP |
|
${If} $MultiUser.InstallMode != "CurrentUser" |
|
Call un.installService |
|
${EndIf} |
|
|
|
${If} $remove_all == "1" |
|
RMDIR /r "$INSTDIR\*.*" |
|
${Else} |
|
|
|
RMDIR /r "$INSTDIR\build" |
|
RMDIR /r "$INSTDIR\lib" |
|
RMDIR /r "$INSTDIR\plugins" |
|
|
|
|
|
Delete "$INSTDIR\CHANGE*.*" |
|
Delete "$INSTDIR\Dock*" |
|
Delete "$INSTDIR\LIC*" |
|
Delete "$INSTDIR\READ*.*" |
|
Delete "$INSTDIR\req*.*" |
|
Delete "$INSTDIR\tvh*.*" |
|
Delete "$INSTDIR\uninst.exe" |
|
Delete "$INSTDIR\${PRODUCT_NAME}.url" |
|
${EndIf} |
|
|
|
Delete "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" |
|
Delete "$SMPROGRAMS\$ICONS_GROUP\Website.lnk" |
|
Delete "$DESKTOP\cabernet.lnk" |
|
Delete "$SMPROGRAMS\$ICONS_GROUP\cabernet.lnk" |
|
|
|
RMDir "$SMPROGRAMS\$ICONS_GROUP" |
|
|
|
${If} $remove_all == "1" |
|
RMDir "$INSTDIR" |
|
${EndIf} |
|
|
|
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" |
|
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}" |
|
SetAutoClose true |
|
SectionEnd |
|
|
|
|
|
|
|
|