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

Commit bf574e8

Browse files
committed
Work around 2GB payload limit of NSIS
The installer framework currently used for HP (the open source project NSIS) uses a 32-bit-centric file format (apparently) and thus has a limitation of 2GB as the maximum size of a blob that can be included. After investigating numerous alternatives, the simplest work-around seemed to be just to bundle and silently install a number of child installers, breaking the actual HP payload into three logical components: GHC, MSys, Stack, and the HP-specific pre-built packages. Three additional installer scripts are added here, to build 3 of the new child-installers (stack is already packaged with its own NSIS installer, so that is happily used unmodified), along with the necessarily bookkeeping to populate an NSI file from a template, and shake rules to build these installers at the right time with needed contents. Further, the original NSI file is modified to add some new UI (for stack) and create the NSI install-time actions to launch the new child-installers as necessary. * hptool/os-extras/win/templates/Extralibs.nsi.mu * New. Template (using the "Mustache" syntax) for the additional pre-built HP-installed packages. * hptool/os-extras/win/templates/GHC.nsi.mu * New. Template (using the "Mustache" syntax) for everything that is part of the GHC pre-built binary distribution. * hptool/os-extras/win/templates/MSys.nsi.mu * New. Template (using the "Mustache" syntax) for the MSys content. * hptool/os-extras/win/templates/Nsisfile.nsi.mu * In addition to the changes already mentioned above, some white space clean up to make it easy to read. Add a public-service annoucement at the end of the installation to explain to users that they may see a brief "pop-up" window immediately after closing the installer (it is ghc running to update the package spec; this action is not new but the PSA is). * hptool/src/OS/Win.hs * Build rules for the new sub-installers * hptool/src/OS/Win/WinNsis.hs * The rules for building the NSI file from the template * hptool/src/OS/Win/WinPaths.hs * Paths for all the new sub-installer templates, output files, etc. * hptool/src/OS/Win/WinRules.hs * Replace the rule invocations for the NSIS generation. For stack, the linux-ish platforms simply copy the stack executable but for Windows, there is an installer and it is launched as part of the HP install, so remove the action here to copy the stack executable.
1 parent 31efb47 commit bf574e8

File tree

8 files changed

+943
-71
lines changed

8 files changed

