This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup.nsi
executable file
·222 lines (172 loc) · 8.52 KB
/
setup.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
; NSIS installer script for the MSP430 BSL Utility
;
; (C) 2012 Flying Camp Design
;
; All Rights Reserved.
;
; AUTHOR: Chris Wilson <[email protected]>
;
; Released under a BSD-style license (please see LICENSE)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Defines
!define APP_NAME "MSP430 BSL Utility"
!define APP_EXE "${APP_NAME}.exe"
!define APP_UNINSTALL_EXE "Uninstall.exe"
!define APP_ICON "ic.ico"
!define APP_VERSION "0.9.1"
!define APP_VERSION_MAJOR "0x0"
!define APP_VERSION_MINOR "0x9"
!define APP_LICENSE "LICENSE"
!define APP_COMMENTS ""
!define COMPANY "Flying Camp Design"
!define COMPANY_URL "http://www.flyingcampdesign.com"
!define SUPPORT_URL "http://www.flyingcampdesign.com/support.html"
!define UPDATE_URL "http://www.flyingcampdesign.com/msp430-bsl-utility.html"
!define ABOUT_URL "http://www.flyingcampdesign.com/msp430-bsl-utility.html"
!define NOMODIFY "0x1"
!define NOREPAIR "0x1"
!define DIST_DIR "dist"
!define DOC_DIR "docs"
!define USER_GUIDE "UserGuide.html"
!define HEADER_IMAGE "resources\fcd_nsis_header.bmp"
!define WELCOME_FINISH_IMAGE "resources\fcd_nsis_wf.bmp"
!define INSTALLER_VERSION "${APP_VERSION}.0"
!define INSTALLER_ICON "resources\setup.ico"
!define INSTALLER_OUTDIR "nsis"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Variables
Var StartMenuFolder
Var SizeOfInstall
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; General settings
; Use custom .onGUIInit
!define MUI_CUSTOMFUNCTION_GUIINIT myGUIInit
; Include a function library that includes a file/directory size reporting command
!include "FileFunc.nsh" ; for ${GetSize} for EstimatedSize registry entry
; Use Modern UI 2
!include MUI2.nsh
; Use lzma compression
SetCompressor lzma
; Set UAC level to admin (for Windows Vista and 7)
RequestExecutionLevel admin
; Do a CRC check
CRCCheck On
; Application name
Name "${APP_NAME} ${APP_VERSION}"
; Output file name
OutFile "${INSTALLER_OUTDIR}\msp430_bsl_utility_setup_${APP_VERSION}.exe"
; Default installation directory
InstallDir "$PROGRAMFILES\${COMPANY}\${APP_NAME} ${APP_VERSION}"
;Get installation folder from registry if available
InstallDirRegKey HKLM "Software\${COMPANY}\${APP_NAME} ${APP_VERSION}" ""
; Set COMPANY name
BrandingText "${COMPANY}"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MUI settings
!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_ICON "${INSTALLER_ICON}"
!define MUI_UNICON "${INSTALLER_ICON}"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP ${HEADER_IMAGE}
!define MUI_HEADERIMAGE_BITMAP_NOSTRETCH
!define MUI_HEADERIMAGE_RIGHT
!define MUI_WELCOMEFINISHPAGE_BITMAP ${WELCOME_FINISH_IMAGE}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MUI pages
; Install
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${APP_LICENSE}
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${COMPANY}\${APP_NAME} ${APP_VERSION}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$INSTDIR\${APP_EXE}"
!insertmacro MUI_PAGE_FINISH
; Uninstall
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MUI languages
!insertmacro MUI_LANGUAGE "English"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Version information
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "${APP_NAME}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion" "${APP_VERSION}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "${APP_COMMENTS}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "${COMPANY}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright" "(C) ${COMPANY}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription" "${APP_NAME} Setup"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${APP_VERSION}"
VIProductVersion "${INSTALLER_VERSION}"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Install
Section "Install" install_section_id
; Install for all users
SetShellVarContext all
; Install Files
SetOutPath "$INSTDIR"
; Store installation folder in registry
WriteRegStr HKLM "Software\${COMPANY}\${APP_NAME} ${APP_VERSION}" "" $INSTDIR
; Let installer set compression
SetCompress Auto
; Allow file overwrites
SetOverwrite on
; Install all files in DIST_DIR
File /r "${DIST_DIR}\*"
; Install docs
SetOutPath "$INSTDIR\${DOC_DIR}"
File "${DOC_DIR}\${USER_GUIDE}"
SetOutPath "$INSTDIR"
; Write the uninstall keys to registry
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "DisplayName" "${APP_NAME} ${APP_VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "UninstallString" "$INSTDIR\${APP_UNINSTALL_EXE}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "DisplayIcon" "$INSTDIR\${APP_ICON}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "Publisher" "${COMPANY}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "HelpLink" "${SUPPORT_URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "URLUpdateInfo" "${UPDATE_URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "URLInfoAbout" "${ABOUT_URL}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "DisplayVersion" "${APP_VERSION}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "VersionMajor" "${APP_VERSION_MAJOR}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "VersionMinor" "${APP_VERSION_MINOR}"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "EstimatedSize" "$SizeOfInstall"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "NoModify" ${NOMODIFY}
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}" "NoRepair" ${NOREPAIR}
; Create the uninstaller
WriteUninstaller "${APP_UNINSTALL_EXE}"
; Install start menu folder
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
;Create shortcuts
CreateDirectory "$SMPROGRAMS\${COMPANY}\$StartMenuFolder"
CreateDirectory "$SMPROGRAMS\${COMPANY}\$StartMenuFolder\${DOC_DIR}"
; CreateShortCut "$SMPROGRAMS\${COMPANY}\$StartMenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}" "" "$INSTDIR\${APP_ICON}" 0
CreateShortCut "$SMPROGRAMS\${COMPANY}\$StartMenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_EXE}"
CreateShortCut "$SMPROGRAMS\${COMPANY}\$StartMenuFolder\${DOC_DIR}\Users Guide.lnk" "$INSTDIR\${DOC_DIR}\${USER_GUIDE}"
CreateShortCut "$SMPROGRAMS\${COMPANY}\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\${APP_UNINSTALL_EXE}"
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstall
Section "Uninstall" uninstall_section_id
; Uninstall for all users
SetShellVarContext all
; Delete start menu folder
!insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
RMDir /r "$SMPROGRAMS\${COMPANY}\$StartMenuFolder"
; Delete unistall registry entries
DeleteRegKey HKLM "SOFTWARE\${COMPANY}\${APP_NAME} ${APP_VERSION}"
DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME} ${APP_VERSION}"
; Delete the application directory
RMDir /r "$INSTDIR"
SectionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Functions
Function myGUIInit
; Get size of install section
SectionGetSize ${install_section_id} $SizeOfInstall
; Convert size to DWORD
IntFmt $SizeOfInstall "0x%08X" "$SizeOfInstall"
FunctionEnd