* Windows binary installer ignores user options for Start menu shortcuts [not found] ` <DU0PR03MB8163223924C38FDE037C46DEE5002@DU0PR03MB8163.eurprd03.prod.outlook.com> @ 2024-12-21 19:46 ` Corwin Brust 2024-12-21 23:05 ` bug#75013: " Corwin Brust 0 siblings, 1 reply; 3+ messages in thread From: Corwin Brust @ 2024-12-21 19:46 UTC (permalink / raw) To: Francis Wright, bug-gnu-emacs; +Cc: Emacs developers Thanks much for looking into issues/fixes with the binary installer for Windows, Francis! "Promoting" your comments to a bug report here, as I think you've uncovered an undocumented (and fixable + worth fixing) thing. On Sat, Dec 21, 2024 at 12:29 PM Francis Wright <f.j.wright@live.co.uk> wrote: > > Hi Corwin > > Thanks for working on this. The "greedy uninstaller" was a bit of a pain. I tried your installer [] > and the associated uninstaller seems to work correctly, i.e. it only uninstalls emacs-30.0.93, which is great. I didn't notice any of the other issues you listed. > Yay! > However, I did notice a couple of problems. Firstly, Windows pops up a warning from Microsoft Defender SmartScreen, which is not a new problem and is easy to work around. This I think I am not currently able to do much about, alas. > Secondly, the installer did not install a shortcut folder. On the Choose Start Menu Folder dialogue, Emacs-30.0.93 was pre-selected, and I ensured that Do not create shortcuts was not selected. The only button available was the Close button, which I clicked. A shortcut for Emacs itself was installed but not the shortcut to the folder containing Emacs and the uninstaller. (I can add the folder shortcut by hand.) > Thanks for reporting this issue. I confirmed it exists also with the 29.4 released binary installer. When I select "show details" I can see at the end of the unpacking ("installation") processing step it creates start-menu short-cuts; however, the screen where we choose whether or not we want to install short-cuts isn't shown until after the unpacking step -which I now see does short-cut creation, but shouldn't- is completed. There is some code in the nsi script which might be doing the write thing in the wrong place, at first glance. In any case, with the present (for some time) installer we get a "hard-coded" incorrect value for a start menu shortcut that is always created irrespective of relevant choices offered to the user by said installer. Not great. I'll look into fixing this for the 30.1 installer, also, replying back in here if/when I have an "_3" that seems to warrant others' testing effort. Since this "short-cut page ignored" issue doesn't seem already to have been captured in the bug tracker I have directed this reply such as to create a new bug-report. I'll try to arrange to get additional relevant comments I/we make back on devel show up in the new bug report (I don't have the number yet, as I write this), but: feel free to address replies back to original devel thread (or otherwise to this new bug thread) as you think best. > Best wishes, > Francis > Gratefully, Corwin ^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#75013: Windows binary installer ignores user options for Start menu shortcuts 2024-12-21 19:46 ` Windows binary installer ignores user options for Start menu shortcuts Corwin Brust @ 2024-12-21 23:05 ` Corwin Brust 2024-12-22 18:29 ` Corwin Brust 0 siblings, 1 reply; 3+ messages in thread From: Corwin Brust @ 2024-12-21 23:05 UTC (permalink / raw) To: 75013 [-- Attachment #1: Type: text/plain, Size: 2596 bytes --] tags: patch thanks > > I'll look into fixing this for the 30.1 installer, also, replying back > in here if/when I have an "_3" that seems to warrant others' testing > effort. > I'm attaching a (messy, quick) patch which appears to wrap fixing this issue up with fixing those others I've just been asking others to help me close (by testing out patched installers). I will link devel (and OP) rather than here with the (transient, available for some days at least) link to the new version of the installer I've made applying the attached patch (under other cover). I'll report back in (to this bug) with a "stand-alone" patch showing just code needed to resolve this issue (probably for academic purposes, given this consolidated patch works). It should apply to virtually any branch (or release/pre-release source tarball). FTR, it was easy enough to swap reorder things to ensure that the shortcuts got created properly (according to user options, and not prior to asking for input/confirmation of those preferences, as before); however, I had to go to lengths to ensure the uninstaller removes whatever shortcuts it creates. The resulting (seemingly reliable) result is that we now delete empty parent folders (up to the start menu application's folder root) when deleting whatever shortcuts during uninstallation which the given installer had made. I can (and probably should) give the same treatment to the applications folder, removing empty parents of the User's selected install folder, but I think we have enough to test for just now. (The same approach will work; it won't be difficult to add. But let's confirm the recursive delete method works reliably for others). For anyone seeing this and interested in a (slightly) more durable link from which one can follow (by seeing incremental/experimental builds outside of links shared to devel) along, seeing my current version of the attached patch and related binaries using the 30.0.93 (pre-release 3 for Emacs 30) tarball a starting-point, here's an index page: https://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-30/?C=M;O=D Note, when browsing the above link: The "latest" and otherwise (not 30.0.93_N_or_bug) releases are the latest snapshots taken from the emacs-30 branch (so, by now, more recent than the release tarball mentioned above, and without this/these patches, for now). Such builds are named based on the git revision and include the sources used in the given folders. Builds related to installer fixes based on Emacs 30/pretest #3 are within my "Emacs 30 root folder", index to which is linked above. [-- Attachment #2: emacs.nsi.patch --] [-- Type: application/octet-stream, Size: 3646 bytes --] --- emacs.nsi.STABLE 2024-12-21 16:21:09.921280300 -0600 +++ emacs.nsi 2024-12-21 16:24:55.716019400 -0600 @@ -20,16 +20,27 @@ !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,20 +50,24 @@ StrCpy $INSTDIR "$PROGRAMFILES64\Emacs" functionend - +# main section logic, run after confirming installation Section + # insisting on installing shortcuts for "all users" + # might ensure uninstall can remove shortcuts we created + # SetShellVarContext all + SetOutPath $INSTDIR File /r emacs-${VERSION_BRANCH} # define uninstaller name - WriteUninstaller $INSTDIR\Uninstall.exe + WriteUninstaller "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" - CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + CreateShortcut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" !insertmacro MUI_STARTMENU_WRITE_END CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Emacs.lnk" "$INSTDIR\emacs-${VERSION_BRANCH}\bin\runemacs.exe" @@ -63,15 +78,34 @@ # the section will always be named "Uninstall" Section "Uninstall" - # Always delete uninstaller first - Delete "$INSTDIR\Uninstall.exe" - - # now delete installed directory - RMDir /r "$INSTDIR" - RMDir "$INSTDIR" + # remove All Users shortcuts only + # SetShellVarContext all !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 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: + + # recursively delete directory for this version + RMDir /r "$INSTDIR\emacs-${VERSION_BRANCH}" + + # remove the Emacs directory in Program Files (if empty) + RMDir "$INSTDIR" + + # delete uninstaller last + Delete "$INSTDIR\Uninstall-${VERSION_BRANCH}.exe" - Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" - RMDir "$SMPROGRAMS\$StartMenuFolder" SectionEnd ^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#75013: Windows binary installer ignores user options for Start menu shortcuts 2024-12-21 23:05 ` bug#75013: " Corwin Brust @ 2024-12-22 18:29 ` Corwin Brust 0 siblings, 0 replies; 3+ messages in thread From: Corwin Brust @ 2024-12-22 18:29 UTC (permalink / raw) To: 75013 [-- Attachment #1: Type: text/plain, Size: 416 bytes --] Tags: patch Francis reported that a binary built from the previous version of the patch sent to this bug ticket worked but noted that Emacs (unlike many other programs when running on Windows) cannot be uninstalled via Add Remove Programs in the Windows Control Panel. The updated patch (additionally) enables this method of uninstallation as well as removing empty Program Files parent folders when uninstalling. [-- Attachment #2: emacs.nsi.patch --] [-- Type: application/octet-stream, Size: 5030 bytes --] --- emacs.nsi.STABLE 2024-12-21 16:21:09.921280300 -0600 +++ emacs.nsi 2024-12-22 12:02:04.577320200 -0600 @@ -8,7 +8,10 @@ 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 @@ !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 @@ 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 @@ # 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-22 18:29 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <CAJf-WoSAdP=-3YW=piMfQx5Te9d_+6K2JADJfbWRrWKB81=pGw@mail.gmail.com> [not found] ` <DU0PR03MB8163223924C38FDE037C46DEE5002@DU0PR03MB8163.eurprd03.prod.outlook.com> 2024-12-21 19:46 ` Windows binary installer ignores user options for Start menu shortcuts Corwin Brust 2024-12-21 23:05 ` bug#75013: " Corwin Brust 2024-12-22 18:29 ` Corwin Brust
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).