/
howie.nsi
252 lines (205 loc) · 7.49 KB
/
howie.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
# howie.nsi
#
# Author: Cort Stratton (cortATcortstrattonDOTorg)
#
!include "MUI.nsh"
#--------------------------------
#Configuration
# Basic definitions
Var MY_PRODUCT
Var MY_VERSION
!define MY_PRODUCT "Howie"
!define MY_VERSION "0.6.0"
# General
Name "${MY_PRODUCT}"
OutFile "..\dist\howie-install-${MY_VERSION}.exe"
# Folder selection page
InstallDir "$PROGRAMFILES\${MY_PRODUCT}"
InstallDirRegKey HKLM "Software\${MY_PRODUCT}" "Install_Dir"
# MUI stuff
Var MUI_TEMP
Var STARTMENU_FOLDER
# Compiler configuration
SetCompressor bzip2
ShowInstDetails show
ShowUninstDetails show
InstProgressFlags smooth colored
XPStyle on
#--------------------------------
#Modern UI Configuration
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\${MY_PRODUCT}"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\README.txt"
!define MUI_FINISHPAGE_NOREBOOTSUPPORT
!insertmacro MUI_PAGE_FINISH
!define MUI_ABORTWARNING
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
#--------------------------------
#Languages
!insertmacro MUI_LANGUAGE "English"
#--------------------------------
#Language Strings
# Description
LangString DESC_SecCopyMain ${LANG_ENGLISH} "Installs ${MY_PRODUCT} files to the application folder."
LangString DESC_SecCopyAddOns ${LANG_ENGLISH} "Installs some optional add-on modules to extend ${MY_PRODUCT}'s capabilities."
LangString DESC_SecCopyAcronym ${LANG_ENGLISH} "Handles 'what does X stand for' questions."
LangString DESC_SecCopyGooglism ${LANG_ENGLISH} "Handles 'who/what/where/when is X' questions."
LangString DESC_SecCopyRhyme ${LANG_ENGLISH} "Handles 'what rhymes with X' questions."
#--------------------------------
#Reserve Files
# Things that need to be extracted on first (keep these lines before any
# File command!). Only useful for BZIP2 compression.
!insertmacro MUI_RESERVEFILE_LANGDLL
#--------------------------------
#Installer Sections
Section "!${MY_PRODUCT} (required)" SecCopyMain
# Indicate that this section should always be installed.
SectionIn RO
# Set output path to the installation directory.
SetOutPath $INSTDIR
# Install core files.
DetailPrint "Installing core files..."
SetDetailsPrint textonly
File /r dist\*
Rename runme.exe howie.exe
SetDetailsPrint both
# Install documentation
DetailPrint "Installing documentation..."
SetDetailsPrint textonly
SetOutPath $INSTDIR\docs
File /r docs\*.html
SetDetailsPrint both
# Install uninstaller program
DetailPrint "Installing uninstaller..."
SetDetailsPrint textonly
SetOutPath $INSTDIR
WriteUninstaller Uninstall.exe
WriteRegStr HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" \
"DisplayName" "Howie ${MY_VERSION} (remove only)"
WriteRegStr HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" \
"UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegDWORD HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" \
"NoModify" 1
WriteRegDWORD HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${MY_PRODUCT}" \
"NoRepair" 1
WriteRegStr HKLM "Software\${MY_PRODUCT}" "Installer Language" $LANGUAGE
SetDetailsPrint both
# Write Start Menu shortcuts
!insertmacro MUI_STARTMENU_WRITE_BEGIN Application
# Create shortcuts
DetailPrint "Installing Start Menu shortcuts..."
SetDetailsPrint textonly
CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
SetOutPath $INSTDIR # To set working directory for shortcut
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Configure ${MY_PRODUCT}.lnk" \
"$INSTDIR\howie.ini"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Run ${MY_PRODUCT}.lnk" \
"$INSTDIR\howie.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Run ${MY_PRODUCT} (Local Mode).lnk" \
"$INSTDIR\howie.exe" "-l"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall ${MY_PRODUCT}.lnk" \
"$INSTDIR\Uninstall.exe"
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\README.lnk" \
"$INSTDIR\README.txt"
# Write shortcut location to the registry (for Uninstaller)
WriteRegStr HKLM "Software\${MY_PRODUCT}" "Start Menu Folder" "$STARTMENU_FOLDER"
SetDetailsPrint both
!insertmacro MUI_STARTMENU_WRITE_END
SectionEnd
SubSection "Add-ons" SecCopyAddOns
Section "Acronyms" SecCopyAcronym
# Install acronym
DetailPrint "Installing Acronym module..."
SetDetailsPrint textonly
SetOutPath $INSTDIR\scripts
File scripts\acronym.py
SetOutPath $INSTDIR\standard
File standard\howie-acronym.aiml
SetDetailsPrint both
SectionEnd
Section "Googlisms" SecCopyGooglism
# Install googlism
DetailPrint "Installing Googlism module..."
SetDetailsPrint textonly
SetOutPath $INSTDIR\scripts
File scripts\googlism.py
SetOutPath $INSTDIR\standard
File standard\howie-googlism.aiml
SetDetailsPrint both
SectionEnd
# Install rhyme
Section "Rhymes" SecCopyRhyme
DetailPrint "Installing Rhymes module..."
SetDetailsPrint textonly
SetOutPath $INSTDIR\scripts
File scripts\rhyme.py
File scripts\*.db
SetOutPath $INSTDIR\standard
File standard\howie-rhyme.aiml
SetDetailsPrint both
SectionEnd
SubSectionEnd
#--------------------------------
#Installer Functions
Function .onInit
# Splash screen
#SetOutPath $TEMP
#File /oname=spltmp.bmp "logo.bmp"
#advsplash::show 2000 500 500 -1 $TEMP\spltmp
# $0 has '1' if the user closed the splash screen early,
# '0' if everything closed normal, and '-1' if some error occured.
#Pop $0
#Delete $TEMP\spltmp.bmp
# Language selection
# Font
Push Tahoma
Push 8
# Languages
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
#--------------------------------
#Descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyMain} $(DESC_SecCopyMain)
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyAddOns} $(DESC_SecCopyAddOns)
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyAcronym} $(DESC_SecCopyAcronym)
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyGooglism} $(DESC_SecCopyGooglism)
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyRhyme} $(DESC_SecCopyRhyme)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
#--------------------------------
#Uninstaller Section
Section "Uninstall"
RMDir /r "$INSTDIR"
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
Delete "$SMPROGRAMS\$MUI_TEMP\Configure ${MY_PRODUCT}.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall ${MY_PRODUCT}.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Run ${MY_PRODUCT}.lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\Run ${MY_PRODUCT} (Local Mode).lnk"
Delete "$SMPROGRAMS\$MUI_TEMP\README.lnk"
;Delete empty start menu parent diretories
StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
startMenuDeleteLoop:
RMDir $MUI_TEMP
GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
IfErrors startMenuDeleteLoopDone
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
startMenuDeleteLoopDone:
DeleteRegKey /ifempty HKLM "Software\${MY_PRODUCT}"
SectionEnd
#--------------------------------
#Uninstaller Functions
Function un.onInit
# Get language from registry
ReadRegStr $LANGUAGE HKLM "Software\${MY_PRODUCT}" "Installer Language"
FunctionEnd