forked from etotheipi/BitcoinArmory
-
Notifications
You must be signed in to change notification settings - Fork 174
/
ArmorySetup.nsi
240 lines (216 loc) · 7.84 KB
/
ArmorySetup.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
# Auto-generated by EclipseNSIS Script Wizard
# Sep 25, 2013 4:18:18 PM
Name "Bitcoin Armory"
# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define COMPANY "Community maintained"
!define URL http://btcarmory.com/
# MultiUser Symbol Definitions
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_INSTALLMODE_INSTDIR Armory
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"
# MUI Symbol Definitions
!define MUI_ICON img\armory48x48.ico
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
!define MUI_STARTMENUPAGE_DEFAULTFOLDER Armory
!define MUI_FINISHPAGE_RUN $INSTDIR\ArmoryQt.exe
!define MUI_UNICON img\armory48x48.ico
!define MUI_UNFINISHPAGE_NOAUTOCLOSE
# Included files
!include MultiUser.nsh
!include Sections.nsh
!include MUI2.nsh
!include CompilerArgs.nsi
!include x64.nsh
# Reserved Files
ReserveFile "${NSISDIR}\Plugins\StartMenu.dll"
# Variables
Var StartMenuGroup
# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE LICENSE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
# Installer languages
!insertmacro MUI_LANGUAGE English
# Installer attributes
# Default to -testing to match 90% of builds. Manually change actual releases
OutFile armory_${VERSION}-testing_winAll.exe
InstallDir "$PROGRAMFILES\Armory"
CRCCheck on
XPStyle on
Icon img\armory48x48.ico
ShowInstDetails show
AutoCloseWindow true
LicenseData LICENSE
VIProductVersion "${VERSION}"
VIAddVersionKey ProductName "Bitcoin Armory"
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription ""
VIAddVersionKey LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
UninstallIcon img\armory48x48.ico
ShowUninstDetails show
# Installer sections
# Macro for creating a registry key
!define HKEY_CLASSES_ROOT 0xffffffff80000000
!define HKEY_CURRENT_USER 0xffffffff80000001
!define HKEY_LOCAL_MACHINE 0xffffffff80000002
!define HKEY_USERS 0xffffffff80000003
!define HKEY_PERFORMANCE_DATA 0xffffffff80000004
!define HKEY_CURRENT_CONFIG 0xffffffff80000005
!define HKEY_DYN_DATA 0xffffffff80000006
!define KEY_CREATE_SUB_KEY 0x0004
!macro CreateRegKey ROOT_KEY SUB_KEY
Push $0
Push $1
System::Call /NOUNLOAD "Advapi32::RegCreateKeyExA(i, t, i, t, i, i, i, *i, i) i(${ROOT_KEY}, '${SUB_KEY}', 0, '', 0, ${KEY_CREATE_SUB_KEY}, 0, .r0, 0) .r1"
StrCmp $1 0 +2
SetErrors
StrCmp $0 0 +2
System::Call /NOUNLOAD "Advapi32::RegCloseKey(i) i(r0) .r1"
System::Free 0
Pop $1
Pop $0
!macroend
!macro CREATE_SMGROUP_SHORTCUT NAME PATH ARGS
Push "${ARGS}"
Push "${NAME}"
Push "${PATH}"
Call CreateSMGroupShortcut
!macroend
Section -Main SEC0000
${If} ${RunningX64}
# 64 bit code
SetOutPath $INSTDIR
RmDir /r $INSTDIR
SetOverwrite on
File /r ArmoryStandalone\*
File ArmoryStandalone\ArmoryQt.exe
!insertmacro CreateRegKey ${HKEY_CURRENT_USER} "Software\Armory"
SetOutPath $DESKTOP
CreateShortcut "$DESKTOP\Bitcoin Armory.lnk" $INSTDIR\ArmoryQt.exe
!insertmacro CREATE_SMGROUP_SHORTCUT "Bitcoin Armory" "$INSTDIR\ArmoryQt.exe" ""
!insertmacro CREATE_SMGROUP_SHORTCUT "Bitcoin Armory (Offline)" "$INSTDIR\ArmoryQt.exe" "--offline"
!insertmacro CREATE_SMGROUP_SHORTCUT "Bitcoin Armory (testnet)" "$INSTDIR\ArmoryQt.exe" "--testnet"
WriteRegStr HKLM "${REGKEY}\Components" Main 1
${Else}
# 32 bit code
MessageBox MB_OK "You cannot install this version on a 32-bit system"
${EndIf}
SectionEnd
Section -post SEC0001
${If} ${RunningX64}
# 64 bit code
WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
SetOutPath $INSTDIR
WriteUninstaller $INSTDIR\uninstall.exe
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
!insertmacro MUI_STARTMENU_WRITE_END
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
${Else}
# 32 bit code
${EndIf}
SectionEnd
# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
Push $R0
ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
StrCmp $R0 1 0 next${UNSECTION_ID}
!insertmacro SelectSection "${UNSECTION_ID}"
GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
!insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
Pop $R0
!macroend
# Uninstaller sections
!macro DELETE_SMGROUP_SHORTCUT NAME
Push "${NAME}"
Call un.DeleteSMGroupShortcut
!macroend
Section /o -un.Main UNSEC0000
!insertmacro DELETE_SMGROUP_SHORTCUT "Bitcoin Armory (testnet)"
!insertmacro DELETE_SMGROUP_SHORTCUT "Bitcoin Armory (Offline)"
!insertmacro DELETE_SMGROUP_SHORTCUT "Bitcoin Armory"
Delete /REBOOTOK "$DESKTOP\Bitcoin Armory.lnk"
DeleteRegKey /IfEmpty HKEY_CURRENT_USER "Software\Armory"
Delete /REBOOTOK $INSTDIR\ArmoryQt.exe
RmDir /r /REBOOTOK $INSTDIR
DeleteRegValue HKLM "${REGKEY}\Components" Main
SectionEnd
Section -un.post UNSEC0001
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
Delete /REBOOTOK $INSTDIR\uninstall.exe
DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
DeleteRegValue HKLM "${REGKEY}" Path
DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
DeleteRegKey /IfEmpty HKLM "${REGKEY}"
RmDir /r /REBOOTOK $SMPROGRAMS\$StartMenuGroup
RmDir /r /REBOOTOK $INSTDIR
Push $R0
StrCpy $R0 $StartMenuGroup 1
StrCmp $R0 ">" no_smgroup
no_smgroup:
Pop $R0
SectionEnd
# Installer functions
Function .onInit
InitPluginsDir
!insertmacro MULTIUSER_INIT
FunctionEnd
Function CreateSMGroupShortcut
Exch $R0 ;PATH
Exch
Exch $R1 ;NAME
Exch 2
Exch $R3
Push $R2
StrCpy $R2 $StartMenuGroup 1
StrCmp $R2 ">" no_smgroup
SetOutPath $SMPROGRAMS\$StartMenuGroup
CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$R1.lnk" $R0 $R3
no_smgroup:
Pop $R2
Pop $R1
Pop $R0
FunctionEnd
# Uninstaller functions
Function un.onInit
ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup
!insertmacro MULTIUSER_UNINIT
!insertmacro SELECT_UNSECTION Main ${UNSEC0000}
FunctionEnd
Function un.DeleteSMGroupShortcut
Exch $R1 ;NAME
Push $R2
StrCpy $R2 $StartMenuGroup 1
StrCmp $R2 ">" no_smgroup
Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$R1.lnk"
no_smgroup:
Pop $R2
Pop $R1
FunctionEnd