diff --git a/admin/nt/dist-build/emacs.nsi b/admin/nt/dist-build/emacs.nsi index 557bb106dde..b8226d69423 100644 --- a/admin/nt/dist-build/emacs.nsi +++ b/admin/nt/dist-build/emacs.nsi @@ -8,7 +8,10 @@ Outfile "emacs-${OUT_VERSION}-installer.exe" SetCompressor /solid lzma Var StartMenuFolder +Var UninstallerPath +!define UNINST_KEY \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\emacs-${VERSION_BRANCH}" !define MUI_WELCOMEPAGE_TITLE "Emacs" !define MUI_WELCOMEPAGE_TITLE_3LINES @@ -20,16 +23,27 @@ Var StartMenuFolder !insertmacro MUI_PAGE_WELCOME - -!define MUI_LICENSEPAGE_TEXT_TOP "The GNU General Public License" +# licensing/about click-though page +!define MUI_PAGE_HEADER_TEXT "Emacs is Free Software" +!define MUI_PAGE_HEADER_SUBTEXT "A component of the GNU operating system." +!define MUI_LICENSEPAGE_TEXT_TOP "This program is free software." +!define MUI_LICENSEPAGE_TEXT_BOTTOM "You can redistribute this program and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License (as above), or (at your option) any later version." +!define MUI_LICENSEPAGE_BUTTON "OK" !insertmacro MUI_PAGE_LICENSE "emacs-${VERSION_BRANCH}\share\emacs\${EMACS_VERSION}\lisp\COPYING" +# user option page: installation path !insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES +# user option page: start menu shortcut !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder +# user option confirm/begin install +!insertmacro MUI_PAGE_INSTFILES + +# uninstaller confirmation/options (no options) !insertmacro MUI_UNPAGE_CONFIRM + +# uninstaller begin !insertmacro MUI_UNPAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" @@ -39,23 +53,35 @@ function .onInit StrCpy $INSTDIR "$PROGRAMFILES64\Emacs" functionend - +# main section logic, run after confirming installation Section - SetOutPath $INSTDIR + # insisting on installing shortcuts for "all users" + # might ensure uninstall can remove shortcuts we created + # SetShellVarContext all + # extract program files + SetOutPath $INSTDIR File /r emacs-${VERSION_BRANCH} # define uninstaller name - WriteUninstaller $INSTDIR\Uninstall.exe + StrCpy $UninstallerPath "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" + + # create uninstaller + WriteUninstaller "$UninstallerPath" + + # add registry key to enable uninstall from control panel + WriteRegStr HKLM "${UNINST_KEY}" "DisplayName" "GNU Emacs ${VERSION_BRANCH}" + WriteRegStr HKLM "${UNINST_KEY}" "UninstallString" "$\"$UninstallerPath$\"" - !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory "$SMPROGRAMS\$StartMenuFolder" - CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" - + CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" \ + "$UninstallerPath" + CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Emacs.lnk" \ + "$INSTDIR\emacs-${VERSION_BRANCH}\bin\runemacs.exe" !insertmacro MUI_STARTMENU_WRITE_END - CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Emacs.lnk" "$INSTDIR\emacs-${VERSION_BRANCH}\bin\runemacs.exe" SectionEnd @@ -63,15 +89,50 @@ SectionEnd # the section will always be named "Uninstall" Section "Uninstall" - # Always delete uninstaller first - Delete "$INSTDIR\Uninstall.exe" + # remove All Users shortcuts only + # SetShellVarContext all - # now delete installed directory - RMDir /r "$INSTDIR" - RMDir "$INSTDIR" + # retreive/recalculate uninstaller location + StrCpy $UninstallerPath "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" + # remove registry key + DeleteRegKey HKLM "${UNINST_KEY}" + + # delete uninstaller + Delete "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" + + # retreive/reclculate startmenu shortcuts location !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder + StrCpy $StartMenuFolder "$SMPROGRAMS\$StartMenuFolder" + + # remove Start Menu Program shortcuts + Delete "$StartMenuFolder\Emacs.lnk" + Delete "$StartMenuFolder\Uninstall.lnk" + + # remove empty startmenu parents up to $SMPROGRAMS + startMenuDeleteLoop: + ClearErrors + RMDir $StartMenuFolder + GetFullPathName $StartMenuFolder "$StartMenuFolder\.." + IfErrors startMenuDeleteLoopDone + StrCmp $StartMenuFolder $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop + + # we're basically using GOTO, above, so we should get here.. + startMenuDeleteLoopDone: + + # next we remove stuff from program-files/instalation path + # start with recursive delete of the Emacs we installed + RMDir /r "$INSTDIR\emacs-${VERSION_BRANCH}" + + # now walk parents of installation directory, deleting if empty + instDirDeleteLoop: + ClearErrors + RMDir $INSTDIR + GetFullPathName $INSTDIR "$INSTDIR\.." + IfErrors instDirDeleteLoopDone + StrCmp $INSTDIR $PROGRAMFILES64 instDirDeleteLoopDone instDirDeleteLoop + + # final clean-up (after removing from startmenu and progfiles) + instDirDeleteLoopDone: - Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" - RMDir "$SMPROGRAMS\$StartMenuFolder" SectionEnd