diff options
Diffstat (limited to 'build-aux/speedo/w32/inst.nsi')
-rw-r--r-- | build-aux/speedo/w32/inst.nsi | 143 |
1 files changed, 88 insertions, 55 deletions
diff --git a/build-aux/speedo/w32/inst.nsi b/build-aux/speedo/w32/inst.nsi index 7716f7f0e..297ef06ae 100644 --- a/build-aux/speedo/w32/inst.nsi +++ b/build-aux/speedo/w32/inst.nsi @@ -1,5 +1,6 @@ # inst.nsi - Installer for GnuPG on Windows. -*- coding: latin-1; -*- # Copyright (C) 2005, 2014 g10 Code GmbH +# 2017 Intevation GmbH # # This file is part of GnuPG. # @@ -42,7 +43,7 @@ !define PRETTY_PACKAGE "GNU Privacy Guard" !define PRETTY_PACKAGE_SHORT "GnuPG" !define COMPANY "The GnuPG Project" -!define COPYRIGHT "Copyright (C) 2015 The GnuPG Project" +!define COPYRIGHT "Copyright (C) 2017 The GnuPG Project" !define DESCRIPTION "GnuPG: The GNU Privacy Guard for Windows" !define INSTALL_DIR "GnuPG" @@ -80,9 +81,6 @@ SetCompressor lzma # SetCompressorDictSize 8 !endif -# Include the generic parts. -!define HAVE_STARTMENU - # We use the modern UI. !include "MUI.nsh" @@ -90,6 +88,17 @@ SetCompressor lzma !include "LogicLib.nsh" !include "x64.nsh" +# We support user mode installation but prefer system wide +!define MULTIUSER_EXECUTIONLEVEL Highest +!define MULTIUSER_MUI +!define MULTIUSER_INSTALLMODE_COMMANDLINE +!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "Software\${PACKAGE_SHORT}" +!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "" +!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "Software\${PACKAGE_SHORT}" +!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "Install Directory" +!define MULTIUSER_INSTALLMODE_INSTDIR "${PACKAGE_SHORT}" +!include "MultiUser.nsh" + # Set the package name. Note that this name should not be suffixed # with the version because this would get displayed in the start menu. # Given that a slash in the name troubles Windows startmenu creation @@ -109,9 +118,6 @@ OutFile "${NAME}-${VERSION}_${BUILD_DATESTR}.exe" !endif InstallDir "$PROGRAMFILES\${INSTALL_DIR}" -InstallDirRegKey HKLM "Software\${PACKAGE_SHORT}" "Install Directory" - - # Add version information to the file properties. VIProductVersion "${PROD_VERSION}" VIAddVersionKey "ProductName" "${PRETTY_PACKAGE_SHORT} (${VERSION})" @@ -161,7 +167,7 @@ VIAddVersionKey "FileVersion" "${PROD_VERSION}" # We don't have MUI_PAGE_DIRECTORY -!ifdef HAVE_STARTMENU +!ifdef WITH_GUI Page custom CustomPageOptions @@ -169,7 +175,7 @@ Var STARTMENU_FOLDER !define MUI_PAGE_CUSTOMFUNCTION_PRE CheckIfStartMenuWanted !define MUI_STARTMENUPAGE_NODISABLE -!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" +!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\GnuPG" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" # We need to set the Startmenu name explicitly because a slash in the @@ -354,6 +360,8 @@ FunctionEnd # OS version without the need for an Administrator is in use. Print a # diagnostic if this is not the case and abort installation. Function PrintNonAdminWarning + Var /GLOBAL is_user_install + StrCpy $is_user_install "0" ClearErrors UserInfo::GetName IfErrors leave @@ -361,9 +369,11 @@ Function PrintNonAdminWarning UserInfo::GetAccountType Pop $1 StrCmp $1 "Admin" leave +1 - MessageBox MB_OK "$(T_AdminNeeded)" - Quit - + MessageBox MB_YESNO "$(T_AdminWanted)" IDNO exit + StrCpy $is_user_install "1" + goto leave + exit: + Quit leave: FunctionEnd @@ -446,24 +456,30 @@ LangString T_FoundExistingVersion ${LANG_GERMAN} \ eine neuere oder dieselbe Version handelt.)" LangString T_FoundExistingVersionB ${LANG_ENGLISH} \ "A version of GnuPG has already been installed on the system. \ - There will be no problem installing and thus overwriting this \ - Version. $\r$\n\ + $\r$\n\ $\r$\n\ Do you want to continue installing GnuPG?" LangString T_FoundExistingVersionB ${LANG_GERMAN} \ "Eine Version von GnuPG ist hier bereits installiert. \ - Es ist problemlos m�glich, die Installation fortzuf�hren. $\r$\n\ + $\r$\n\ $\r$\n\ M�chten die die Installation von GnuPG fortf�hren?" # From Function PrintNonAdminWarning -LangString T_AdminNeeded ${LANG_ENGLISH} \ - "Warning: Administrator permissions required for a successful installation" -LangString T_AdminNeeded ${LANG_GERMAN} \ - "Achtung: F�r eine erfolgreiche Installation werden \ - Administratorrechte ben�tigt." +LangString T_AdminWanted ${LANG_ENGLISH} \ + "Warning: It is recommended to install GnuPG system-wide with \ + administrator rights. \ + $\r$\n\ + $\r$\n\ + Do you want to continue installing GnuPG without administrator rights?" +LangString T_AdminWanted ${LANG_GERMAN} \ + "Achtung: Es wird empfohlen GnuPG systemweit mit \ + Administratorrechten zu installieren. \ + $\r$\n\ + $\r$\n\ + M�chten die die Installation von GnuPG ohne Administratorrechte fortf�hren?" # From Function PrintCloseOtherApps LangString T_CloseOtherApps ${LANG_ENGLISH} \ @@ -505,7 +521,7 @@ FunctionEnd # Input - head of the stack Function AddToPath Exch $0 - g4wihelp::path_add "$0" + g4wihelp::path_add "$0" $is_user_install StrCmp $R5 "0" add_to_path_done SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 add_to_path_done: @@ -516,8 +532,24 @@ FunctionEnd # RemoveFromPath - Remove a given dir from the path # Input: head of the stack Function un.RemoveFromPath + ClearErrors + UserInfo::GetName + IfErrors remove_admin + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" remove_admin remove_user + +remove_admin: + Exch $0 + g4wihelp::path_remove "$0" "0" + goto remove_done +remove_user: Exch $0 - g4wihelp::path_remove "$0" + g4wihelp::path_remove "$0" "1" + goto remove_done + +remove_done: StrCmp $R5 "0" remove_from_path_done SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 remove_from_path_done: @@ -540,7 +572,7 @@ Section "-gnupginst" FileWrite $0 "${VERSION}$\r$\n" FileClose $0 - WriteRegStr HKLM "Software\GnuPG" "Install Directory" $INSTDIR + WriteRegStr SHCTX "Software\GnuPG" "Install Directory" $INSTDIR # If we are reinstalling, try to kill a possible running gpa using # an already installed gpa. @@ -1381,7 +1413,7 @@ Section "-un.gnupginst" RMDir "$INSTDIR" # Clean the registry. - DeleteRegValue HKLM "Software\GNU\GnuPG" "Install Directory" + DeleteRegValue SHCTX "Software\GNU\GnuPG" "Install Directory" SectionEnd @@ -1409,8 +1441,25 @@ Function .onInit !insertmacro MUI_INSTALLOPTIONS_EXTRACT "${W32_SRCDIR}/inst-options.ini" #Call CalcDepends + + Var /GLOBAL changed_dir + # Check if the install directory was modified on the command line + StrCmp "$INSTDIR" "$PROGRAMFILES\${INSTALL_DIR}" unmodified 0 + # It is modified. Save that value. + StrCpy $changed_dir "$INSTDIR" + + # MULITUSER_INIT overwrites directory setting from command line + !insertmacro MULTIUSER_INIT + StrCpy $INSTDIR "$changed_dir" + goto initDone +unmodified: + !insertmacro MULTIUSER_INIT +initDone: FunctionEnd +Function "un.onInit" + !insertmacro MULTIUSER_UNINIT +FunctionEnd #Function .onInstFailed # Delete $TEMP\gpgspltmp.wav @@ -1439,13 +1488,6 @@ FunctionEnd !ifdef WITH_GUI Section "-startmenu" -!ifdef HAVE_STARTMENU - # Make sure that the context of the automatic variables has been set to - # the "all users" shell folder. This guarantees that the menu gets written - # for all users. We have already checked that we are running as Admin; or - # we printed a warning that installation will not succeed. - SetShellVarContext all - # Check if the start menu entries where requested. !insertmacro MUI_INSTALLOPTIONS_READ $R0 "${W32_SRCDIR}/inst-options.ini" \ "Field 2" "State" @@ -1517,7 +1559,6 @@ no_gpa_quicklaunch: no_quick_launch: -!endif SectionEnd !endif @@ -1533,30 +1574,23 @@ Section # Windows Add/Remove Programs support StrCpy $MYTMP "Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuPG" - WriteRegExpandStr HKLM $MYTMP "UninstallString" '"$INSTDIR\gnupg-uninstall.exe"' - WriteRegExpandStr HKLM $MYTMP "InstallLocation" "$INSTDIR" - WriteRegStr HKLM $MYTMP "DisplayName" "${PRETTY_PACKAGE}" + WriteRegExpandStr SHCTX $MYTMP "UninstallString" '"$INSTDIR\gnupg-uninstall.exe"' + WriteRegExpandStr SHCTX $MYTMP "InstallLocation" "$INSTDIR" + WriteRegStr SHCTX $MYTMP "DisplayName" "${PRETTY_PACKAGE}" !ifdef WITH_GUI - WriteRegStr HKLM $MYTMP "DisplayIcon" "$INSTDIR\bin\gpa.exe,0" + WriteRegStr SHCTX $MYTMP "DisplayIcon" "$INSTDIR\bin\gpa.exe,0" +!else + WriteRegStr SHCTX $MYTMP "DisplayIcon" "$INSTDIR\bin\gpg.exe,0" !endif - WriteRegStr HKLM $MYTMP "DisplayVersion" "${VERSION}" - WriteRegStr HKLM $MYTMP "Publisher" "The GnuPG Project" - WriteRegStr HKLM $MYTMP "URLInfoAbout" "https://gnupg.org" - WriteRegDWORD HKLM $MYTMP "NoModify" "1" - WriteRegDWORD HKLM $MYTMP "NoRepair" "1" + WriteRegStr SHCTX $MYTMP "DisplayVersion" "${VERSION}" + WriteRegStr SHCTX $MYTMP "Publisher" "The GnuPG Project" + WriteRegStr SHCTX $MYTMP "URLInfoAbout" "https://gnupg.org" + WriteRegDWORD SHCTX $MYTMP "NoModify" "1" + WriteRegDWORD SHCTX $MYTMP "NoRepair" "1" SectionEnd - Section Uninstall - !ifdef WITH_GUI -!ifdef HAVE_STARTMENU - # Make sure that the context of the automatic variables has been set to - # the "all users" shell folder. This guarantees that the menu gets written - # for all users. We have already checked that we are running as Admin; or - # we printed a warning that installation will not succeed. - SetShellVarContext all - #--------------------------------------------------- # Delete the menu entries and any empty parent menus #--------------------------------------------------- @@ -1574,7 +1608,7 @@ Section Uninstall StrCmp $MYTMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop startMenuDeleteLoopDone: - DeleteRegValue HKLM "Software\GNU\GnuPG" "Start Menu Folder" + DeleteRegValue SHCTX "Software\GNU\GnuPG" "Start Menu Folder" # Delete Desktop links. Delete "$DESKTOP\GPA.lnk" @@ -1587,14 +1621,13 @@ Section Uninstall no_quick_launch_uninstall: !endif -!endif Delete "$INSTDIR\gnupg-uninstall.exe" RMDir "$INSTDIR" # Clean the registry. - DeleteRegValue HKLM "Software\GnuPG" "Install Directory" - DeleteRegKey /ifempty HKLM "Software\GnuPG" + DeleteRegValue SHCTX "Software\GnuPG" "Install Directory" + DeleteRegKey /ifempty SHCTX "Software\GnuPG" # Remove Windows Add/Remove Programs support. - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuPG" + DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\GnuPG" SectionEnd |