+943
-71
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
;; WARNING: Extralibs.nsi is automatically generated from Extralibs.nsi.mu by
2+
;; the hptool. Make sure you are editing the template not the generated file.
3+
4+
5+
; Extralibs Installer
6+
7+
;--------------------------------
8+
;Includes
9+
10+
!Include "FileFunc.nsh"
11+
!Include "StrFunc.nsh"
12+
!Include "LogicLib.nsh"
13+
!Include "MUI2.nsh"
14+
!Include "WordFunc.nsh"
15+
!Include "x64.nsh"
16+
17+
;--------------------------------
18+
;Defines
19+
20+
!Define GHC_VERSION "{{ghcVersion}}"
21+
!Define PLATFORM_VERSION "{{hpVersion}}"
22+
!Define PRODUCT_DIR_REG_KEY "Software\Haskell\Haskell Platform\${PLATFORM_VERSION}"
23+
!Define HACKAGE_SHORTCUT_TEXT "HackageDB - Haskell Software Repository"
24+
!Define FILES_SOURCE_PATH "{{targetFiles}}"
25+
!Define INST_DAT "Extralibs_inst.dat"
26+
!Define UNINST_DAT "Extralibs_uninst.dat"
27+
28+
;--------------------------------
29+
;Variables
30+
31+
Var PROGRAM_FILES
32+
33+
;--------------------------------
34+
;General settings
35+
36+
;Name and file
37+
Name "Haskell Platform ${PLATFORM_VERSION} {{is32or64}}-bit"
38+
OutFile "{{productFile}}"
39+
40+
;Default install dir
41+
InstallDir "$PROGRAMFILES\Haskell Platform\${PLATFORM_VERSION}"
42+
InstallDirRegKey HKLM "${PRODUCT_DIR_REG_KEY}" ""
43+
44+
;Icon
45+
!Define MUI_ICON "icons/installer.ico"
46+
!Define MUI_UNICON "icons/installer.ico"
47+
48+
;Request application privileges for Windows Vista
49+
RequestExecutionLevel highest
50+
51+
;Best available compression
52+
SetCompressor /SOLID lzma
53+
54+
;Install types
55+
InstType "Standard"
56+
InstType "Portable (just unpack the files)"
57+
58+
;--------------------------------
59+
;Macros
60+
61+
!macro CheckAdmin thing
62+
UserInfo::GetAccountType
63+
pop $0
64+
${If} $0 != "admin" ;Require admin rights on NT4+
65+
MessageBox MB_YESNO "It is recommended to run this ${thing} as administrator. Do you want to quit and restart the ${thing} manually with elevated privileges?" IDNO CheckAdminDone
66+
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
67+
Quit
68+
${EndIf}
69+
CheckAdminDone:
70+
!macroend
71+
72+
;--------------------------------
73+
;Win 64-bit support
74+
75+
!macro do64Stuff isInstall
76+
; The NSIS installer is a 32-bit executable, but it can do a 64-bit install.
77+
; Default to 32-bit, change if installing 64-bit on 64-bit.
78+
;
79+
; The 'isInstall' argument is 1 for the install part of the script (from
80+
; .onInit function) and 0 if for the uninstall part (via un.onInit). The
81+
; $INSTDIR must be changed for the installation step to account for the case
82+
; of installing the 32-bit installer onto 64-bit Windows; and and it must
83+
; happen before the user gets to the dialog to change installation location.
84+
; On the other hand, $INSTDIR must *not* be changed for the uninstall step
85+
; because doing so over-rides what the user did during the install step.
86+
;
87+
; Also, do not force $INSTDIR to change if this is a silent install.
88+
SetRegView 32
89+
StrCpy $PROGRAM_FILES "$PROGRAMFILES"
90+
${IfNot} ${Silent}
91+
${If} ${isInstall} = 1
92+
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
93+
${EndIf}
94+
${EndIf}
95+
{{#build64bit}}
96+
${If} ${RunningX64}
97+
; If this is installing the 64-bit HP on 64-bit Windows, enable FSRedirection.
98+
${EnableX64FSRedirection}
99+
; enable access to 64-bit portion of registry
100+
SetRegView 64
101+
StrCpy $PROGRAM_FILES "$PROGRAMFILES64"
102+
${IfNot} ${Silent}
103+
${If} ${isInstall} = 1
104+
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
105+
${EndIf}
106+
${EndIf}
107+
${Else}
108+
; pop up an error message: Cannot install 64-bit HP on 32-bit Windows
109+
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."
110+
SetErrorLevel 0x800401FAL ; CO_E_WRONGOSFORAPP
111+
Quit
112+
${EndIf}
113+
{{/build64bit}}
114+
!macroend
115+
116+
;--------------------------------
117+
;Callbacks
118+
119+
Function .onInit
120+
!insertmacro do64Stuff 1
121+
!insertmacro CheckAdmin "installer"
122+
SetShellVarContext all
123+
FunctionEnd
124+
125+
Function un.onInit
126+
!insertmacro do64Stuff 0
127+
!insertmacro CheckAdmin "uninstaller"
128+
SetShellVarContext all
129+
FunctionEnd
130+
131+
;--------------------------------
132+
;Interface Settings
133+
134+
!define MUI_ABORTWARNING
135+
136+
;--------------------------------
137+
;Pages
138+
139+
!Define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp"
140+
!insertmacro MUI_PAGE_WELCOME
141+
!insertmacro MUI_PAGE_LICENSE "LICENSE"
142+
!insertmacro MUI_PAGE_DIRECTORY
143+
144+
!Define MUI_COMPONENTSPAGE_NODESC
145+
!insertmacro MUI_PAGE_COMPONENTS
146+
147+
!insertmacro MUI_PAGE_INSTFILES
148+
!insertmacro MUI_PAGE_FINISH
149+
150+
!insertmacro MUI_UNPAGE_WELCOME
151+
!insertmacro MUI_UNPAGE_CONFIRM
152+
!insertmacro MUI_UNPAGE_INSTFILES
153+
!insertmacro MUI_UNPAGE_FINISH
154+
155+
;--------------------------------
156+
;Languages
157+
158+
!insertmacro MUI_LANGUAGE "English"
159+
160+
;--------------------------------
161+
;Installer Sections
162+
163+
Section "Base components" SecMain
164+
165+
SectionIn 1 2
166+
; Make this section mandatory
167+
SectionIn RO
168+
169+
!Include ${INST_DAT}
170+
171+
SectionEnd
172+
173+
Section "Create uninstaller" SecAddRem
174+
175+
SectionIn 1
176+
SectionIn RO
177+
178+
;Create uninstaller
179+
WriteUninstaller "$INSTDIR\Extralibs_Uninstall.exe"
180+
181+
SectionEnd
182+
183+
;--------------------------------
184+
;Uninstaller Section
185+
186+
Section "Uninstall"
187+
188+
!Include ${UNINST_DAT}
189+
190+
Delete "$INSTDIR\Extralibs_Uninstall.exe"
191+
192+
SectionEnd
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
;; WARNING: GHC.nsi is automatically generated from GHC.nsi.mu by
2+
;; the hptool. Make sure you are editing the template not the generated file.
3+
4+
5+
; GHC Installer
6+
7+
;--------------------------------
8+
;Includes
9+
10+
!Include "FileFunc.nsh"
11+
!Include "StrFunc.nsh"
12+
!Include "LogicLib.nsh"
13+
!Include "MUI2.nsh"
14+
!Include "WordFunc.nsh"
15+
!Include "x64.nsh"
16+
17+
;--------------------------------
18+
;Defines
19+
20+
!Define GHC_VERSION "{{ghcVersion}}"
21+
!Define PLATFORM_VERSION "{{hpVersion}}"
22+
!Define PRODUCT_DIR_REG_KEY "Software\Haskell\Haskell Platform\${PLATFORM_VERSION}"
23+
!Define HACKAGE_SHORTCUT_TEXT "HackageDB - Haskell Software Repository"
24+
!Define FILES_SOURCE_PATH "{{targetFiles}}"
25+
!Define INST_DAT "GHC_inst.dat"
26+
!Define UNINST_DAT "GHC_uninst.dat"
27+
28+
;--------------------------------
29+
;Variables
30+
31+
Var PROGRAM_FILES
32+
33+
;--------------------------------
34+
;General settings
35+
36+
;Name and file
37+
Name "Haskell Platform ${PLATFORM_VERSION} {{is32or64}}-bit"
38+
OutFile "{{productFile}}"
39+
40+
;Default install dir
41+
InstallDir "$PROGRAMFILES\Haskell Platform\${PLATFORM_VERSION}"
42+
InstallDirRegKey HKLM "${PRODUCT_DIR_REG_KEY}" ""
43+
44+
;Icon
45+
!Define MUI_ICON "icons/installer.ico"
46+
!Define MUI_UNICON "icons/installer.ico"
47+
48+
;Request application privileges for Windows Vista
49+
RequestExecutionLevel highest
50+
51+
;Best available compression
52+
SetCompressor /SOLID lzma
53+
54+
;Install types
55+
InstType "Standard"
56+
InstType "Portable (just unpack the files)"
57+
58+
;--------------------------------
59+
;Macros
60+
61+
!macro CheckAdmin thing
62+
UserInfo::GetAccountType
63+
pop $0
64+
${If} $0 != "admin" ;Require admin rights on NT4+
65+
MessageBox MB_YESNO "It is recommended to run this ${thing} as administrator. Do you want to quit and restart the ${thing} manually with elevated privileges?" IDNO CheckAdminDone
66+
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
67+
Quit
68+
${EndIf}
69+
CheckAdminDone:
70+
!macroend
71+
72+
;--------------------------------
73+
;Win 64-bit support
74+
75+
!macro do64Stuff isInstall
76+
; The NSIS installer is a 32-bit executable, but it can do a 64-bit install.
77+
; Default to 32-bit, change if installing 64-bit on 64-bit.
78+
;
79+
; The 'isInstall' argument is 1 for the install part of the script (from
80+
; .onInit function) and 0 if for the uninstall part (via un.onInit). The
81+
; $INSTDIR must be changed for the installation step to account for the case
82+
; of installing the 32-bit installer onto 64-bit Windows; and and it must
83+
; happen before the user gets to the dialog to change installation location.
84+
; On the other hand, $INSTDIR must *not* be changed for the uninstall step
85+
; because doing so over-rides what the user did during the install step.
86+
;
87+
; Also, do not force $INSTDIR to change if this is a silent install.
88+
SetRegView 32
89+
StrCpy $PROGRAM_FILES "$PROGRAMFILES"
90+
${IfNot} ${Silent}
91+
${If} ${isInstall} = 1
92+
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
93+
${EndIf}
94+
${EndIf}
95+
{{#build64bit}}
96+
${If} ${RunningX64}
97+
; If this is installing the 64-bit HP on 64-bit Windows, enable FSRedirection.
98+
${EnableX64FSRedirection}
99+
; enable access to 64-bit portion of registry
100+
SetRegView 64
101+
StrCpy $PROGRAM_FILES "$PROGRAMFILES64"
102+
${IfNot} ${Silent}
103+
${If} ${isInstall} = 1
104+
StrCpy $INSTDIR "$PROGRAM_FILES\Haskell Platform\${PLATFORM_VERSION}"
105+
${EndIf}
106+
${EndIf}
107+
${Else}
108+
; pop up an error message: Cannot install 64-bit HP on 32-bit Windows
109+
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."
110+
SetErrorLevel 0x800401FAL ; CO_E_WRONGOSFORAPP
111+
Quit
112+
${EndIf}
113+
{{/build64bit}}
114+
!macroend
115+
116+
;--------------------------------
117+
;Callbacks
118+
119+
Function .onInit
120+
!insertmacro do64Stuff 1
121+
!insertmacro CheckAdmin "installer"
122+
SetShellVarContext all
123+
FunctionEnd
124+
125+
Function un.onInit
126+
!insertmacro do64Stuff 0
127+
!insertmacro CheckAdmin "uninstaller"
128+
SetShellVarContext all
129+
FunctionEnd
130+
131+
;--------------------------------
132+
;Interface Settings
133+
134+
!define MUI_ABORTWARNING
135+
136+
;--------------------------------
137+
;Pages
138+
139+
!Define MUI_WELCOMEFINISHPAGE_BITMAP "welcome.bmp"
140+
!insertmacro MUI_PAGE_WELCOME
141+
!insertmacro MUI_PAGE_LICENSE "LICENSE"
142+
!insertmacro MUI_PAGE_DIRECTORY
143+
144+
!Define MUI_COMPONENTSPAGE_NODESC
145+
!insertmacro MUI_PAGE_COMPONENTS
146+
147+
!insertmacro MUI_PAGE_INSTFILES
148+
!insertmacro MUI_PAGE_FINISH
149+
150+
!insertmacro MUI_UNPAGE_WELCOME
151+
!insertmacro MUI_UNPAGE_CONFIRM
152+
!insertmacro MUI_UNPAGE_INSTFILES
153+
!insertmacro MUI_UNPAGE_FINISH
154+
155+
;--------------------------------
156+
;Languages
157+
158+
!insertmacro MUI_LANGUAGE "English"
159+
160+
;--------------------------------
161+
;Installer Sections
162+
163+
Section "Base components" SecMain
164+
165+
SectionIn 1 2
166+
; Make this section mandatory
167+
SectionIn RO
168+
169+
!Include ${INST_DAT}
170+
171+
SectionEnd
172+
173+
Section "Create uninstaller" SecAddRem
174+
175+
SectionIn 1
176+
SectionIn RO
177+
178+
;Create uninstaller
179+
WriteUninstaller "$INSTDIR\GHC_Uninstall.exe"
180+
181+
SectionEnd
182+
183+
;--------------------------------
184+
;Uninstaller Section
185+
186+
Section "Uninstall"
187+
188+
!Include ${UNINST_DAT}
189+
190+
Delete "$INSTDIR\GHC_Uninstall.exe"
191+
192+
SectionEnd

0 commit comments

Comments
 (0)