blob: 843a8cf4404cdbbe49084e1782bb7d0f78a75bf5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
#! stdtmpl(subsChar='?') | standard
#proc generateNsisSetup(c: ConfigData): string =
# result = "; NSIS script generated by niminst\n" &
# "; To regenerate run ``niminst nsis`` or ``koch nsis``\n"
;--------------------------------
; Included headers
; Modern User Interface 2.0 Header
!include "MUI2.nsh"
; File Functions Header, used to get the current drive root.
!include "FileFunc.nsh"
; *Patched* Environment Variable Manipulation Header, used to add
; tools to the user's PATH environment variable.
!include "EnvVarUpdate.nsh"
;--------------------------------
; Global variables and defines
!define PRODUCT_NAME "?c.displayName"
!define PRODUCT_VERSION "?c.version"
!define PRODUCT_PUBLISHER "?c.authors"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\?{c.name}.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKCU"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
;--------------------------------
; General Setup Information
; Name and output file
Name "?{c.name} ?{c.version}"
OutFile "?{c.name}_?{c.version}.exe"
; Default installation folder
; This is changed later (in .onInit) to the root directory, if possible.
InstallDir "$LOCALAPPDATA\?{c.name}-?{c.version}"
; Get installation folder from registry if available
InstallDirRegKey HKCU "Software\c.name\c.version" ""
; Request user level application privileges.
RequestExecutionLevel user
; Allow installation to the root drive directory.
AllowRootDirInstall true
; Maximum compression!
SetCompressor /SOLID /FINAL lzma
; Installer and Uninstaller Icons
; Icon "nim.ico"
; UninstallIcon "nim.ico"
; Set installation details to be shown by default
ShowInstDetails show
ShowUnInstDetails show
;--------------------------------
; Interface Settings
; Warn the user if aborting during installation/uninstallation
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
; Don't show a description for sections
!define MUI_COMPONENTSPAGE_NODESC
;--------------------------------
; Pages
; Setup the installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "?{expandFilename(c.license)}"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
; Setup the start menu entry page
var ICONS_GROUP
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "?{c.displayName}"
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "${PRODUCT_STARTMENU_REGVAL}"
!insertmacro MUI_PAGE_STARTMENU Application $ICONS_GROUP
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; Setup the uninstaller pages
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;--------------------------------
;Languages
!insertmacro MUI_LANGUAGE "English"
;--------------------------------
;Installer Sections
; The core section. This is comprised of a base Nim installation,
; such as what would be retrieved via git, and an already bootstrapped
; Nim binary.
Section "Core Files" CoreSection
; This is a mandotory section
SectionIn RO
; Output files to the base installation directory
SetOutPath "$INSTDIR"
; Only overwrite newer files
SetOverwrite ifnewer
; Write all the files to the output directory.
#for i in low(FileCategory)..fcWindows:
# for f in items(c.cat[i]):
SetOutPath "$INSTDIR\?{splitFile(f).dir.toWin}"
File "?{expandFilename(f).toWin}"
# end for
#end for
; Write out the uninstaller
WriteUninstaller "$INSTDIR\uninstaller.exe"
SectionEnd
Section "-Add Registry Keys" RegistrySection
; Write application registry keys
WriteRegStr HKCU "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\bin\?{c.name}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninstaller.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\bin\?{c.name}.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
; Reset the output path
SetOutPath "$INSTDIR"
SectionEnd
; Section for adding the shortcuts related to files and applications
Section "-Setup Shortcuts" ShortcutsSection
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"
#if c.app == appConsole:
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\start.bat"
CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\start.bat"
#else:
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe"
CreateShortCut "$DESKTOP\?{c.displayName}.lnk" "$INSTDIR\?{c.name}.exe"
#end if
; Write the shortcut to the uninstaller
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\uninstaller.exe"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
; Section for adding tools to the PATH variable
Section "Setup Path Environment" PathSection
${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\dist\mingw"
${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\dist\mingw\bin"
${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\bin"
${EnvVarUpdate} $R0 "PATH" "A" "HKCU" "$INSTDIR\dist\babel"
SectionEnd
; The downloadable sections. These sections are automatically generated by
; niminst and the template filters.
#var i = 0
#for download in c.downloads:
# inc i
# let d = download.split('|')
# if d.len != 5 and d.len != 6:
# quit("download string needs 5..6 parts: " & download)
# end if
# let sectionName = d[0]
# let dir = d[1]
# let zipName = d[2]
# let size = d[3]
# let url = d[4]
Section /o "?sectionName" ?{i}Section
; Add the section size to the total size.
AddSize ?size
; Download the file, and if successful, extract it to the given directory
; otherwise,
retry:
NSISdl::download "?url" "$TEMP\?zipName"
Pop $0
${If} $0 == "success"
ZipDLL::extractall "$TEMP\?zipName" "$INSTDIR\?dir"
Delete "$TEMP\?zipName"
${ElseIf} $0 == "cancel"
MessageBox MB_ICONQUESTION|MB_YESNO|MB_TOPMOST \
"Download of component '?sectionName' cancelled. Continue installation process??" \
IDYES ignore
abort
${Else}
MessageBox MB_ICONSTOP|MB_ABORTRETRYIGNORE|MB_TOPMOST "Error: $0" \
IDRETRY retry IDIGNORE ignore
abort
${EndIf}
; Shortcuts
# if d.len >= 6:
# let startMenuEntry = d[5]
# let e = splitFile(startMenuEntry).name.capitalize
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\?{e}.lnk" "$INSTDIR\?dir\?{startMenuEntry.toWin}"
!insertmacro MUI_STARTMENU_WRITE_END
# end if
ignore:
SectionEnd
#end
;--------------------------------
; Section Descriptions
; Series of strings describing each section
; LangString DESC_CoreSection ${LANG_ENGLISH} "Core Nim files"
; The macros to actually insert the descriptions into the sections.
; Each description above should have a corresponding MUI_DESCRIPTION_TEXT
; macro linking the section to the description.
; !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
; !insertmacro MUI_DESCRIPTION_TEXT ${CoreSection} $(DESC_CoreSection)
; !insertmacro MUI_FUNCTION_DESCRIPTION_END
;--------------------------------
; Uninstaller Sections
Section "Uninstall"
; Remove previously created shortcuts
!insertmacro MUI_STARTMENU_GETFOLDER "Application" $ICONS_GROUP
Delete "$DESKTOP\?{c.displayName}.lnk"
; Remove installed application files
RMDir /r "$SMPROGRAMS\$ICONS_GROUP"
RMDir /r "$INSTDIR"
; Remove the previously created registry key
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
DeleteRegKey HKCU "${PRODUCT_DIR_REGKEY}"
SetAutoClose true
; Remove entries from the PATH environment variable
${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\dist\mingw"
${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\dist\mingw\bin"
${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\bin"
${un.EnvVarUpdate} $R0 "PATH" "R" "HKCU" "$INSTDIR\dist\babel"
SectionEnd
;--------------------------------
; Function hooks
Function .onInit
${GetRoot} "$EXEDIR" $R0
strCpy $INSTDIR "$R0\?{c.name}"
FunctionEnd
|