forked from leo-editor/leo-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnsi-boilerplate.txt
204 lines (177 loc) · 7.22 KB
/
nsi-boilerplate.txt
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
;@+leo-ver=5-thin
;@+node:ekr.20101027115225.1494: * @file nsi-boilerplate.txt
;@@language nsi
; RequestExecutionLevel highest
; RequestExecutionLevel admin
;@+<< prolog >>
;@+node:ekr.20101027115225.1495: ** << prolog >>
; Globals.
Var PythonDirectory
; Directory containing Pythonw.exe
; Set by onInit. May be set in Python Directory page.
!define PythonExecutable "$PythonDirectory\pythonw.exe"
;;; Always use pythonw.exe here.
;;; To debug, set the target to python.exe in the desktop icon properties.
!addincludedir C:\leo.repo\leo-editor\leo\dist
; Boilerplate
SetCompressor bzip2
Caption "${name}-${version} Installer"
AutoCloseWindow false
SilentInstall normal
CRCCheck on
SetCompress auto
SetDatablockOptimize on
WindowIcon on
ShowInstDetails show
ShowUnInstDetails show
; Locations
Name "${name}"
OutFile "${target_file}"
InstallDir "$PROGRAMFILES\${name}-${version}"
; Icons
;!define MUI_ICON "${icon}"
;@-<< prolog >>
;@+<< pages >>
;@+node:ekr.20101027115225.1496: ** << pages >>
;@@language nsi
Var StartMenuFolder
; Define the TEXT_TOP for both the MUI_PAGE_DIRECTORY pages.
; "${s1a} ${s2} ${s3}" is the TEXT_TOP for the Install Location page.
; "${s2b} ${s2} ${s3}" is the TEXT_TOP for the Choose Python Folder page.
!define s1a "Setup will install ${name} in the following folder."
!define s1b "Setup will use the following folder as the Python location."
!define s2 "To install in a different folder, click Browse and select another folder."
!define s3 "Click next to continue."
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE ${license}
!insertmacro MUI_PAGE_COMPONENTS
; These are the defaults, but defined them here so the back button works.
!define MUI_PAGE_HEADER_TEXT "Choose Install Location"
!define MUI_PAGE_HEADER_SUBTEXT "Choose the folder in which to install ${name}"
!define MUI_DIRECTORYPAGE_TEXT_TOP "${s1a} ${s2} ${s3}"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Destination Folder"
!insertmacro MUI_PAGE_DIRECTORY
; It's so easy: just set these *before* creating another directory page!
!define MUI_PAGE_HEADER_TEXT "Choose Python Location"
!define MUI_PAGE_HEADER_SUBTEXT "Select the top-level Python directory"
!define MUI_DIRECTORYPAGE_TEXT_TOP "${s1b} ${s2} ${s3}"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Python Folder"
!define MUI_DIRECTORYPAGE_VARIABLE $PythonDirectory
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU "Application" $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
; ----- uninstaller pages -----
!insertmacro MUI_UNPAGE_WELCOME
; !insertmacro MUI_UNPAGE_LICENSE ${license}
; !insertmacro MUI_UNPAGE_CONFIRM
; !insertmacro MUI_UNPAGE_COMPONENTS ; doesn't actually list components.
!insertmacro MUI_UNPAGE_DIRECTORY
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;@-<< pages >>
; Language should follow pages.
!insertmacro MUI_LANGUAGE "English"
; The order of sections *does* matter slightly.
; It determines the order of items in the components dialog.
; It may also have some other very subtle effects.
;@+others
;@+node:ekr.20101027115225.1497: ** onInit
; Set PythonDirectory to the top-level Python path.
; For now, prefer Python 2.x to Python 3.x.
Function .onInit
;try27:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\2.7\InstallPath" ""
StrCmp $9 "" try26 ok
try26:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\2.6\InstallPath" ""
StrCmp $9 "" try35 ok
try35:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.5\InstallPath" ""
StrCmp $9 "" try34 ok
try34:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.4\InstallPath" ""
StrCmp $9 "" try33 ok
try33:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.3\InstallPath" ""
StrCmp $9 "" try32 ok
try32:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.2\InstallPath" ""
StrCmp $9 "" try31 ok
try31:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.1\InstallPath" ""
StrCmp $9 "" try30 ok
try30:
ReadRegStr $9 HKLM "SOFTWARE\Python\PythonCore\3.0\InstallPath" ""
StrCmp $9 "" oops ok
oops:
MessageBox MB_OK "Python not found"
StrCpy $PythonDirectory ""
Goto done
ok:
StrCpy $PythonDirectory $9
done:
FunctionEnd ; End .onInit
;@+node:ekr.20101027115225.1504: ** Section Leo
; The name of this section must be "Leo".
Section "Leo" SEC01
; Add all files and directories.
; The make-leo button creates nsi-install-files.txt.
!include nsi-install-files.txt
SectionEnd
;@+node:ekr.20101027115225.1499: ** Section File Association
Section "${ext} File Association" SEC02
SectionIn 1 2 3 4
WriteRegStr HKCR "${ext}" "" "${name}File"
WriteRegStr HKCR "${name}File" "" "${name} File"
WriteRegStr HKCR "${name}File\shell" "" "open"
; The single quotes below appear to be required.
WriteRegStr HKCR "${name}File\DefaultIcon" "" '"$INSTDIR\${app_icon}"'
; https://github.com/leo-editor/leo-editor/issues/24
WriteRegStr HKCR "${name}File\shell\open\command" "" '"${PythonExecutable}" "$INSTDIR\launchLeo.py %*"'
SectionEnd
;@+node:ekr.20101027115225.1498: ** Section Desktop Shortcut
Section "${name} Desktop Shortcut" SEC03
; This sets the "Start in folder" box!!!"
SetOutPath "$INSTDIR\leo"
;;; This is **tricky**. We need single quotes to handle paths containing spaces.
;;; Add single quotes around PythonExecutable and launchLeo.py args, but *not* the app_icon arg.
CreateShortCut "$DESKTOP\${name}.lnk" '"${PythonExecutable}"' '"$INSTDIR\launchLeo.py"' "$INSTDIR\${app_icon}"
SectionEnd
;@+node:ekr.20101027115225.1500: ** Section Start Menu
Section "${name} Start Menu" SEC04
CreateDirectory "$SMPROGRAMS\${name}"
;;; This is **tricky**. We need single quotes to handle paths containing spaces.
;;; Add single quotes around PythonExecutable and launchLeo.py args, but *not* the app_icon arg.
CreateShortCut "$SMPROGRAMS\${name}\${name}.lnk" '"${PythonExecutable}"' '"$INSTDIR\launchLeo.py"' "$INSTDIR\${app_icon}"
CreateShortCut "$SMPROGRAMS\${name}\Uninstall.lnk" '"$INSTDIR\uninst.exe"'
SectionEnd
;@+node:ekr.20101027115225.1501: ** Section -Post
Section -Post
WriteRegStr HKLM ${leo_hklm} "" "$INSTDIR"
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${uninst_key}" "DisplayName" "${name}-${version} (remove only)"
WriteRegStr HKLM "${uninst_key}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr HKLM "${uninst_key}" "DisplayVersion" "${version}"
WriteRegStr HKLM "${uninst_key}" "URLInfoAbout" "${site}"
WriteRegStr HKLM "${uninst_key}" "Publisher" "${publisher}"
SectionEnd
;@+node:ekr.20101027115225.1503: ** Section Uninstall
Section Uninstall
DeleteRegKey HKLM "${leo_hklm}"
DeleteRegKey HKCR "${ext}"
DeleteRegKey HKCR "${name}File"
; Safely removes all files and directories, including $INSTDIR.
; The make-leo button creates nsi-uninstall-files.txt.
!include nsi-uninstall-files.txt
; Remove links.
Delete "$SMPROGRAMS\${name}\Uninstall.lnk"
Delete "$SMPROGRAMS\${name}.lnk"
; RMDir "$SMPROGRAMS\${name}-${version}"
RMDir "$SMPROGRAMS\${name}"
Delete "$DESKTOP\${name}.lnk"
DeleteRegKey HKLM "${uninst_key}"
SetAutoClose false
SectionEnd ; end Uninstall section
;@-others
;@-leo