Skip to content
This repository was archived by the owner on Feb 3, 2022. It is now read-only.

Commit 0be3c8f

Browse files
authored
Merge pull request #264 from randen/win802a
Improve silent install functionality (Windows)
2 parents b51bc68 + 1e0d786 commit 0be3c8f

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

hptool/os-extras/win/templates/Nsisfile.nsi.mu

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
!Include "WordFunc.nsh"
1616
!Include "CreateInternetShortcut.nsh"
1717
!Include "x64.nsh"
18+
!insertmacro GetParameters
19+
!insertmacro GetOptions
1820

1921
;--------------------------------
2022
;Defines
@@ -30,6 +32,7 @@
3032

3133
Var START_MENU_FOLDER
3234
Var PROGRAM_FILES
35+
Var STACK_INSTALL_DIR
3336

3437
;--------------------------------
3538
;General settings
@@ -39,7 +42,15 @@
3942
OutFile "{{productFile}}"
4043

4144
;Default install dir
45+
; Set as appropriate for 32-bit or 64-bit OS
46+
{{#build64bit}}
47+
InstallDir "$PROGRAMFILES64\Haskell Platform\${PLATFORM_VERSION}"
48+
{{/build64bit}}
49+
50+
{{^build64bit}}
4251
InstallDir "$PROGRAMFILES\Haskell Platform\${PLATFORM_VERSION}"
52+
{{/build64bit}}
53+
4354
InstallDirRegKey HKLM "${PRODUCT_DIR_REG_KEY}" ""
4455

4556
;Icon
@@ -83,38 +94,29 @@ CheckAdminDone:
8394
; The 'isInstall' argument is 1 for the install part of the script (from
8495
; .onInit function) and 0 if for the uninstall part (via un.onInit). The
8596
; $INSTDIR must be changed for the installation step to account for the case
86-
; of installing the 32-bit installer onto 64-bit Windows; and and it must
97+
; of installing the 32-bit installer onto 64-bit Windows; and it must
8798
; happen before the user gets to the dialog to change installation location.
8899
; On the other hand, $INSTDIR must *not* be changed for the uninstall step
89100
; because doing so over-rides what the user did during the install step.
90101
;
91102
; Also, do not force $INSTDIR to change if this is a silent install.
92103
SetRegView 32
93104
StrCpy $PROGRAM_FILES "$PROGRAMFILES"
94-
${IfNot} ${Silent}
95-
${If} ${isInstall} = 1
96-
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
97-
${EndIf}
98-
${EndIf}
99105
{{#build64bit}}
100106
${If} ${RunningX64}
101107
; If this is installing the 64-bit HP on 64-bit Windows, enable FSRedirection.
102108
${EnableX64FSRedirection}
103109
; enable access to 64-bit portion of registry
104110
SetRegView 64
105111
StrCpy $PROGRAM_FILES "$PROGRAMFILES64"
106-
${IfNot} ${Silent}
107-
${If} ${isInstall} = 1
108-
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
109-
${EndIf}
110-
${EndIf}
111112
${Else}
112113
; pop up an error message: Cannot install 64-bit HP on 32-bit Windows
113114
MessageBox MB_OK "You are trying to install the 64-bit version of the Haskell Platform onto a 32-bit version of Windows. Please use the 32-bit version of the Haskell Platform."
114115
SetErrorLevel 0x800401FAL ; CO_E_WRONGOSFORAPP
115116
Quit
116117
${EndIf}
117118
{{/build64bit}}
119+
118120
!macroend
119121

120122
;--------------------------------
@@ -175,6 +177,11 @@ Function .onInit
175177
SetShellVarContext all
176178
SectionSetSize 0 {{mainInstalledSize}} ; 0 is ${SecMain} but the symbol is not defined yet
177179
SectionSetSize 1 {{stackInstalledSize}} ; 1 is ${SecStack}
180+
; /STACK switch to the HP installer for setting the stack install dir
181+
${GetParameters} $R0
182+
${GetOptions} $R0 "/STACK=" $STACK_INSTALL_DIR
183+
StrCmp $STACK_INSTALL_DIR "" +2
184+
StrCpy $STACK_INSTALL_DIR "/D=$STACK_INSTALL_DIR"
178185
FunctionEnd
179186

180187
Function un.onInit
@@ -267,7 +274,11 @@ Section "Base components" SecMain
267274
File "{{stackInstallerPath}}"
268275
DetailPrint "installing Stack"
269276
SetDetailsPrint listonly
270-
ExecWait '"$INSTDIR\temp\{{stackInstallerFileName}}" /S'
277+
${If} ${Silent}
278+
ExecWait '"$INSTDIR\temp\{{stackInstallerFileName}}" /S $STACK_INSTALL_DIR'
279+
${Else}
280+
ExecWait '"$INSTDIR\temp\{{stackInstallerFileName}}" $STACK_INSTALL_DIR'
281+
${EndIf}
271282
SetDetailsPrint lastused
272283
DetailPrint "finished Stack"
273284
Delete "$INSTDIR\temp\{{stackInstallerFileName}}"

hptool/src/OS/Win/WinNsis.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ genNsisFiles = do
130130
mainSize <- getDirContentSize filterEmptyDirs winTargetDir
131131
let nsisCtx = expandNsisInfo rls bc ift
132132
ctx = nsisCtx `ctxAppend` pCtx
133-
stackSize = 37 * 1024 * 1024 -- not sure how to actually determine
133+
stackSize = 48 * 1024 * 1024 -- not sure how to automatically determine
134134
ift = InfoForTemplate pFile nFile stackFile stackSize mainSize
135135
copyExpandedFile ctx templ nFile
136136

0 commit comments

Comments
 (0)