[cmake-developers] [CMake 0014397]: CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL mixes settings from versions

Mantis Bug Tracker mantis at public.kitware.com
Tue Sep 10 17:52:25 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14397 
====================================================================== 
Reported By:                David Golub
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14397
Category:                   CPack
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-09-10 17:52 EDT
Last Modified:              2013-09-10 17:52 EDT
====================================================================== 
Summary:                    CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL mixes
settings from versions
Description: 
In order for the CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL to work properly, it
is necessary to use the same registry key for all versions, which causes a
number of problems when installing multiple version of a product side-by-side. 
The simplest of these are that the newer version will be given a start menu
folder named after the older version by default.  Also, the older version's
entry in Add/Remove Programs will be overwritten by the newer version.  There is
also one more issue, which can be reproduced using the following steps given two
versions of a product, Version 1 and Version 2:

1. Install Version 1.
2. Install Version 2.  When prompted to uninstall Version 1, do not do so. 
Change the start menu folder to be different from that used for Version 1.
3. Uninstall Version 1.

When Version 1 is uninstalled, the start menu folder for Version 2 will be
removed, while the start menu folder for Version 1 will remain.

Additional Information: 
The issue can be fixed by using a different registry key for each version
installed and a separate registry key holding the name of the latest version
installed, which will be uninstalled if the user elects to do so when a new
version is installed.  While I have not tried to integrate our fix into CPack's
template, I am providing the code that we are using at Organic Motion to work
around the issue for our products:

  # In theory, prompting to uninstall an old version before installing a new
  # one should be as simple as setting
CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL.
  # However, in practice, the implementation of this option in CMake is very
  # buggy and causes settings from the two versions to get mixed.  Instead, we
  # manually add a modified version of the logic used to implement this option.
  # Our version differs from that provided with CMake in that it stores the
  # uninstallation information for each version in a separate registry key and
  # then uses a separate registry key to store the name of the last version
  # installed for each product.  The version provided with CMake uses a single
  # registry key for each product, causing the settings to get mixed.
  if(OM_PROMPT_UNINSTALL)
    set(OM_EXTRA_INIT_COMMANDS "ReadRegStr $0 HKLM \\\"Software\\\\Organic
Motion\\\\${OM_PRODUCT_NAME}\\\" \\\"LastVersionName\\\"
StrCmp $0 \\\"\\\" not_found
ReadRegStr $1 HKLM
\\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\$0\\\"
\\\"UninstallString\\\"
StrCmp $1 \\\"\\\" not_found
ReadRegStr $2 HKLM
\\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Uninstall\\\\$0\\\"
\\\"DisplayName\\\"
MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \\\"$2 is already
installed.$\\\\n$\\\\nDo you want to uninstall the old version before installing
the new one?\\\" IDYES found IDNO not_found
Abort
found:
ClearErrors
StrLen $3 \\\"\\\\Uninstall.exe\\\"
StrCpy $4 $1 -$3
ExecWait '$1 _?=$4'
IfErrors 0 not_found
MessageBox MB_OK|MB_ICONSTOP \\\"Uninstall failed.\\\"
Abort
not_found:
${OM_EXTRA_INIT_COMMANDS}")
    set(OM_EXTRA_INSTALL_COMMANDS "WriteRegStr HKLM \\\"Software\\\\Organic
Motion\\\\${OM_PRODUCT_NAME}\\\" \\\"LastVersionName\\\" \\\"${OM_PRODUCT_NAME}
${OM_VERSION}\\\"
${OM_EXTRA_INSTALL_COMMANDS}")
  endif(OM_PROMPT_UNINSTALL)
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-09-10 17:52 David Golub    New Issue                                    
======================================================================




More information about the cmake-developers mailing list