pw3270.nsi.in
12.1 KB
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# Copyright (C) 2021 Perry Werneck <perry.werneck@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
!include "MUI2.nsh"
!include "x64.nsh"
!include "FileFunc.nsh"
!include "LogicLib.nsh"
!include "winmessages.nsh"
Name "@PRODUCT_NAME@"
Caption "@PRODUCT_NAME@ - @PACKAGE_DESCRIPTION@"
outfile "@PRODUCT_NAME@-@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@-@host_cpu@.exe"
XPStyle on
installDir "$@PROGRAMFILES@\@PRODUCT_NAME@"
#define the installer icon
!define MUI_ICON "bin\@PRODUCT_NAME@.ico"
!define MUI_UNICON "bin\@PRODUCT_NAME@.ico"
icon "bin\@PRODUCT_NAME@.ico"
# Get installation folder from registry if available
InstallDirRegKey HKLM "Software\@PRODUCT_NAME@" "InstallLocation"
RequestExecutionLevel admin
# Properties
VIProductVersion "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@"
VIFileVersion "@WIN32_VERSION@"
# Reference: https://nsis.sourceforge.io/Reference/VIAddVersionKey
VIAddVersionKey "ProductVersion" "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@"
VIAddVersionKey "FileVersion" "@WIN32_VERSION@"
VIAddVersionKey "ProductName" "@PRODUCT_NAME@"
VIAddVersionKey "FileDescription" "@PACKAGE_DESCRIPTION@"
VIAddVersionKey "LegalCopyright" "(C) 2017 Banco do Brasil S/A. All Rights Reserved"
# VIAddVersionKey "PrivateBuild" ""
# Interface
!define MUI_ABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "share\@PRODUCT_NAME@\LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
# Languages
!insertmacro MUI_LANGUAGE "English"
# Section scripts
!include Sections.nsh
# default section
SubSection "@PRODUCT_NAME@" SecMain
Section "@PRODUCT_NAME@" SecCore
SetRegView @WINARCH@
${DisableX64FSRedirection}
# Set SMPROGRAMS and DESKTOP path
SetShellVarContext all
# Binary files
setOutPath "$INSTDIR"
file /r "bin"
setOutPath "$INSTDIR\share\@PRODUCT_NAME@"
file /r "share\@PRODUCT_NAME@\*.png"
file /r "share\@PRODUCT_NAME@\*.svg"
file /r "share\@PRODUCT_NAME@\*.ui.xml"
file /r "share\@PRODUCT_NAME@\*.conf"
setOutPath "$INSTDIR\share\@PRODUCT_NAME@\remap"
file /r "share\@PRODUCT_NAME@\remap\*"
setOutPath "$INSTDIR\lib\gdk-pixbuf-2.0"
file /r "lib\gdk-pixbuf-2.0\*"
setOutPath "$INSTDIR\etc"
file /r "etc\*"
setOutPath "$INSTDIR\share\locale"
file /r "share\locale\*"
setOutPath "$INSTDIR\share\themes"
file /r "share\themes\*"
setOutPath "$INSTDIR\share\icons"
file /r "share\icons\*"
setOutPath "$INSTDIR\share\glib-2.0"
file /r "share\glib-2.0\*"
setOutPath "$INSTDIR\share\@PRODUCT_NAME@\icons"
file /r "share\@PRODUCT_NAME@\icons\*"
# define uninstaller name
SetRegView 32
writeUninstaller $INSTDIR\uninstall.exe
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"DisplayName" "@PRODUCT_NAME@ - @PACKAGE_DESCRIPTION@"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"DisplayIcon" "$INSTDIR\@PRODUCT_NAME@.ico"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"DisplayVersion" "@PACKAGE_MAJOR_VERSION@.@PACKAGE_MINOR_VERSION@.@PACKAGE_MAJOR_RELEASE@.@PACKAGE_MINOR_RELEASE@"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"NoModify" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@" \
"NoRepair" "1"
# Default settings
SetRegView @WINARCH@
# Setup log file
# https://docs.microsoft.com/en-us/windows/win32/eventlog/event-sources
WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\EventLog\@PRODUCT_NAME@" \
"PackageVersion" "@PACKAGE_VERSION@"
# Required for IPC Library.
WriteRegStr HKLM "Software\@PRODUCT_NAME@" "InstallLocation" "$INSTDIR"
# Customized options
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "autoconnect" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "blankfill" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "bold" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "keepselected" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "marginedpaste" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "rectselect" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "monocase" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "cursorblink" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "showtiming" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "cursorpos" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "linewrap" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "crosshair" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "fullscreen" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "autoreconnect" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "insert" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "smartpaste" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "beep" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "fieldattr" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "altscreen" 0x00000001
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "keepalive" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "dstrace" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "screentrace" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "eventtrace" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "nettrace" 0x00000000
WriteRegDWORD HKLM "Software\@PRODUCT_NAME@\toggles" "ssltrace" 0x00000000
WriteRegStr HKLM "Software\@PRODUCT_NAME@" "font-family" "Lucida Console"
WriteRegStr HKLM "Software\@PRODUCT_NAME@" "colors" "rgb(24,24,24);rgb(79,156,254);rgb(237,74,70);rgb(235,110,183);rgb(131,199,70);rgb(86,216,201);rgb(239,197,65);rgb(222,222,222);rgb(59,59,59);rgb(54,142,171);rgb(250,145,83);rgb(165,128,226);rgb(112,180,51);rgb(65,199,185);rgb(219,179,45);rgb(119,119,119);rgb(131,199,70);rgb(237,74,70);rgb(65,199,185);rgb(250,145,83);rgb(37,37,37);rgb(222,222,222);rgb(222,222,222);rgb(24,24,24);rgb(222,222,222);rgb(79,156,254);rgb(131,199,70);rgb(239,197,65);rgb(239,197,65)"
createShortCut "$SMPROGRAMS\@PRODUCT_NAME@.lnk" "$INSTDIR\bin\@PRODUCT_NAME@.exe" "" "$INSTDIR\bin\@PRODUCT_NAME@.ico"
createShortCut "$DESKTOP\@PRODUCT_NAME@.lnk" "$INSTDIR\bin\@PRODUCT_NAME@.exe" "" "$INSTDIR\bin\@PRODUCT_NAME@.ico"
sectionEnd
!ifdef WITHSDK
Section /o "Software Development Kit" SDK
setOutPath $INSTDIR\sdk\include
file /r "include\*.*"
setOutPath $INSTDIR\sdk\lib
file /r "lib\*.a"
setOutPath $INSTDIR\sdk\lib\pkgconfig
file /r "lib\pkgconfig\*.pc"
setOutPath $INSTDIR\sdk\msvc
file /r "share\@PRODUCT_NAME@\def\*.def"
file /r "share\@PRODUCT_NAME@\def\*.mak"
SetRegView @WINARCH@
WriteRegExpandStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PW3270_SDK_PATH" "$INSTDIR\sdk"
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
SectionEnd
!endif
!ifdef WITHCERTS
Section "SSL Certificates" SSLCerts
setOutPath $INSTDIR\certs
file /r "sslcerts\*.*"
sectionEnd
!endif
SubSection "Plugins" SecPLugin
Section "Remote control" IPCPlugin
${DisableX64FSRedirection}
CreateDirectory "$INSTDIR\lib\@PRODUCT_NAME@-plugins"
file "/oname=$INSTDIR\lib\@PRODUCT_NAME@-plugins\ipcserver.dll" "lib\@PRODUCT_NAME@-plugins\ipcserver.dll"
sectionEnd
SubSectionEnd
SubSectionEnd
Section "Uninstall"
# Always delete uninstaller first
delete $INSTDIR\uninstaller.exe
# Remove association
# Set SMPROGRAMS and DESKTOP path
SetShellVarContext all
# now delete installed files
delete $INSTDIR\@PRODUCT_NAME@.exe
delete $SMPROGRAMS\@PRODUCT_NAME@.lnk
delete $DESKTOP\@PRODUCT_NAME@.lnk
RMDir /r "$INSTDIR"
# Remove registry
SetRegView 32
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@PRODUCT_NAME@"
DeleteRegKey HKLM "Software\@PRODUCT_NAME@"
SetRegView @WINARCH@
DeleteRegKey HKLM "Software\@PRODUCT_NAME@"
DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PW3270_SDK_PATH"
DeleteRegKey HKLM "SYSTEM\CurrentControlSet\Services\EventLog\@PRODUCT_NAME@"
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
DeleteRegKey HKLM "Software\GSettings\apps\@PACKAGE_NAME@\@PRODUCT_NAME@"
# Delete System libraries
${@NSISREDIR@}
delete $SYSDIR\libipc3270.dll
!ifdef WITHLIBHLLAPI
delete $SYSDIR\libhllapi.dll
delete $SYSDIR\hllapi.dll
!endif
!ifdef WITHMONO-TN3270
delete $SYSDIR\mono-tn3270.dll
!endif
RMDir /r "$INSTDIR"
SectionEnd
Function .onInit
#---[ Check if already installed ]--------------------------------------------------------------------
${If} ${FileExists} "$INSTDIR\@PRODUCT_NAME@.exe"
MessageBox MB_OK|MB_ICONEXCLAMATION "@PRODUCT_NAME@ is already installed. Please uninstall it first" /SD IDOK
Abort
${EndIf}
#---[ Check SDK Command line option ]-----------------------------------------------------------------
!ifdef WITHSDK
Push $0
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /SDK= $0
${if} $0 == "YES"
SectionGetFlags ${SDK} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${SDK} $0
${else}
SectionGetFlags ${SDK} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${SDK} $0
${EndIf}
Pop $0
!endif
#---[ Check DOTNET Command line option ]--------------------------------------------------------------
!ifdef WITHMONO-TN3270
Push $0
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /DOTNET= $0
# Default = NO
${if} $0 == "YES"
SectionGetFlags ${DOTNET} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${DOTNET} $0
SectionGetFlags ${IPCPlugin} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${IPCPlugin} $0
${else}
SectionGetFlags ${DOTNET} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${DOTNET} $0
${EndIf}
Pop $0
!endif
#---[ Check HLLAPI Command line option ]-------------------------------------------------------------
!ifdef WITHLIBHLLAPI
Push $0
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /HLLAPI= $0
# Default = YES
${if} $0 == "NO"
SectionGetFlags ${HLLAPIBinding} $0
IntOp $0 $0 & ${SECTION_OFF}
SectionSetFlags ${HLLAPIBinding} $0
${else}
SectionGetFlags ${HLLAPIBinding} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${HLLAPIBinding} $0
SectionGetFlags ${IPCPlugin} $0
IntOp $0 $0 | ${SF_SELECTED}
SectionSetFlags ${IPCPlugin} $0
${EndIf}
Pop $0
!endif
FunctionEnd
Function .onInstSuccess
# Update GTK Image loaders
FunctionEnd