-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfantom.nsi
226 lines (176 loc) · 7.43 KB
/
fantom.nsi
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
#
# Fantom installer
#
# Built with large strings build for 3.0b1 -> http://nsis.sourceforge.net/Special_Builds
!define VERSION "1.0.80"
!define AF_VERSION "1.0.80"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "etc\fantomBanner.bmp"
!define UNINST_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Fantom"
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_KEY "${UNINST_REG_KEY}"
!define MULTIUSER_INSTALLMODE_DEFAULT_REGISTRY_VALUENAME "InstallLocation"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${UNINST_REG_KEY}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUENAME "InstallLocation"
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
# Uncomment for dev
#!define MUI_FINISHPAGE_NOAUTOCLOSE
#!define MUI_UNFINISHPAGE_NOAUTOCLOSE
!include "MultiUser.nsh" ; Multi-Users
!include "MUI2.nsh" ; Modern UI
!include "x64.nsh" ; 64 bit detection
!include "inc\EnvVarUpdate.nsh" ;
Name "Fantom ${VERSION}"
OutFile "fantom-${AF_VERSION}.exe"
InstallDir "$PROGRAMFILES\fantom-${VERSION}\"
BrandingText "NSIS Fantom Installer by Steve Eynon"
!define MUI_ICON "etc\fantom.ico"
!define MUI_UNICON "etc\uninstall.ico"
VIAddVersionKey "ProductName" "Fantom"
VIAddVersionKey "Comments" "NSIS Fantom Installer by Steve Eynon"
VIAddVersionKey "LegalCopyright" "(c) 2011, Brian Frank and Andy Frank"
VIAddVersionKey "FileDescription" "Installer for the Fantom Language"
VIAddVersionKey "FileVersion" "${AF_VERSION}"
VIProductVersion "1.0.80.0"
VIFileVersion "1.0.80.0"
Var AF_ORIG_INSTDIR
# ---- Pages ------------------------------------------------------------------
!insertmacro MUI_PAGE_COMPONENTS
!define MUI_PAGE_CUSTOMFUNCTION_PRE multiuser_pre_func
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE multiuser_post_func
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
# see https://nsis-dev.github.io/NSIS-Forums/html/t-292340.html
Function multiuser_pre_func
ClearErrors
ReadRegStr $R1 SHCTX "${UNINST_REG_KEY}" "InstallLocation"
${Unless} ${Errors}
Abort
${EndUnless}
FunctionEnd
Function multiuser_post_func
${If} "$MultiUser.InstallMode" == "CurrentUser"
StrCpy $INSTDIR "$LOCALAPPDATA\fantom-${VERSION}\"
${Else}
StrCpy $INSTDIR $AF_ORIG_INSTDIR
${EndIf}
FunctionEnd
# -----------------------------------------------------------------------------
Section "Application Files" applicationFiles
SectionIn RO
SetOutPath "$INSTDIR"
File fantom\readme.html
File fantom\readme.md
SetOutPath "$INSTDIR\bin"
File /r fantom\bin\*.*
File etc\fantom.ico
SetOutPath "$INSTDIR\etc"
File /r fantom\etc\*.*
SetOutPath "$INSTDIR\lib"
File /r /x ext "fantom\lib\*.*"
${If} "$MultiUser.InstallMode" == "AllUsers"
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "FAN_HOME" "$INSTDIR"
${EnvVarUpdate} $0 "PATH" "A" HKLM "%FAN_HOME%\bin"
${Else}
WriteRegStr HKCU "Environment" "FAN_HOME" "$INSTDIR"
${EnvVarUpdate} $0 "PATH" "A" HKCU "%FAN_HOME%\bin"
${EndIf}
WriteUninstaller "$INSTDIR\Uninstall.exe"
# see http://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs#With_a_MultiUser_Installer
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD SHCTX "${UNINST_REG_KEY}" "EstimatedSize" "$0"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "InstallLocation" "$INSTDIR"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "DisplayName" "Fantom ${VERSION}"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "Publisher" "Fantom-Factory"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "DisplayVersion" "${VERSION}"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "DisplayIcon" "$INSTDIR\bin\fantom.ico"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\" /$MultiUser.InstallMode"
WriteRegStr SHCTX "${UNINST_REG_KEY}" "QuietUninstallString" "$\"$INSTDIR\Uninstall.exe$\" /$MultiUser.InstallMode /S"
SectionEnd
# -----------------------------------------------------------------------------
Section "Admin Tools" adminTools
SetOutPath "$INSTDIR\adm"
File /r extras\adm\*.*
SectionEnd
# -----------------------------------------------------------------------------
Section "Examples" examples
SetOutPath "$INSTDIR\examples"
File /r extras\examples\*.*
SectionEnd
# -----------------------------------------------------------------------------
Section "Source Files" sourceFiles
SetOutPath "$INSTDIR\src"
File /r extras\src\*.*
SectionEnd
# -----------------------------------------------------------------------------
Section "FWT" fwt
SetOutPath "$INSTDIR\"
File /r extras\fwt\*.*
SectionEnd
LangString DESC_applicationFiles ${LANG_ENGLISH} "Core Fantom libraries"
LangString DESC_adminTools ${LANG_ENGLISH} "Admin scripts and text editor configutaion files"
LangString DESC_examples ${LANG_ENGLISH} "Fantom examples"
LangString DESC_sourceFiles ${LANG_ENGLISH} "Fantom source files"
LangString DESC_fwt ${LANG_ENGLISH} "Fantom Widgit Toolkit; pods, src, examples, and SWT jars"
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${applicationFiles} $(DESC_applicationFiles)
!insertmacro MUI_DESCRIPTION_TEXT ${adminTools} $(DESC_adminTools)
!insertmacro MUI_DESCRIPTION_TEXT ${examples} $(DESC_examples)
!insertmacro MUI_DESCRIPTION_TEXT ${sourceFiles} $(DESC_sourceFiles)
!insertmacro MUI_DESCRIPTION_TEXT ${fwt} $(DESC_fwt)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# -----------------------------------------------------------------------------
Function .onInit
StrCpy $INSTDIR "$PROGRAMFILES32\fantom-${VERSION}\"
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\fantom-${VERSION}\"
${EndIf}
StrCpy $AF_ORIG_INSTDIR $INSTDIR
!insertmacro MULTIUSER_INIT
# AddSize doesn't work (reports wrong sizes) with the large strings build
SectionSetSize ${applicationFiles} 5444
SectionSetSize ${adminTools} 144
SectionSetSize ${examples} 55
SectionSetSize ${sourceFiles} 9825
SectionSetSize ${fwt} 6387
FunctionEnd
Function un.onInit
!insertmacro MULTIUSER_UNINIT
FunctionEnd
# -----------------------------------------------------------------------------
Section "Uninstall"
Delete "$INSTDIR\readme.html"
Delete "$INSTDIR\readme.md"
Delete "$INSTDIR\Uninstall.exe"
RMDir /r /REBOOTOK "$INSTDIR\adm"
RMDir /r /REBOOTOK "$INSTDIR\bin"
RMDir /r /REBOOTOK "$INSTDIR\etc"
RMDir /r /REBOOTOK "$INSTDIR\examples"
RMDir /r /REBOOTOK "$INSTDIR\lib"
RMDir /r /REBOOTOK "$INSTDIR\src"
${If} "$MultiUser.InstallMode" == "AllUsers"
DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "FAN_HOME"
${un.EnvVarUpdate} $0 "PATH" "R" HKLM "%FAN_HOME%\bin"
${Else}
DeleteRegValue HKCU "Environment" "FAN_HOME"
${un.EnvVarUpdate} $0 "PATH" "R" HKCU "%FAN_HOME%\bin"
${EndIf}
# ${If} "$MultiUser.InstallMode" == "AllUsers"
# StrCpy $1 "HKLM"
# ${Else}
# StrCpy $1 "HKCU"
# ${EndIf}
#
# ${un.EnvVarUpdate} $0 "PATH" "R" $1 "%FAN_HOME%\bin"
# ${un.EnvVarUpdate} $0 "FAN_HOME" "R" $1 "$\"%$INSTDIR$\""
DeleteRegKey SHCTX "${UNINST_REG_KEY}"
SectionEnd