-
Notifications
You must be signed in to change notification settings - Fork 13
/
LOSI.nsi
243 lines (195 loc) · 6.99 KB
/
LOSI.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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
; NSIS extensions needed to compile this script that
; aren't in the default install:
; FindProcDLL (don't get the optimized for size version,
; KillProcDLL I had no luck with that)
; ShutDown
; NSISArray (And the header that comes with it)
; UserMgr
; You will also need the include header "Advanced Uninstall Log NSIS Header"
; Make sure you get the modified version that has support for localization
;--------------------------------
;Variables
var currentShell
var hasStartedLS
var username
var langWhereProfiles
var abortWarning
var advancedInstall
;--------------------------------
;Include Modern UI
!include "MUI.nsh"
!include WinMessages.nsh
!define PRODUCT_NAME "LOSI"
!define PRODUCT_VERSION "0.4.5"
!define PRODUCT_PUBLISHER "Tobbe"
!define PRODUCT_WEB_SITE "http://tlundberg.com/LOSI"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\litestep.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_STARTMENU_REGVAL "NSIS:StartMenuDir"
SetCompressor bzip2
;--------------------------------
; Uninstall log
!define INSTDIR_REG_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define INSTDIR_REG_KEY "${PRODUCT_UNINST_KEY}"
!define UNINSTALLOG_LOCALIZE
!include AdvUninstLog.nsh
!insertmacro UNATTENDED_UNINSTALL ;Keep all files we didn't install without asking
;--------------------------------
; NSISArray
!include NSISArray.nsh
${Array} whereprofilesarray 5 ${NSIS_MAX_STRLEN}
${ArrayFunc} Read
${ArrayFunc} Write
${ArrayFunc} Shift
${ArrayFunc} SizeOf
${ArrayFunc} Clear
${ArrayFunc} Debug
${Array} un.whereprofilesarray 5 ${NSIS_MAX_STRLEN}
${ArrayFunc} Read
${ArrayFunc} Write
${ArrayFunc} Shift
${ArrayFunc} SizeOf
${ArrayFunc} Clear
${ArrayFunc} Debug
;--------------------------------
;MUI Settings
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ".\header.bmp" ; optional
!define MUI_WELCOMEFINISHPAGE_BITMAP ".\welcomefinish.bmp"
!define MUI_UNWELCOMEFINISHPAGE_BITMAP ".\welcomefinish.bmp"
!define MUI_ICON ".\installer.ico"
!define MUI_UNICON ".\installer.ico"
!define MUI_CUSTOMFUNCTION_ABORT customOnUserAbort
;--------------------------------
;Reserve Files
;These files should be inserted before other files in the data block
;Keep these lines before any File command
;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA)
ReserveFile "ioTypeOfInstall.ini"
ReserveFile "ioHowLS.ini"
ReserveFile "ioWhereProfiles.ini"
ReserveFile "ioPreviousInstall.ini"
ReserveFile "ioFileAssoc.ini"
ReserveFile "ioPreReq.ini"
ReserveFile "test.txt"
ReserveFile "cross.bmp"
ReserveFile "check.bmp"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
!insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog
;--------------------------------
;General
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
;Name of installation exe
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
;Default installation folder
InstallDir "$PROGRAMFILES\LiteStep"
;Get installation folder from registry if available
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show
ShowUnInstDetails show
;--------------------------------
;Language Selection Dialog Settings
;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
;End Lang. Sel.
;--------------------------------
;--------------------------------
;Pages and Sections
; Here you include the pages and sections you want in the installer.
; If you don't want one of the pages/sections just remove/comment that line.
!include PageWelcome.nsh
!include PageLicense.nsh
!include PagePrerequisites.nsh
!include PageTypeOfInstall.nsh
!include PageDirectory.nsh
!include PagePreviousInstall.nsh
!include SectionCore.nsh
!include SectionTheme.nsh
!include HiddenSectionTheme.nsh
!include PageAndHiddenSectionStartMenu.nsh
!include SectionLOSI.nsh
!include PageHowLS.nsh
!include PageWhereProfiles.nsh
!include PageInstFiles.nsh ; This page is needed to execute any Sections
!include PageAndSectionConfigEvars.nsh
!include PageAndSectionFileAssoc.nsh
!include PageFinish.nsh
!include Uninstaller.nsh
;End Pages and Sections
;--------------------------------
!include "LanguageStrings.nsh"
Function .onInit
StrCpy $abortWarning "true"
StrCpy $advancedInstall "true"
UserInfo::GetName
Pop $username
ClearErrors ; UserInfo might genrate an error, but we don't care
; Set a default profiles directory
${whereprofilesarray->Init}
${whereprofilesarray->Shift} "$PROGRAMFILES\LiteStep\Profiles\$username"
!insertmacro MUI_LANGDLL_DISPLAY
;Always prepare the log within the .onInit function
!insertmacro UNINSTALL.LOG_PREPARE_INSTALL
;Extract InstallOptions INI Files
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioPreReq.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioPreviousInstall.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioTypeOfInstall.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioHowLS.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioWhereProfiles.ini"
!insertmacro MUI_INSTALLOPTIONS_EXTRACT "ioFileAssoc.ini"
FunctionEnd
Function .onInstSuccess
;Alwasy create/update log within the .onInstSuccess function
!insertmacro UNINSTALL.LOG_UPDATE_INSTALL
FunctionEnd
Function .onGUIEnd
!ifdef PAGE_CONFIG_EVARS
${EvarNames->Inited} 0 dontDeleteEvarArrays
${InputHwnds->Delete}
${EvarNames->Delete}
${EvarPaths->Delete}
dontDeleteEvarArrays:
${whereprofilesarray->Delete}
!endif
FunctionEnd
Function customOnUserAbort
StrCmp $abortWarning "false" NoAbortWarning
MessageBox MB_YESNO|MB_ICONEXCLAMATION "$(ABORT_WARNING)" IDYES NoAbortWarning
Abort ; causes installer to not quit.
NoAbortWarning:
FunctionEnd
!ifdef WRITE_UNINSTALLER
Function un.onUninstSuccess
HideWindow
MessageBox MB_ICONINFORMATION|MB_OK $(UNINSTALL_SUCCESS)
FunctionEnd
Function un.onInit
!insertmacro MUI_UNGETLANGUAGE
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(UNINSTALL_CONFIRM) IDYES +2
Abort
!insertmacro UNINSTALL.LOG_BEGIN_UNINSTALL
FunctionEnd
!endif
;Assign language strings to sections
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!ifdef SECTION_CORE
!insertmacro MUI_DESCRIPTION_TEXT ${SecCore} $(DESC_SecCore)
!endif
!ifdef SECTION_THEME
!insertmacro MUI_DESCRIPTION_TEXT ${SecTheme} $(DESC_SecTheme)
!endif
!ifdef SECTION_LOSI
!insertmacro MUI_DESCRIPTION_TEXT ${SecLosi} $(DESC_SecLosi)
!endif
!ifdef PAGE_FILE_ASSOC
!insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} $(DESC_SecFileAssoc)
!endif
!ifdef PAGE_CONFIG_EVARS
!insertmacro MUI_DESCRIPTION_TEXT ${SecConfigEvars} $(DESC_SecConfigEvars)
!endif
!insertmacro MUI_FUNCTION_DESCRIPTION_END
!include PreFunctions.nsh
!include Kill.nsh