From 88b4a5d835b7b4f640a0ac292fd0a5c184d27489 Mon Sep 17 00:00:00 2001 From: Ryan Volz Date: Mon, 22 Jan 2024 12:03:29 -0500 Subject: [PATCH] Update NSIS template customization for latest constructor. --- constructor/nsis/main.nsi.tmpl | 36 ++++++++++++++--------------- constructor/nsis/main.nsi.tmpl.orig | 36 ++++++++++++++--------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/constructor/nsis/main.nsi.tmpl b/constructor/nsis/main.nsi.tmpl index 53daa7b..d63ca3a 100644 --- a/constructor/nsis/main.nsi.tmpl +++ b/constructor/nsis/main.nsi.tmpl @@ -57,7 +57,7 @@ Unicode "true" !define DEFAULT_PREFIX_ALL_USERS __DEFAULT_PREFIX_ALL_USERS__ !define PRE_INSTALL_DESC __PRE_INSTALL_DESC__ !define POST_INSTALL_DESC __POST_INSTALL_DESC__ -!define MENU_PKGS "@MENU_PKGS@" +!define ENABLE_SHORTCUTS __ENABLE_SHORTCUTS__ !define SHOW_REGISTER_PYTHON __SHOW_REGISTER_PYTHON__ !define SHOW_ADD_TO_PATH __SHOW_ADD_TO_PATH__ !define PRODUCT_NAME "${NAME} ${VERSION} (${ARCH})" @@ -296,14 +296,18 @@ FunctionEnd ${EndIf} ${EndIf} - ClearErrors - ${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts - ${IfNot} ${Errors} - ${If} $ARGV_NoShortcuts = "1" - StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} - ${ElseIf} $ARGV_NoShortcuts = "0" - StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED} + ${If} "${ENABLE_SHORTCUTS}" == "yes" + ClearErrors + ${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts + ${IfNot} ${Errors} + ${If} $ARGV_NoShortcuts = "1" + StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} + ${ElseIf} $ARGV_NoShortcuts = "0" + StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED} + ${EndIf} ${EndIf} + ${Else} + StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} ${EndIf} ClearErrors @@ -1116,6 +1120,7 @@ Section "Install" @SCRIPT_ENV_VARIABLES@ System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_SAFETY_CHECKS", "disabled").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_EXTRA_SAFETY_CHECKS", "no").r0' + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_PKGS_DIRS", "$INSTDIR\pkgs")".r0' # Extra info for pre and post install scripts # NOTE: If more vars are added, make sure to update the examples/scripts tests too @@ -1163,14 +1168,6 @@ Section "Install" AddSize @SIZE@ - ${If} $Ana_CreateShortcuts_State = ${BST_CHECKED} - DetailPrint "Creating @NAME@ menus..." - push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@' - push 'Failed to create menus' - push 'WithLog' - call AbortRetryNSExecWait - ${EndIf} - #if has_conda is True DetailPrint "Initializing conda directories..." push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs' @@ -1292,10 +1289,11 @@ SectionEnd !macroend Section "Uninstall" - # Remove menu items, path entries + ${LogSet} on - DetailPrint "Deleting @NAME@ menus..." - nsExec::ExecToLog '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --rm-menus' + # Remove menu items, path entries + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0' + @UNINSTALL_MENUS@ # ensure that MSVC runtime DLLs are on PATH during uninstallation ReadEnvStr $0 PATH diff --git a/constructor/nsis/main.nsi.tmpl.orig b/constructor/nsis/main.nsi.tmpl.orig index a2ae2fb..664e79b 100644 --- a/constructor/nsis/main.nsi.tmpl.orig +++ b/constructor/nsis/main.nsi.tmpl.orig @@ -57,7 +57,7 @@ Unicode "true" !define DEFAULT_PREFIX_ALL_USERS __DEFAULT_PREFIX_ALL_USERS__ !define PRE_INSTALL_DESC __PRE_INSTALL_DESC__ !define POST_INSTALL_DESC __POST_INSTALL_DESC__ -!define MENU_PKGS "@MENU_PKGS@" +!define ENABLE_SHORTCUTS __ENABLE_SHORTCUTS__ !define SHOW_REGISTER_PYTHON __SHOW_REGISTER_PYTHON__ !define SHOW_ADD_TO_PATH __SHOW_ADD_TO_PATH__ !define PRODUCT_NAME "${NAME} ${VERSION} (${ARCH})" @@ -296,14 +296,18 @@ FunctionEnd ${EndIf} ${EndIf} - ClearErrors - ${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts - ${IfNot} ${Errors} - ${If} $ARGV_NoShortcuts = "1" - StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} - ${ElseIf} $ARGV_NoShortcuts = "0" - StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED} + ${If} "${ENABLE_SHORTCUTS}" == "yes" + ClearErrors + ${GetOptions} $ARGV "/NoShortcuts=" $ARGV_NoShortcuts + ${IfNot} ${Errors} + ${If} $ARGV_NoShortcuts = "1" + StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} + ${ElseIf} $ARGV_NoShortcuts = "0" + StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED} + ${EndIf} ${EndIf} + ${Else} + StrCpy $Ana_CreateShortcuts_State ${BST_UNCHECKED} ${EndIf} ClearErrors @@ -1116,6 +1120,7 @@ Section "Install" @SCRIPT_ENV_VARIABLES@ System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_SAFETY_CHECKS", "disabled").r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_EXTRA_SAFETY_CHECKS", "no").r0' + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0' System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_PKGS_DIRS", "$INSTDIR\pkgs")".r0' # Extra info for pre and post install scripts # NOTE: If more vars are added, make sure to update the examples/scripts tests too @@ -1163,14 +1168,6 @@ Section "Install" AddSize @SIZE@ - ${If} $Ana_CreateShortcuts_State = ${BST_CHECKED} - DetailPrint "Creating @NAME@ menus..." - push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@' - push 'Failed to create menus' - push 'WithLog' - call AbortRetryNSExecWait - ${EndIf} - #if has_conda is True DetailPrint "Initializing conda directories..." push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs' @@ -1272,10 +1269,11 @@ SectionEnd !macroend Section "Uninstall" - # Remove menu items, path entries + ${LogSet} on - DetailPrint "Deleting @NAME@ menus..." - nsExec::ExecToLog '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --rm-menus' + # Remove menu items, path entries + System::Call 'kernel32::SetEnvironmentVariable(t,t)i("CONDA_ROOT_PREFIX", "$INSTDIR")".r0' + @UNINSTALL_MENUS@ # ensure that MSVC runtime DLLs are on PATH during uninstallation ReadEnvStr $0 PATH