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

Commit d522ddd

Browse files
authored
Merge pull request #261 from randen/win801a3
Windows-only: work around 2GB payload limit of NSIS; plus 2 other
2 parents f5bbba0 + c4d8c90 commit d522ddd

File tree

9 files changed

+955
-76
lines changed

9 files changed

+955
-76
lines changed

hptool/hptool.cabal

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ Executable hptool
5959
text,
6060
transformers
6161

62+
if os(windows)
63+
build-depends:
64+
filepath,
65+
unix-compat
66+
6267
ghc-options: -Wall -fwarn-tabs
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)