diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-09-09 09:30:54 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-09-13 21:23:51 +0000 |
commit | ec5f5780a11ca1e2019f3d5b7bf6a9a64aa0b144 (patch) | |
tree | 58b0e09a1c6f18e4bc30959de62bdf8448492757 /packaging | |
parent | aa44e3b75da316bb9ee3237c401042afa36db7d8 (diff) | |
download | wireshark-ec5f5780a11ca1e2019f3d5b7bf6a9a64aa0b144.tar.gz |
NSIS: Look for an installed WiX package.
Dig through the registry and look for a WiX / Windows Installer package.
Offer to uninstall it if we find one.
Change-Id: I513ce4184880571c484461483a3d25e6d90a85e0
Reviewed-on: https://code.wireshark.org/review/17613
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'packaging')
-rw-r--r-- | packaging/nsis/config.nsh.in | 1 | ||||
-rw-r--r-- | packaging/nsis/wireshark.nsi | 66 |
2 files changed, 63 insertions, 4 deletions
diff --git a/packaging/nsis/config.nsh.in b/packaging/nsis/config.nsh.in index c119d04fd4..69212541e6 100644 --- a/packaging/nsis/config.nsh.in +++ b/packaging/nsis/config.nsh.in @@ -4,6 +4,7 @@ # Do not prefix comments with ";". They will be removed by CMake. +# MUST match "<Product ... Name=" in wix/Wireshark.wxs. !define PROGRAM_NAME "@PROGRAM_NAME@" !define TOP_SRC_DIR "@TOP_SRC_DIR@" !define STAGING_DIR "@STAGING_DIR@" diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index 83d41ca1c2..672bfecc28 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -205,11 +205,19 @@ Associate.end: Pop $R0 FunctionEnd +; NSIS Var OLD_UNINSTALLER Var OLD_INSTDIR Var OLD_DISPLAYNAME Var TMP_UNINSTALLER +; WiX +Var REGISTRY_BITS +Var TMP_PRODUCT_GUID +Var WIX_DISPLAYNAME +Var WIX_DISPLAYVERSION +Var WIX_UNINSTALLSTRING + ; ============================================================================ ; 64-bit support ; ============================================================================ @@ -270,16 +278,17 @@ lbl_winversion_unsupported_xp_2003: lbl_winversion_supported: !insertmacro IsWiresharkRunning + ; Look for an NSIS-installed package. ; Copied from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new ReadRegStr $OLD_UNINSTALLER HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ "UninstallString" - StrCmp $OLD_UNINSTALLER "" done + StrCmp $OLD_UNINSTALLER "" check_wix ReadRegStr $OLD_INSTDIR HKLM \ "Software\Microsoft\Windows\CurrentVersion\App Paths\${PROGRAM_NAME}.exe" \ "Path" - StrCmp $OLD_INSTDIR "" done + StrCmp $OLD_INSTDIR "" check_wix ReadRegStr $OLD_DISPLAYNAME HKLM \ "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \ @@ -290,14 +299,14 @@ lbl_winversion_supported: "$OLD_DISPLAYNAME is already installed.\ $\n$\nWould you like to uninstall it first?" \ /SD IDYES \ - IDYES prep_uninstaller \ + IDYES prep_nsis_uninstaller \ IDNO done Abort ; Copy the uninstaller to $TEMP and run it. ; The uninstaller normally does this by itself, but doesn't wait around ; for the executable to finish, which means ExecWait won't work correctly. -prep_uninstaller: +prep_nsis_uninstaller: ClearErrors StrCpy $TMP_UNINSTALLER "$TEMP\${PROGRAM_NAME}_uninstaller.exe" ; ...because we surround UninstallString in quotes. @@ -309,7 +318,56 @@ prep_uninstaller: Delete "$TMP_UNINSTALLER" +; Look for a WiX-installed package. + +check_wix: + StrCpy $REGISTRY_BITS 64 + SetRegView 64 + check_wix_restart: + StrCpy $0 0 + wix_reg_enum_loop: + EnumRegKey $TMP_PRODUCT_GUID HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" $0 + StrCmp $TMP_PRODUCT_GUID "" wix_enum_reg_done + IntOp $0 $0 + 1 + ReadRegStr $WIX_DISPLAYNAME HKLM \ + "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$TMP_PRODUCT_GUID" \ + "DisplayName" + ; MessageBox MB_OK|MB_ICONINFORMATION "Reading HKLM SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$1 DisplayName = $2" + ; Look for "Wireshark". + StrCmp $WIX_DISPLAYNAME "${PROGRAM_NAME}" wix_found wix_reg_enum_loop + + wix_found: + ReadRegStr $WIX_DISPLAYVERSION HKLM \ + "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$TMP_PRODUCT_GUID" \ + "DisplayVersion" + ReadRegStr $WIX_UNINSTALLSTRING HKLM \ + "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$TMP_PRODUCT_GUID" \ + "UninstallString" + StrCmp $WIX_UNINSTALLSTRING "" done + MessageBox MB_YESNOCANCEL|MB_ICONQUESTION \ + "$WIX_DISPLAYNAME $WIX_DISPLAYVERSION (msi) is already installed.\ + $\n$\nWould you like to uninstall it first?" \ + /SD IDYES \ + IDYES prep_wix_uninstaller \ + IDNO done + Abort + + ; Run the WiX-provided UninstallString. + prep_wix_uninstaller: + ClearErrors + ExecWait "$WIX_UNINSTALLSTRING" + + Goto done + + wix_enum_reg_done: + MessageBox MB_OK|MB_ICONINFORMATION "Checked $0 $REGISTRY_BITS bit keys" + IntCmp $REGISTRY_BITS 32 done + StrCpy $REGISTRY_BITS 32 + SetRegView 32 + Goto check_wix_restart + done: + ;Extract InstallOptions INI files !insertmacro MUI_INSTALLOPTIONS_EXTRACT "AdditionalTasksPage.ini" !insertmacro MUI_INSTALLOPTIONS_EXTRACT "WinpcapPage.ini" |