forked from tpruvot/cpuminer-multi
-
Notifications
You must be signed in to change notification settings - Fork 9
/
cpuminer.nsi
executable file
·363 lines (288 loc) · 11.2 KB
/
cpuminer.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
; NSIS script (UTF-8) NSIS-3 Unicode
; Install
; Unicode true
; SetCompressor lzma
RequestExecutionLevel Admin
; --------------------
!include x64.nsh
!include FileFunc.nsh
!include WinMessages.nsh
AllowRootDirInstall true
; --------------------
; LANG TABLES: 1
!define MINER_VERSION "1.1"
!define VERSION "${MINER_VERSION}.0.0"
BrandingText "CPU Miner Install System"
!define PROGRAM_NAME "CPU Miner"
!define PROGRAM_KEY "cpuminer"
Name "cpuminer-multi v${MINER_VERSION}"
OutFile "${PROGRAM_KEY}-setup.exe"
Icon "res\setup.ico"
; Icon "res\${PROGRAM_KEY}.ico"
Caption "${PROGRAM_NAME}"
VIProductVersion "${VERSION}"
VIAddVersionKey ProductName "${PROGRAM_NAME} - Setup"
VIAddVersionKey Comments ""
VIAddVersionKey CompanyName "Open Source"
VIAddVersionKey LegalCopyright "2015 - Open Source"
VIAddVersionKey FileDescription "${PROGRAM_NAME} - Setup"
VIAddVersionKey FileVersion "${MINER_VERSION}"
VIAddVersionKey ProductVersion "${MINER_VERSION}"
VIAddVersionKey InternalName "${PROGRAM_NAME}"
VIAddVersionKey LegalTrademarks ""
VIAddVersionKey OriginalFilename "${PROGRAM_KEY}.exe"
!define NSIS_MAKENSIS64
!ifdef NSIS_MAKENSIS64
!define BITS 64
InstallDir $PROGRAMFILES64\cpuminer-multi
!define RK_UNINSTALL "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_KEY}"
!else
!define BITS 32
InstallDir $PROGRAMFILES32\cpuminer-multi
!define RK_UNINSTALL "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_KEY}"
;!define RK_UNINSTALL "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_KEY}"
!endif
# Test folders x86/x64
# InstType "Custom"
# InstallDir $WINDIR\system32
; LANG: ${LANG_ENGLISH}
LangString LSTR_0 ${LANG_ENGLISH} "CPU Miner Install System"
LangString LSTR_3 ${LANG_ENGLISH} "Space available: "
LangString LSTR_4 ${LANG_ENGLISH} "Space required: "
LangString LSTR_5 ${LANG_ENGLISH} "Can't write: "
LangString LSTR_17 ${LANG_ENGLISH} "Error decompressing data! Corrupted installer?"
LangString LSTR_21 ${LANG_ENGLISH} "Extract: "
LangString LSTR_22 ${LANG_ENGLISH} "Extract: error writing to file "
LangString LSTR_25 ${LANG_ENGLISH} "Output folder: "
LangString LSTR_29 ${LANG_ENGLISH} "Skipped: "
LangString LSTR_30 ${LANG_ENGLISH} "Copy Details To Clipboard"
LangString LSTR_32 ${LANG_ENGLISH} "B"
LangString LSTR_33 ${LANG_ENGLISH} "K"
LangString LSTR_34 ${LANG_ENGLISH} "M"
LangString LSTR_35 ${LANG_ENGLISH} "G"
LangString LSTR_36 ${LANG_ENGLISH} "Choose Install Location"
LangString LSTR_37 ${LANG_ENGLISH} "Choose the folder in which to install ${PROGRAM_NAME}."
LangString LSTR_38 ${LANG_ENGLISH} "Installing"
LangString LSTR_39 ${LANG_ENGLISH} "Please wait while ${PROGRAM_NAME} is being installed."
LangString LSTR_40 ${LANG_ENGLISH} "Installation Complete"
LangString LSTR_41 ${LANG_ENGLISH} "Setup was completed successfully."
LangString LSTR_42 ${LANG_ENGLISH} "Installation Aborted"
LangString LSTR_43 ${LANG_ENGLISH} "Setup was not completed successfully."
LangString LSTR_44 ${LANG_ENGLISH} "MS Shell Dlg"
LangString LSTR_45 ${LANG_ENGLISH} "8"
LangString LSTR_46 ${LANG_ENGLISH} "Error opening file for writing: $\r$\n$\r$\n$0$\r$\n$\r$\nClick Abort to stop the installation,$\r$\nRetry to try again, or$\r$\nIgnore to skip this file."
LangString LSTR_48 ${LANG_ENGLISH} "Cancel"
LangString LSTR_49 ${LANG_ENGLISH} "Setup will install ${PROGRAM_NAME} in the following folder. To install in a different folder, click Browse and select another folder. $_CLICK"
LangString LSTR_50 ${LANG_ENGLISH} "Destination Folder"
LangString LSTR_51 ${LANG_ENGLISH} "B&rowse..."
LangString LSTR_52 ${LANG_ENGLISH} "Select the folder to install ${PROGRAM_NAME} in:"
LangString LSTR_53 ${LANG_ENGLISH} "< &Back"
LangString LSTR_54 ${LANG_ENGLISH} "&Install"
LangString LSTR_55 ${LANG_ENGLISH} "Click Install to start the installation."
LangString LSTR_56 ${LANG_ENGLISH} "Show &details"
LangString LSTR_57 ${LANG_ENGLISH} "Completed"
LangString LSTR_58 ${LANG_ENGLISH} "&Next >"
LangString LSTR_59 ${LANG_ENGLISH} "Click Next to continue."
LangString LSTR_60 ${LANG_ENGLISH} " "
LangString LSTR_61 ${LANG_ENGLISH} "&Close"
; --------------------
; VARIABLES:
Var _0_
Var _1_
Var _2_
Var _3_
Var _4_
Var _5_
Var _6_
Var DATADIR
Var REALINSTDIR
; --------------------
; PAGES: 3
; Page 0
Page directory func_title_pre0 func_show0 func_leave0 /ENABLECANCEL
; DirVar $CMDLINE
DirText $(LSTR_49) $(LSTR_50) $(LSTR_51) $(LSTR_52) ; Setup will install ${PROGRAM_NAME} in the following folder....
; Page 1
Page instfiles func_title_pre1 func_show1 func_leave1
CompletedText $(LSTR_57) ; Completed
DetailsButtonText $(LSTR_56) ; Show &details
/*
; Page 2
Page COMPLETED
*/
; --------------------
Function func_title_pre0 ; Page 0, Pre
SendMessage $_0_ ${WM_SETTEXT} 0 STR:$(LSTR_36) ; Choose Install Location
SendMessage $_2_ ${WM_SETTEXT} 0 STR:$(LSTR_37) ; Choose the folder in which to install ${PROGRAM_NAME}.
FunctionEnd
Function func_show0 ; Page 0, Show
; FindWindow $_12_ "#32770" "" $HWNDPARENT
; GetDlgItem $_13_ $_12_ 1006
; GetDlgItem $_14_ $_12_ 1020
; GetDlgItem $_15_ $_12_ 1019
; GetDlgItem $_16_ $_12_ 1001
; GetDlgItem $_17_ $_12_ 1023
; GetDlgItem $_18_ $_12_ 1024
FunctionEnd
Function func_leave0 ; Page 0, Leave
FunctionEnd
Function func_title_pre1 ; Page 1, Pre
SendMessage $_0_ ${WM_SETTEXT} 0 STR:$(LSTR_38) ; Installing
SendMessage $_2_ ${WM_SETTEXT} 0 STR:$(LSTR_39) ; Please wait while ${PROGRAM_NAME} is being installed. cpuminer-multi
FunctionEnd
Function func_show1 ; Page 1, Show
; FindWindow $_19_ "#32770" "" $HWNDPARENT
; GetDlgItem $_20_ $_19_ 1006
; GetDlgItem $_21_ $_19_ 1004
; GetDlgItem $_22_ $_19_ 1027
; GetDlgItem $_23_ $_19_ 1016
FunctionEnd
Function func_leave1 ; Page 1, Leave
IfAbort label_27
SendMessage $_0_ ${WM_SETTEXT} 0 STR:$(LSTR_40) ; "Installation Complete"
SendMessage $_2_ ${WM_SETTEXT} 0 STR:$(LSTR_41) ; "Setup was completed successfully."
Goto label_29
label_27:
SendMessage $_0_ ${WM_SETTEXT} 0 STR:$(LSTR_42) ; "Installation Aborted"
SendMessage $_2_ ${WM_SETTEXT} 0 STR:$(LSTR_43) ; "Setup was not completed successfully."
label_29:
IfAbort label_30
label_30:
FunctionEnd
Function .onInit
# `/SD IDYES' tells MessageBox to automatically choose IDYES if the installer is silent
# in this case, the installer can only be silent if the user used the /S switch or if
# you've uncommented line number 5
# MessageBox MB_YESNO|MB_ICONQUESTION "Would you like the installer to be silent from now on?" \
# /SD IDYES IDNO no IDYES yes
# yes:
# SetSilent silent
# Goto done
# no:
# SetSilent normal
#SetSilent silent
ReadRegStr $R0 HKLM ${RK_UNINSTALL} \
"UninstallString"
StrCmp $R0 "" done
DeleteRegKey HKLM ${RK_UNINSTALL}
ClearErrors
done:
FunctionEnd
Function .onGUIInit
GetDlgItem $_0_ $HWNDPARENT 1037
CreateFont $_1_ $(LSTR_44) $(LSTR_45) 700 ; "MS Shell Dlg" 8
SendMessage $_0_ ${WM_SETFONT} $_1_ 0
GetDlgItem $_2_ $HWNDPARENT 1038
SetCtlColors $_0_ "" 0xFFFFFF
SetCtlColors $_2_ "" 0xFFFFFF
GetDlgItem $_3_ $HWNDPARENT 1034
SetCtlColors $_3_ "" 0xFFFFFF
GetDlgItem $_4_ $HWNDPARENT 1039
SetCtlColors $_4_ "" 0xFFFFFF
GetDlgItem $_6_ $HWNDPARENT 1028
SetCtlColors $_6_ /BRANDING ""
GetDlgItem $_5_ $HWNDPARENT 1256
SetCtlColors $_5_ /BRANDING ""
SendMessage $_5_ ${WM_SETTEXT} 0 "STR:$(LSTR_0) " ; "CPU Miner Install System"
; GetDlgItem $_7_ $HWNDPARENT 1035
; GetDlgItem $_8_ $HWNDPARENT 1045
; GetDlgItem $_9_ $HWNDPARENT 1
; GetDlgItem $_10_ $HWNDPARENT 2
; GetDlgItem $_11_ $HWNDPARENT 3
FunctionEnd
Function .onUserAbort
FunctionEnd
Section
StrCpy $DATADIR "$APPDATA\${PROGRAM_KEY}"
StrCpy $REALINSTDIR "$INSTDIR"
${If} ${RunningX64}
${DisableX64FSRedirection}
; StrCmp $INSTDIR "$WINDIR\system32" 0 +2
; StrCpy $INSTDIR "$WINDIR\sysnative"
SetRegView 64
${Else}
SetRegView 32
${Endif}
SetOutPath "$INSTDIR"
# call UserInfo plugin to get user info. The plugin puts the result in the stack
UserInfo::getAccountType
# pop the result from the stack into $0
Pop $0
# If match, jump 3 lines down.
StrCmp $0 "Admin" +3
MessageBox MB_OK "Installer requires admin rights: $0"
Return
SetOverwrite on
File cpuminer-gw64.exe
File cpuminer-x64.exe
File cpuminer-conf.json
File /oname=LICENSE.txt LICENSE
File /oname=README.txt README.md
SetOverwrite off
AllowSkipFiles on
File x64\Release\msvcr120.dll
# Create the uninstaller
CreateDirectory "$DATADIR"
File "/oname=$DATADIR\cpuminer-conf.json" cpuminer-conf.json
WriteUninstaller "$DATADIR\cpuminer-uninst.exe"
# Shortcuts (program + uninstaller)
CreateDirectory "$SMPROGRAMS\${PROGRAM_NAME}"
CreateShortCut /NoWorkingDir "$SMPROGRAMS\${PROGRAM_NAME}\${PROGRAM_NAME}.lnk" "$REALINSTDIR\cpuminer-gw64.exe"
CreateShortCut /NoWorkingDir "$SMPROGRAMS\${PROGRAM_NAME}\Config.lnk" "$SYSDIR\notepad.exe" "$DATADIR\cpuminer-conf.json"
CreateShortCut "$SMPROGRAMS\${PROGRAM_NAME}\Uninstall.lnk" "$DATADIR\cpuminer-uninst.exe"
CreateShortCut /NoWorkingDir "$SMPROGRAMS\${PROGRAM_NAME}\${PROGRAM_NAME}-bg.lnk" "$REALINSTDIR\cpuminer-gw64.exe" "-q -B" "" "" SW_SHOWMINIMIZED
WriteRegStr HKLM ${RK_UNINSTALL} \
"DisplayName" "${PROGRAM_NAME}"
WriteRegStr HKLM ${RK_UNINSTALL} \
"DisplayVersion" "${MINER_VERSION}"
WriteRegStr HKLM ${RK_UNINSTALL} \
"Publisher" "Open Source"
WriteRegStr HKLM ${RK_UNINSTALL} \
"DisplayIcon" "$REALINSTDIR\cpuminer-x64.exe"
WriteRegStr HKLM ${RK_UNINSTALL} \
"InstallLocation" "$REALINSTDIR"
WriteRegStr HKLM ${RK_UNINSTALL} \
"UninstallString" "$\"$DATADIR\cpuminer-uninst.exe$\""
${GetSize} "$INSTDIR" "/M=cpuminer* /S=0K /G=0" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "${RK_UNINSTALL}" \
"EstimatedSize" "$0"
# Add application to Windows Firewall exception list (to check)
;liteFirewall::AddRule "$REALINSTDIR\cpuminer-gw64.exe" "CPU Miner (MinGW64)"
;liteFirewall::AddRule "$REALINSTDIR\cpuminer-x64.exe" "CPU Miner (x64)"
SectionEnd
Section "uninstall"
StrCpy $DATADIR "$APPDATA\${PROGRAM_KEY}"
${If} ${RunningX64}
;StrCmp $INSTDIR "$WINDIR\system32" 0 +2
;StrCpy $INSTDIR "$WINDIR\sysnative"
${DisableX64FSRedirection}
SetRegView 64
${Else}
SetRegView 32
${Endif}
ReadRegStr $INSTDIR HKLM ${RK_UNINSTALL} "InstallLocation"
StrCpy $REALINSTDIR "$INSTDIR"
Delete "$INSTDIR\cpuminer-conf.json"
Delete "$INSTDIR\cpuminer-gw64.exe"
Delete "$INSTDIR\cpuminer-x64.exe"
Delete "$INSTDIR\LICENSE.txt"
Delete "$INSTDIR\README.txt"
StrCmp $REALINSTDIR "$WINDIR/system32" +2
Delete "$INSTDIR\msvcr120.dll"
RMDir "$INSTDIR"
Delete "$DATADIR\cpuminer-uninst.exe"
RMDir "$DATADIR"
; Delete "$DATADIR\cpuminer-conf.json"
; RMDir "$DATADIR"
# second, remove the link from the start menu
Delete "$SMPROGRAMS\${PROGRAM_NAME}\${PROGRAM_NAME}.lnk"
Delete "$SMPROGRAMS\${PROGRAM_NAME}\${PROGRAM_NAME}-bg.lnk"
Delete "$SMPROGRAMS\${PROGRAM_NAME}\Config.lnk"
Delete "$SMPROGRAMS\${PROGRAM_NAME}\Uninstall.lnk"
RMDir "$SMPROGRAMS\${PROGRAM_NAME}"
DeleteRegKey HKLM ${RK_UNINSTALL}
# Remove application from Windows Firewall exception list
;liteFirewall::RemoveRule "$REALINSTDIR\cpuminer-gw64.exe" "CPU Miner (MinGW64)"
;liteFirewall::RemoveRule "$REALINSTDIR\cpuminer-x64.exe" "CPU Miner (x64)"
SectionEnd