139 lines
4.7 KiB
NSIS
139 lines
4.7 KiB
NSIS
; Media Server NSIS Installer
|
|
; Cross-compilable: apt install nsis && makensis -DVERSION="1.0.0" installer.nsi
|
|
|
|
!include "MUI2.nsh"
|
|
!include "FileFunc.nsh"
|
|
|
|
; --- Configuration ---
|
|
!define APPNAME "Media Server"
|
|
!define EXENAME "media-server.bat"
|
|
!define VBSNAME "start-hidden.vbs"
|
|
!ifndef VERSION
|
|
!define VERSION "0.0.0"
|
|
!endif
|
|
|
|
Name "${APPNAME} ${VERSION}"
|
|
OutFile "build\MediaServer-v${VERSION}-setup.exe"
|
|
InstallDir "$LOCALAPPDATA\${APPNAME}"
|
|
RequestExecutionLevel user
|
|
|
|
; --- UI ---
|
|
; To use a custom icon, convert icon.svg to icon.ico and uncomment:
|
|
; !define MUI_ICON "media_server\static\icons\icon.ico"
|
|
; !define MUI_UNICON "media_server\static\icons\icon.ico"
|
|
!define MUI_ABORTWARNING
|
|
!define MUI_FINISHPAGE_RUN "wscript.exe"
|
|
!define MUI_FINISHPAGE_RUN_PARAMETERS '"$INSTDIR\scripts\${VBSNAME}"'
|
|
!define MUI_FINISHPAGE_RUN_TEXT "Launch ${APPNAME}"
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
!insertmacro MUI_PAGE_COMPONENTS
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_PAGE_FINISH
|
|
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
; --- Sections ---
|
|
Section "!Core (required)" SecCore
|
|
SectionIn RO
|
|
|
|
; Stop running instance if any
|
|
nsExec::ExecToLog 'taskkill /F /IM python.exe /FI "WINDOWTITLE eq media_server*"'
|
|
|
|
SetOutPath "$INSTDIR"
|
|
|
|
; Copy entire distribution
|
|
File /r "dist\media-server\*.*"
|
|
|
|
; Create uninstaller
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
|
|
; Start Menu shortcuts
|
|
CreateDirectory "$SMPROGRAMS\${APPNAME}"
|
|
CreateShortcut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" \
|
|
"wscript.exe" '"$INSTDIR\scripts\${VBSNAME}"' \
|
|
"$INSTDIR\python\python.exe" 0
|
|
CreateShortcut "$SMPROGRAMS\${APPNAME}\${APPNAME} (Console).lnk" \
|
|
"$INSTDIR\${EXENAME}" "" \
|
|
"$INSTDIR\python\python.exe" 0
|
|
CreateShortcut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" \
|
|
"$INSTDIR\uninstall.exe"
|
|
|
|
; Registry for Add/Remove Programs
|
|
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"DisplayName" "${APPNAME}"
|
|
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"UninstallString" "$\"$INSTDIR\uninstall.exe$\""
|
|
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"InstallLocation" "$INSTDIR"
|
|
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"Publisher" "Alexei Dolgolyov"
|
|
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"NoModify" 1
|
|
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"NoRepair" 1
|
|
|
|
; Calculate installed size
|
|
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
|
|
IntFmt $0 "0x%08X" $0
|
|
WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" \
|
|
"EstimatedSize" "$0"
|
|
SectionEnd
|
|
|
|
Section "Desktop shortcut" SecDesktop
|
|
CreateShortcut "$DESKTOP\${APPNAME}.lnk" \
|
|
"wscript.exe" '"$INSTDIR\scripts\${VBSNAME}"' \
|
|
"$INSTDIR\python\python.exe" 0
|
|
SectionEnd
|
|
|
|
Section "Start with Windows" SecAutostart
|
|
; Create Startup folder shortcut (runs hidden via VBS)
|
|
CreateShortcut "$SMSTARTUP\${APPNAME}.lnk" \
|
|
"wscript.exe" '"$INSTDIR\scripts\${VBSNAME}"' \
|
|
"$INSTDIR\python\python.exe" 0
|
|
SectionEnd
|
|
|
|
; --- Section descriptions ---
|
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecCore} \
|
|
"Core application files, embedded Python, and Start Menu shortcuts."
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} \
|
|
"Create a desktop shortcut to launch ${APPNAME}."
|
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecAutostart} \
|
|
"Automatically start ${APPNAME} when you log in to Windows."
|
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
|
|
|
; --- Uninstaller ---
|
|
Section "Uninstall"
|
|
; Stop running instance
|
|
nsExec::ExecToLog 'taskkill /F /IM python.exe /FI "WINDOWTITLE eq media_server*"'
|
|
|
|
; Remove application files
|
|
RMDir /r "$INSTDIR\python"
|
|
RMDir /r "$INSTDIR\app"
|
|
RMDir /r "$INSTDIR\scripts"
|
|
Delete "$INSTDIR\${EXENAME}"
|
|
Delete "$INSTDIR\VERSION"
|
|
Delete "$INSTDIR\uninstall.exe"
|
|
|
|
; Preserve config.yaml (user data) — only remove the example
|
|
Delete "$INSTDIR\config.example.yaml"
|
|
|
|
; Remove shortcuts
|
|
Delete "$DESKTOP\${APPNAME}.lnk"
|
|
Delete "$SMSTARTUP\${APPNAME}.lnk"
|
|
RMDir /r "$SMPROGRAMS\${APPNAME}"
|
|
|
|
; Remove registry
|
|
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
|
|
|
|
; Remove install dir only if empty (config.yaml may remain)
|
|
RMDir "$INSTDIR"
|
|
SectionEnd
|