Upgrades kept ElyMark's old git folder and CEF files. The installer now runs the uninstaller's file list before copying, only when the folder already holds this app's exe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
97 lines
3.2 KiB
NSIS
97 lines
3.2 KiB
NSIS
; Per-user installer; pass APP_NAME, APP_SLUG, VERSION, STAGE, ICON, TYPES.
|
|
Unicode true
|
|
!include "MUI2.nsh"
|
|
|
|
!ifndef APP_NAME
|
|
!error "pass -DAPP_NAME"
|
|
!endif
|
|
!ifndef APP_SLUG
|
|
!error "pass -DAPP_SLUG"
|
|
!endif
|
|
!ifndef VERSION
|
|
!error "pass -DVERSION"
|
|
!endif
|
|
!ifndef STAGE
|
|
!error "pass -DSTAGE, a folder from packaging/stage.sh"
|
|
!endif
|
|
!ifndef ICON
|
|
!error "pass -DICON"
|
|
!endif
|
|
!ifndef TYPES
|
|
!error "pass -DTYPES, from packaging/windows/types.sh"
|
|
!endif
|
|
!include "${TYPES}"
|
|
!ifndef OUTFILE
|
|
!define OUTFILE "${APP_SLUG}-${VERSION}-setup.exe"
|
|
!endif
|
|
!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Ely Office ${APP_NAME}"
|
|
|
|
!define MUI_ICON "${ICON}"
|
|
!define MUI_UNICON "${ICON}"
|
|
Name "${APP_NAME}"
|
|
OutFile "${OUTFILE}"
|
|
RequestExecutionLevel user
|
|
InstallDir "$LOCALAPPDATA\Programs\Ely Office\${APP_NAME}"
|
|
InstallDirRegKey HKCU "Software\Ely Office\${APP_NAME}" "InstallDir"
|
|
SetCompressor /SOLID lzma
|
|
|
|
!insertmacro MUI_PAGE_DIRECTORY
|
|
!insertmacro MUI_PAGE_INSTFILES
|
|
!insertmacro MUI_UNPAGE_CONFIRM
|
|
!insertmacro MUI_UNPAGE_INSTFILES
|
|
!insertmacro MUI_LANGUAGE "SimpChinese"
|
|
!insertmacro MUI_LANGUAGE "English"
|
|
|
|
LangString DeleteData ${LANG_SIMPCHINESE} "同时删除 ${APP_NAME} 的缓存、账号与本地历史吗?你的文档不受影响。"
|
|
LangString DeleteData ${LANG_ENGLISH} "Also delete the cache, accounts and local history of ${APP_NAME}? Your documents stay."
|
|
|
|
!macro ElyRemoveFiles
|
|
; What stage.sh lays out, and nothing else.
|
|
RMDir /r "$INSTDIR\libreoffice"
|
|
RMDir /r "$INSTDIR\tessdata"
|
|
RMDir /r "$INSTDIR\git"
|
|
RMDir /r "$INSTDIR\content"
|
|
RMDir /r "$INSTDIR\locales"
|
|
RMDir /r "$INSTDIR\licenses"
|
|
Delete "$INSTDIR\*.exe"
|
|
Delete "$INSTDIR\*.dll"
|
|
Delete "$INSTDIR\*.pak"
|
|
Delete "$INSTDIR\*.bin"
|
|
Delete "$INSTDIR\*.dat"
|
|
Delete "$INSTDIR\*.json"
|
|
Delete "$INSTDIR\${APP_SLUG}.ico"
|
|
!macroend
|
|
|
|
Section "Install"
|
|
; An older install's files go first, so none linger.
|
|
IfFileExists "$INSTDIR\${APP_SLUG}.exe" 0 fresh
|
|
!insertmacro ElyRemoveFiles
|
|
fresh:
|
|
SetOutPath "$INSTDIR"
|
|
File /r "${STAGE}\*.*"
|
|
File "/oname=${APP_SLUG}.ico" "${ICON}"
|
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
|
CreateShortcut "$SMPROGRAMS\${APP_NAME}.lnk" "$INSTDIR\${APP_SLUG}.exe" "" "$INSTDIR\${APP_SLUG}.ico"
|
|
WriteRegStr HKCU "Software\Ely Office\${APP_NAME}" "InstallDir" "$INSTDIR"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayName" "${APP_NAME}"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "Publisher" "ZacharyZhang"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "URLInfoAbout" "https://zacharyzhang.com"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayVersion" "${VERSION}"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\${APP_SLUG}.ico"
|
|
WriteRegStr HKCU "${UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
|
WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoModify" 1
|
|
!insertmacro ElyTypesInstall
|
|
SectionEnd
|
|
|
|
Section "Uninstall"
|
|
!insertmacro ElyRemoveFiles
|
|
RMDir "$INSTDIR"
|
|
Delete "$SMPROGRAMS\${APP_NAME}.lnk"
|
|
DeleteRegKey HKCU "Software\Ely Office\${APP_NAME}"
|
|
DeleteRegKey HKCU "${UNINSTALL_KEY}"
|
|
!insertmacro ElyTypesUninstall
|
|
MessageBox MB_YESNO|MB_DEFBUTTON2 "$(DeleteData)" IDNO done
|
|
RMDir /r "$LOCALAPPDATA\ElyOffice\${APP_SLUG}"
|
|
done:
|
|
SectionEnd
|