Skip to content

Commit

Permalink
Merge pull request #466 from ericpre/no_shortcuts_argument_cli
Browse files Browse the repository at this point in the history
Add option to disable creation of start menu shortcuts and fix regression
  • Loading branch information
mcg1969 authored Dec 29, 2021
2 parents 1c3e0d5 + 69dd7f7 commit 08a8ad3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
17 changes: 17 additions & 0 deletions constructor/nsis/OptionsDialog.nsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ Var mui_AnaCustomOptions.AddToPath
Var mui_AnaCustomOptions.RegisterSystemPython
Var mui_AnaCustomOptions.PostInstall
Var mui_AnaCustomOptions.ClearPkgCache
Var mui_AnaCustomOptions.CreateShortcuts

# These are the checkbox states, to be used by the installer
Var Ana_AddToPath_State
Var Ana_RegisterSystemPython_State
Var Ana_PostInstall_State
Var Ana_ClearPkgCache_State
Var Ana_CreateShortcuts_State

Var Ana_AddToPath_Label
Var Ana_RegisterSystemPython_Label
Expand All @@ -37,6 +39,9 @@ Function mui_AnaCustomOptions_InitDefaults
${Else}
StrCpy $Ana_RegisterSystemPython_State ${BST_CHECKED}
${EndIf}
${If} $Ana_CreateShortcuts_State == ""
StrCpy $Ana_CreateShortcuts_State ${BST_CHECKED}
${EndIf}
${EndIf}
FunctionEnd

Expand All @@ -60,6 +65,12 @@ Function mui_AnaCustomOptions_Show
"Advanced Installation Options" \
"Customize how ${NAME} integrates with Windows"


${NSD_CreateCheckbox} 0 0u 100% 11u "Create start menu shortcuts (supported packages only)."
Pop $mui_AnaCustomOptions.CreateShortcuts
${NSD_SetState} $mui_AnaCustomOptions.CreateShortcuts $Ana_CreateShortcuts_State
${NSD_OnClick} $mui_AnaCustomOptions.CreateShortcuts CreateShortcuts_OnClick

${If} $InstMode = ${JUST_ME}
StrCpy $1 "my"
${Else}
Expand Down Expand Up @@ -188,3 +199,9 @@ Function ClearPkgCache_OnClick
${EndIf}
ShowWindow $Ana_ClearPkgCache_Label ${SW_SHOW}
FunctionEnd

Function CreateShortcuts_OnClick
Pop $0
${NSD_GetState} $0 $Ana_CreateShortcuts_State

FunctionEnd
2 changes: 1 addition & 1 deletion constructor/nsis/_nsis.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def mk_menus(remove=False, prefix=None, pkg_names=None, root_prefix=None):
for fn in os.listdir(menu_dir):
if not fn.endswith('.json'):
continue
if pkg_names is not None and fn[:-5] not in pkg_names:
if pkg_names is not None and len(pkg_names) > 0 and fn[:-5] not in pkg_names:
# skip when not in the list of menus to create
# when installing, the pkg_names list is specified, otherwise not
# and we don't skip to try to remove shortcuts
Expand Down
23 changes: 19 additions & 4 deletions constructor/nsis/main.nsi.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Unicode "true"
!define DEFAULT_PREFIX_DOMAIN_USER __DEFAULT_PREFIX_DOMAIN_USER__
!define DEFAULT_PREFIX_ALL_USERS __DEFAULT_PREFIX_ALL_USERS__
!define POST_INSTALL_DESC __POST_INSTALL_DESC__
!define MENU_PKGS "@MENU_PKGS@"
!define PRODUCT_NAME "${NAME} ${VERSION} (${ARCH})"
!define UNINSTALL_NAME "@UNINSTALL_NAME@"
!define UNINSTREG "SOFTWARE\Microsoft\Windows\CurrentVersion\
Expand All @@ -53,6 +54,7 @@ var /global ARGV_KeepPkgCache
var /global ARGV_RegisterPython
var /global ARGV_NoRegistry
var /global ARGV_NoScripts
var /global ARGV_NoShortcuts
var /global ARGV_CheckPathLength

var /global IsDomainUser
Expand Down Expand Up @@ -187,6 +189,7 @@ FunctionEnd
/RegisterPython=[0|1] [default: AllUsers: 1, JustMe: 0]$\n$\n\
/NoRegistry=[0|1] [default: AllUsers: 0, JustMe: 0]$\n$\n\
/NoScripts=[0|1] [default: 0]$\n$\n\
/NoShortcuts=[0|1] [default: 0]$\n$\n\
/CheckPathLength=[0|1] [default: 1]$\n$\n\
Examples:$\n\
Install for all users, but don't add to PATH env var:$\n\
Expand Down Expand Up @@ -250,6 +253,16 @@ 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}
${EndIf}
${EndIf}

ClearErrors
${GetOptions} $ARGV "/CheckPathLength=" $ARGV_CheckPathLength
${IfNot} ${Errors}
Expand Down Expand Up @@ -900,10 +913,12 @@ Section "Install"
SetOutPath "$INSTDIR\conda-meta"
File __CONDA_HISTORY__

DetailPrint "Creating @NAME@ menus..."
push '"$INSTDIR\_conda.exe" constructor --prefix "$INSTDIR" --make-menus @MENU_PKGS@'
push 'Failed to create menus'
call AbortRetryNSExecWait
${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'
call AbortRetryNSExecWait
${EndIf}

push '"$INSTDIR\pythonw.exe" -E -s "$INSTDIR\Lib\_nsis.py" mkdirs'
push 'Failed to initialize Anaconda directories'
Expand Down

0 comments on commit 08a8ad3

Please sign in to comment.