File: nsis_template.py

package info (click to toggle)
pyhoca-gui 0.6.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,524 kB
  • sloc: python: 6,911; makefile: 37; sh: 20
file content (400 lines) | stat: -rw-r--r-- 13,954 bytes parent folder | download | duplicates (2)
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
394
395
396
397
398
399
400
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8

# Copyright (C) 2010-2020 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
#
# PyHoca is free software; you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# PyHoca 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.

NSIS_SCRIPT_TEMPLATE = """
;{program_name}.nsi
;

!define VERSION {program_version}

!define UNINSTALL_REGKEY    "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}"

;--------------------------------

; The name of the installer
Name "{program_name}"

; Sets the title bar text
Caption "{program_desc_short}"

!define distOutputDirectory '{output_dir}'

; The file to write
OutFile "..\\{program_name}_${{VERSION}}_win32-setup.exe"

; The default installation directory
InstallDir $PROGRAMFILES\\{program_name}

; NSIS 2.46 defaults to zlib. Setting this reduces the size of current
; builds (which include no fonts for the X server) by about 27%
SetCompressor /SOLID lzma

; Registry key to check for directory (so if you install again, it will
; overwrite the old one automatically)
InstallDirRegKey HKLM "Software\\{program_name}" "Install_Dir"

; OBSOLETE WITH MUI2: Request application privileges for Windows Vista
;RequestExecutionLevel admin

!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!include MultiUser.nsh
!include MUI2.nsh

!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_LICENSE COPYING
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "English" ;first language is the default language
;!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
;!insertmacro MUI_LANGUAGE "SpanishInternational"
;!insertmacro MUI_LANGUAGE "SimpChinese"
;!insertmacro MUI_LANGUAGE "TradChinese"
;!insertmacro MUI_LANGUAGE "Japanese"
;!insertmacro MUI_LANGUAGE "Korean"
;!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Dutch"
;!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Swedish"
;!insertmacro MUI_LANGUAGE "Norwegian"
;!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
;!insertmacro MUI_LANGUAGE "Finnish"
;!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Russian"
;!insertmacro MUI_LANGUAGE "Portuguese"
;!insertmacro MUI_LANGUAGE "PortugueseBR"
;!insertmacro MUI_LANGUAGE "Polish"
;!insertmacro MUI_LANGUAGE "Ukrainian"
;!insertmacro MUI_LANGUAGE "Czech"
;!insertmacro MUI_LANGUAGE "Slovak"
;!insertmacro MUI_LANGUAGE "Croatian"
;!insertmacro MUI_LANGUAGE "Bulgarian"
;!insertmacro MUI_LANGUAGE "Hungarian"
;!insertmacro MUI_LANGUAGE "Thai"
;!insertmacro MUI_LANGUAGE "Romanian"
;!insertmacro MUI_LANGUAGE "Latvian"
;!insertmacro MUI_LANGUAGE "Macedonian"
;!insertmacro MUI_LANGUAGE "Estonian"
;!insertmacro MUI_LANGUAGE "Turkish"
;!insertmacro MUI_LANGUAGE "Lithuanian"
;!insertmacro MUI_LANGUAGE "Slovenian"
;!insertmacro MUI_LANGUAGE "Serbian"
;!insertmacro MUI_LANGUAGE "SerbianLatin"
;!insertmacro MUI_LANGUAGE "Arabic"
;!insertmacro MUI_LANGUAGE "Farsi"
;!insertmacro MUI_LANGUAGE "Hebrew"
;!insertmacro MUI_LANGUAGE "Indonesian"
;!insertmacro MUI_LANGUAGE "Mongolian"
;!insertmacro MUI_LANGUAGE "Luxembourgish"
;!insertmacro MUI_LANGUAGE "Albanian"
;!insertmacro MUI_LANGUAGE "Breton"
;!insertmacro MUI_LANGUAGE "Belarusian"
;!insertmacro MUI_LANGUAGE "Icelandic"
;!insertmacro MUI_LANGUAGE "Malay"
;!insertmacro MUI_LANGUAGE "Bosnian"
;!insertmacro MUI_LANGUAGE "Kurdish"
;!insertmacro MUI_LANGUAGE "Irish"
;!insertmacro MUI_LANGUAGE "Uzbek"
;!insertmacro MUI_LANGUAGE "Galician"
;!insertmacro MUI_LANGUAGE "Afrikaans"
;!insertmacro MUI_LANGUAGE "Catalan"
;!insertmacro MUI_LANGUAGE "Esperanto"
;!insertmacro MUI_LANGUAGE "Asturian"

; License data
; Not exactly translated, but it shows what's needed
LicenseLangString myLicenseData ${{LANG_ENGLISH}} "COPYING"
LicenseLangString myLicenseData ${{LANG_DUTCH}} "COPYING"
;LicenseLangString myLicenseData ${{LANG_FRENCH}} "COPYING"
LicenseLangString myLicenseData ${{LANG_GERMAN}} "COPYING"
;LicenseLangString myLicenseData ${{LANG_KOREAN}} "COPYING"
LicenseLangString myLicenseData ${{LANG_RUSSIAN}} "COPYING"
LicenseLangString myLicenseData ${{LANG_SPANISH}} "COPYING"
LicenseLangString myLicenseData ${{LANG_SWEDISH}} "COPYING"
;LicenseLangString myLicenseData ${{LANG_TRADCHINESE}} "COPYING"
;LicenseLangString myLicenseData ${{LANG_SIMPCHINESE}} "COPYING"
;LicenseLangString myLicenseData ${{LANG_SLOVAK}} "COPYING"

LicenseData $(myLicenseData)

; Set name using the normal interface (Name command)
LangString Name ${{LANG_ENGLISH}} "English"
LangString Name ${{LANG_DUTCH}} "Dutch"
;LangString Name ${{LANG_FRENCH}} "French"
LangString Name ${{LANG_GERMAN}} "German"
;LangString Name ${{LANG_KOREAN}} "Korean"
LangString Name ${{LANG_RUSSIAN}} "Russian"
LangString Name ${{LANG_SPANISH}} "Spanish"
LangString Name ${{LANG_SWEDISH}} "Swedish"
;LangString Name ${{LANG_TRADCHINESE}} "Traditional Chinese"
;LangString Name ${{LANG_SIMPCHINESE}} "Simplified Chinese"
;LangString Name ${{LANG_SLOVAK}} "Slovak"

;--------------------------------

; Installer Language Configuration

;!include LogicLib.nsh

var LC_MESSAGES

; i18n strings
var REQUIRED
var DESKTOP_LINKS
var STARTMENU_LINKS
var WITHOUT_PULSEAUDIO
var GSPRINT

Function .onInit

;        ;Language selection dialog
;
        Push ""
        Push ${{LANG_ENGLISH}}
        Push English
        Push ${{LANG_DUTCH}}
        Push Dutch
;       Push ${{LANG_FRENCH}}
;       Push French
        Push ${{LANG_GERMAN}}
        Push German
;       Push ${{LANG_KOREAN}}
;       Push Korean
        Push ${{LANG_RUSSIAN}}
        Push Russian
        Push ${{LANG_SPANISH}}
        Push Spanish
        Push ${{LANG_SWEDISH}}
        Push Swedish
;       Push ${{LANG_TRADCHINESE}}
;       Push "Traditional Chinese"
;       Push ${{LANG_SIMPCHINESE}}
;       Push "Simplified Chinese"
;       Push ${{LANG_SLOVAK}}
;       Push Slovak
        Push A ; A means auto count languages
               ; for the auto count to work the first empty push (Push "") must remain
        LangDLL::LangDialog "Installer Language" "Please select the language of the installer"

        Pop $LANGUAGE

        ${{Switch}} $LANGUAGE
          ${{Case}} 1031
            StrCpy $LC_MESSAGES "de"
            !include "nsis_include\\de.nsi"
            ${{Break}}
          ${{Case}} 1033
            StrCpy $LC_MESSAGES "en"
            !include "nsis_include\\en.nsi"
            ${{Break}}
          ${{Case}} 1043
            StrCpy $LC_MESSAGES "nl"
            !include "nsis_include\\nl.nsi"
            ${{Break}}
          ${{Case}} 1034
            StrCpy $LC_MESSAGES "es"
            !include "nsis_include\\es.nsi"
            ${{Break}}
          ${{Case}} 1053
            StrCpy $LC_MESSAGES "sv"
            !include "nsis_include\\sv.nsi"
            ${{Break}}
          ${{Case}} 1049
            StrCpy $LC_MESSAGES "ru"
            !include "nsis_include\\ru.nsi"
            ${{Break}}
        ${{EndSwitch}}

        StrCmp $LANGUAGE "cancel" 0 +2
            Abort

        !insertmacro MULTIUSER_INIT

FunctionEnd

Function un.onInit

        !insertmacro MULTIUSER_UNINIT

FunctionEnd

;--------------------------------

;--------------------------------
;Installer Sections

;"Recommended" is the default because it is specified 1st.
InstType "Recommended"
InstType "Full"
InstType "Minimal"

; The application and all its required dependencies
Section "{program_name} ($REQUIRED)"

  SectionIn RO
  ; Set output path to the installation directory.
  SetOutPath "$INSTDIR"
  ; Empty $INSTDIR before writing new files to it.
  RmDir /r "$INSTDIR\\*.*"
  ; Install new files...
  ; Due to a limitation of nsis, we cannot tell it to exclude vcxsrv\\fonts
  ; specifically. Instead, we must tell it to match every folder named
  ; "fonts" (of which there is only one.)
  File /r /x .svn /x .git /x fonts "${{distOutputDirectory}}\\*.*"

  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\\{program_name} "Install_Dir" "$INSTDIR"

  ; Write the uninstall keys for Windows

  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "InstallLocation"      "$INSTDIR"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "UninstallString"      "$INSTDIR\\uninstall.exe"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "DisplayIcon"          "$INSTDIR\\{icon_location}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "DisplayName"          "{uninstall_name}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "DisplayVersion"       "${{VERSION}}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "Publisher"            "{publisher}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "HelpLink"             "{url}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "URLInfoAbout"         "{url}"
  WriteRegStr HKLM ${{UNINSTALL_REGKEY}}   "URLUpdateInfo"        "{url}"
  WriteRegDWORD HKLM ${{UNINSTALL_REGKEY}} "NoModify" 1
  WriteRegDWORD HKLM ${{UNINSTALL_REGKEY}} "NoRepair" 1
  WriteUninstaller "uninstall.exe"

SectionEnd

SectionGroup "Fonts"

  ;Empirical testing shows that "misc" fixes compatibility for the majority
  ;of applications with font compatibility programs.
  ;So lets make "misc" be part of "recommended", and therefore the default.
  ;
  ;As of VcXsrv-xp 1.14.3.2
  ;misc is 412 files at 6.80 MB (7.94 MB on disk)
  Section "misc" fonts-misc
    ; SectionIn Recommended & Full
    SectionIn 1 2
    SetOutPath "$INSTDIR\\vcxsrv\\fonts\\"
    File "${{distOutputDirectory}}\\vcxsrv\\fonts\\fonts.conf"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\misc"
  SectionEnd

  ;As of VcXsrv-xp 1.14.3.2
  ;75dpi is 1,897 files at 10.7 MB (15.6 MB on disk)
  Section "75dpi" fonts-75dpi
    ; SectionIn Full
    SectionIn 2
    SetOutPath "$INSTDIR\\vcxsrv\\fonts\\"
    File "${{distOutputDirectory}}\\vcxsrv\\fonts\\fonts.conf"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\75dpi"
  SectionEnd

  ;As of VcXsrv-xp 1.14.3.2
  ;100dpi is 1,897 files at 12.3 MB (16.8 MB on disk)
  Section "100dpi" fonts-100dpi
    ; SectionIn Full
    SectionIn 2
    SetOutPath "$INSTDIR\\vcxsrv\\fonts\\"
    File "${{distOutputDirectory}}\\vcxsrv\\fonts\\fonts.conf"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\100dpi"
  SectionEnd

  ;As of VcXsrv-xp 1.14.3.2
  ;everything else is 466 files at 12.8MB (13.8 MB on disk)
  Section "others" fonts-others
    ; SectionIn Full
    SectionIn 2
    SetOutPath "$INSTDIR\\vcxsrv\\fonts\\"
    File "${{distOutputDirectory}}\\vcxsrv\\fonts\\fonts.conf"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\cyrillic"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\encodings"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\OTF"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\Speedo"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\terminus-font"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\TTF"
    File /r "${{distOutputDirectory}}\\vcxsrv\\fonts\\Type1"
  SectionEnd

SectionGroupEnd

; Optional section (can be disabled by the user)
Section "$STARTMENU_LINKS"

  ; SectionIn Recommended & Full
  SectionIn 1 2

  SetOutPath "$INSTDIR"
  CreateDirectory "$SMPROGRAMS\\{program_name}"
  CreateShortCut "$SMPROGRAMS\\{program_name}\\{program_name}.lnk" "$INSTDIR\\{program_name}.exe" "--quiet --start-xserver --start-pulseaudio --lang $LC_MESSAGES" "$INSTDIR\\icons\\{program_name}.ico" 0
  CreateShortCut "$SMPROGRAMS\\{program_name}\\{program_name} ($WITHOUT_PULSEAUDIO).lnk" "$INSTDIR\\{program_name}.exe" "--quiet --start-xserver --lang $LC_MESSAGES" "$INSTDIR\\icons\\{program_name}.ico" 0
  CreateShortCut "$SMPROGRAMS\\{program_name}\\{program_name} (debug).lnk" "$INSTDIR\\{program_name}.exe" "--debug --libdebug --start-xserver --start-pulseaudio --lang $LC_MESSAGES" "$INSTDIR\\icons\\{program_name}.ico" 0
  CreateShortCut "$SMPROGRAMS\\{program_name}\\{program_name} ($WITHOUT_PULSEAUDIO, debug).lnk" "$INSTDIR\\{program_name}.exe" "--debug --libdebug --start-xserver --lang $LC_MESSAGES" "$INSTDIR\\icons\\{program_name}.ico" 0
  CreateShortCut "$SMPROGRAMS\\{program_name}\\X2Go Website.lnk" "https://www.x2go.org" "" "$INSTDIR\\icons\\pyhoca_x2go-logo-ubuntu.ico" 0
  CreateShortCut "$SMPROGRAMS\\{program_name}\\Uninstall.lnk" "$INSTDIR\\uninstall.exe" "" "$INSTDIR\\uninstall.exe" 0

SectionEnd

; Optional section (can be disabled by the user)
Section "$DESKTOP_LINKS"

  ; SectionIn Recommended & Full
  SectionIn 1 2

  SetOutPath "$INSTDIR"
  CreateShortCut "$DESKTOP\\{program_name}.lnk" "$INSTDIR\\{program_name}.exe" "--quiet --start-xserver --start-pulseaudio --lang $LC_MESSAGES" "$INSTDIR\\icons\\{program_name}.ico" 0

SectionEnd

; Hidden section, always enabled
Section -EstimatedSize
  SectionIn RO
  ${{GetSize}} "$INSTDIR" "/S=0K" $0 $1 $2
  IntFmt $0 "0x%08X" $0
  WriteRegDWORD HKLM ${{UNINSTALL_REGKEY}} "EstimatedSize" "$0"
SectionEnd

;--------------------------------

; Uninstaller

Section "Uninstall"

  ; Remove registry keys
  DeleteRegKey HKLM ${{UNINSTALL_REGKEY}}
  DeleteRegKey HKLM SOFTWARE\\{program_name}

  ; Remove files and uninstaller
  Delete $INSTDIR\\uninstall.exe

  ; Remove shortcuts, if any
  Delete "$SMPROGRAMS\\{program_name}\\*.*"
  Delete "$DESKTOP\\{program_name}.lnk"

  ; Remove directories used
  RMDir "$SMPROGRAMS\\{program_name}"
  RMDir /r /REBOOTOK $INSTDIR

SectionEnd
"""