-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_installer.nsi
229 lines (177 loc) · 7.62 KB
/
build_installer.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
; Installer / UnInstaller Script for gtksourceview for Inkscape
; You need to run "python build_packages.py" before executing this
; script in order to prepare the files to be packaged.
; Set the ARCHITECTURE variable to either 32 or 64 depending on
; the architecture you want to build the installer for
; Use only for Inkscape 1.0
Unicode True
; Product name and version information
!define PRODUCT_NAME "GtkSourceView 3.24.11 for Inkscape"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_REGKEY "${PRODUCT_NAME} ${PRODUCT_VERSION}"
!define PRODUCT_PUBLISHER "TexText"
!define ARCHITECTURE "32"
; Names of the installer executable
!define INSTALLER_NAME "Install-GtkSourceView-3.24-Inkscape-${PRODUCT_VERSION}-${ARCHITECTURE}bit.exe"
!define UNINSTALLER_NAME "UnInstall-GtkSourceView-3.24-Inkscape-${PRODUCT_VERSION}-${ARCHITECTURE}bit.exe"
; Basic registry keys (required by uninstall)
!define INSTDIR_REG_ROOT "HKLM"
!define INSTDIR_REG_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_REGKEY}"
; List of files (autogenerated from Python script "create_installer_file_lists.py")
; calling command: python create_installer_file_lists.py 'files inst_file_list.txt' 'uninst_file_list.txt'
!define FILES_SOURCE_PATH "files/${ARCHITECTURE}bit"
!define INST_FILE_LIST "inst_file_list_${ARCHITECTURE}bit.txt"
!define UNINST_FILE_LIST "uninst_file_list_${ARCHITECTURE}bit.txt"
; Inkscape registry key
!define INKSCAPE_REG_KEY "Software\Inkscape\Inkscape"
; Use modern user interface
!include "MUI2.nsh"
!include "LogicLib.nsh"
; MUI Settings
!define MUI_ABORTWARNING
; Welcome page (with detailed information what is going to be installed)
!define MUI_WELCOMEPAGE_TITLE "Welcome to the installation of ${PRODUCT_NAME}!"
!define MUI_TEXT_WELCOME_INFO_TEXT "${PRODUCT_NAME} ${PRODUCT_VERSION} will be installed into the \
base folder of your Inkscape installation. $\n$\n\
GtkSourceView is required by Inkscape-extensions which offer syntax highlighting. $\n$\n\
You can always uninstall all files of this intallation using the provided uninstaller which can be invoked via the well known Windows control panel.$\n$\n\
Now, Setup will guide you through the installation of ${PRODUCT_NAME}.$\n$\n"
!define MUI_WELCOMEPAGE_TITLE_3LINES
!define MUI_PAGE_CUSTOMFUNCTION_SHOW MyWelcomeShowCallback
!insertmacro MUI_PAGE_WELCOME
; License page
!insertmacro MUI_PAGE_LICENSE "LICENSE"
; Directory page
!define MUI_DIRECTORYPAGE_TEXT_TOP "If not already done automatically, please select the folder of your Inkscape installation, \
i.e. the folder that contains the bin, include, lib, and share directories.$\n$\n\
${PRODUCT_NAME} ${PRODUCT_VERSION} will then be installed in the bin, include, lib, and share subdirectories of your Inkscape installation.$\n$\n\
Installation proceeds only when you select a valid Inkscape installation directory!"
!define MUI_DIRECTORYPAGE_TEXT_DESTINATION "Automatically detected Inkscape installation directory"
!define MUI_PAGE_CUSTOMFUNCTION_PRE DirPageInitFunc
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH
; Uninstaller welcome page
!insertmacro MUI_UNPAGE_WELCOME
; Uninstaller confirmation page
!insertmacro MUI_UNPAGE_CONFIRM
; Define what is going to be uninstalled
!insertmacro MUI_UNPAGE_INSTFILES
; Uninstaller finish page
!insertmacro MUI_UNPAGE_FINISH
; Language files
!insertmacro MUI_LANGUAGE "English"
; MUI end ------
; Set some variables
; Since we install into the progam files directory we need administrator privileges
RequestExecutionLevel admin
; The full name of the product
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
; Define where the installer is built
OutFile "build\${INSTALLER_NAME}"
; For details
ShowInstDetails show
Function MyWelcomeShowCallback
SendMessage $mui.WelcomePage.Text ${WM_SETTEXT} 0 "STR:$(MUI_TEXT_WELCOME_INFO_TEXT)"
FunctionEnd
; In this function we try to find where Inkscape is installed. Since the Inkscape installer
; does not write anything useful into the windows registry we have to guess:
; At first we try to look in the 64-bit Program Files directory. If this fails we check
; the 32-bit Program Files directory. If this also fails a message is shown and the user
; has to select the correct directory manually later.
Function DirPageInitFunc
ReadRegStr $0 HKLM ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_HKCU 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_HKCU
goto func_end
check_HKCU:
ReadRegStr $0 HKCU ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_HKLM32 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_HKLM32
goto func_end
check_HKLM32:
SetRegView 32
ReadRegStr $0 HKLM ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_HKCU32 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_HKCU32
goto func_end
check_HKCU32:
SetRegView 32
ReadRegStr $0 HKCU ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_HKLM64 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_HKLM64
goto func_end
check_HKLM64:
SetRegView 64
ReadRegStr $0 HKLM ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_HKCU64 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_HKCU64
goto func_end
check_HKCU64:
SetRegView 64
ReadRegStr $0 HKCU ${INKSCAPE_REG_KEY} ""
StrCmp $0 "" check_64bit 0
StrCpy $INSTDIR $0
IfFileExists $INSTDIR\bin\inkscape.exe 0 check_64bit
;MessageBox MB_OK $INSTDIR IDOK check_64bit
goto func_end
check_64bit:
IfFileExists $PROGRAMFILES64\Inkscape\bin\inkscape.exe 0 check_32bit
StrCpy $INSTDIR $PROGRAMFILES64\Inkscape
goto func_end
check_32bit:
IfFileExists $PROGRAMFILES32\Inkscape\bin\inkscape.exe 0 show_error
StrCpy $INSTDIR $PROGRAMFILES32\Inkscape
goto func_end
show_error:
StrCpy $INSTDIR ""
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer was unable to detect the Inkscape installation directory automatically!\
Hence, you have to select the proper directory manually in the next step!" IDOK func_end
func_end:
FunctionEnd
; We check if the directory which has been selected by the user really contains inkscape.exe
; If not "Abort" is sent and the user cannot proceed the installation.
Function .onVerifyInstDir
IfFileExists $INSTDIR\bin\inkscape.exe path_ok 0
Abort
path_ok:
FunctionEnd
; Installer section
Section "Hauptgruppe" SEC_INSTALL
; Our stuff goes into the base directory of the Inkscape installation directory
SetOutPath $INSTDIR
SetOverwrite ifnewer
; The files we want to pack in the installer
!include ${INST_FILE_LIST}
; Uninstaller is put into the Inkscape installation directory
WriteUninstaller "$INSTDIR\${UNINSTALLER_NAME}"
; Some Registry strings for proper uninstallation
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "InstallDir" "$INSTDIR"
WriteRegStr ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "UninstallString" "$INSTDIR\${UNINSTALLER_NAME}"
; Determine how many bytes we have installed (displayed later in the windows control panel)
Push $0
SectionGetSize ${SEC_INSTALL} $0
IntFmt $0 "0x%08X" $0
WriteRegDWORD ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}" "EstimatedSize" "$0"
Pop $0
SectionEnd
; Uninstaller Section
; $INSTDIR is the directory in which the uninstaller resides!
Section "Uninstall"
; Delete Files
!include ${UNINST_FILE_LIST}
; Delete all registry keys
DeleteRegKey ${INSTDIR_REG_ROOT} "${INSTDIR_REG_KEY}"
; Delete the installer
Delete "$INSTDIR\${UNINSTALLER_NAME}"
SectionEnd