1;NSIS Modern User Interface
2;Multilingual Example Script
3;Written by Joost Verburg
4
5
6!include "MUI.nsh"
7!include "FileFunc.nsh"
8!include "Sections.nsh"
9!insertmacro Locate
10;--------------------------------
11;General
12
13  RequestExecutionLevel admin
14 !define VERSION "X2GOCLIENT_VERSION"
15 !define FILENAME "x2goclient-${VERSION}-setup.exe"
16  Name "x2goclient ${VERSION}"
17  Caption "x2goclient ${VERSION}"
18  OutFile "${FILENAME}"
19  !define MUI_ICON icons\win-install.ico
20  !define MUI_UNICON icons\win-uninstall.ico
21  ;Default installation folder
22  InstallDir "$PROGRAMFILES\x2goclient"
23
24  ;NSIS 2.46 defaults to zlib. Setting this reduces the size of a default
25  ;(no fonts) build by about 24%
26  SetCompressor /SOLID lzma
27
28  ;Get installation folder from registry if available
29  InstallDirRegKey HKLM "Software\x2goclient" ""
30
31;--------------------------------
32;Check if user is admin
33Section
34    userInfo::getAccountType
35    pop $0
36    strCmp $0 "Admin" +3
37    messageBox MB_OK $(ADM_RIGHT)
38    abort
39SectionEnd
40
41;--------------------------------
42;Interface Settings
43
44  !define MUI_ABORTWARNING
45
46;--------------------------------
47;Language Selection Dialog Settings
48
49  ;Remember the installer language
50  !define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
51  !define MUI_LANGDLL_REGISTRY_KEY "Software\x2goclient"
52  !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
53
54;------------------------------
55;Variables
56
57  Var STARTMENU_FOLDER
58  Var MUI_TEMP
59
60  !define  UNINSTALL_REGKEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\x2goclient"
61  !define  UNINSTALL_DISPLAYNAME "X2Go Client for Windows"
62  !define  UNINSTALL_PUBLISHER "X2Go Project"
63  !define  UNINSTALL_DISPLAYVERSION ${VERSION}
64  !define  UNINSTALL_URL "https://www.x2go.org"
65
66;--------------------------------
67;Pages
68
69  !insertmacro MUI_PAGE_LICENSE "gpl.txt"
70  !insertmacro MUI_PAGE_COMPONENTS
71  !insertmacro MUI_PAGE_DIRECTORY
72  !define MUI_STARTMENUPAGE_DEFAULTFOLDER "X2Go Client for Windows"
73  !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
74  !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\x2goclient"
75  !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
76  !insertmacro MUI_PAGE_STARTMENU "Application" $STARTMENU_FOLDER
77  !insertmacro MUI_PAGE_INSTFILES
78  !insertmacro MUI_UNPAGE_CONFIRM
79  !insertmacro MUI_UNPAGE_INSTFILES
80  !insertmacro MUI_PAGE_FINISH
81
82;--------------------------------
83;Languages
84
85  !insertmacro MUI_LANGUAGE "English"
86  !insertmacro MUI_LANGUAGE "German"
87  !insertmacro MUI_LANGUAGE "Russian"
88
89;------------------------------
90; File Properties
91
92  ; This gets truncated to a.b.c.d
93  VIProductVersion "${UNINSTALL_DISPLAYVERSION}"
94  VIAddVersionKey /LANG=${LANG_ENGLISH} "InternalName"     "x2goclient"
95  VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName"      "${UNINSTALL_DISPLAYNAME}"
96  VIAddVersionKey /LANG=${LANG_ENGLISH} "FileDescription"  "Installer for ${UNINSTALL_DISPLAYNAME}"
97  VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName"      "${UNINSTALL_PUBLISHER}"
98  VIAddVersionKey /LANG=${LANG_ENGLISH} "OriginalFilename" "${FILENAME}"
99  ; Due to NSIS "Feature Request" #270, this gets overriden by VIProductVersion
100  VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion"      "${UNINSTALL_DISPLAYVERSION}"
101  VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductVersion"   "${UNINSTALL_DISPLAYVERSION}"
102  VIAddVersionKey /LANG=${LANG_ENGLISH} "LegalCopyright"   "GPL-2+"
103
104;--------------------------------
105;Reserve Files
106
107  ;If you are using solid compression, files that are required before
108  ;the actual installation should be stored first in the data block,
109  ;because this will make your installer start faster.
110
111  !insertmacro MUI_RESERVEFILE_LANGDLL
112
113
114;--------------------------------
115;Installer Sections
116
117;"Recommended" is the default because it is specified 1st.
118InstType "Recommended"
119InstType "Full"
120InstType "Minimal"
121
122Section "X2Go Client (required)" base
123
124  SetShellVarContext all
125  SectionIn RO
126
127  SetOutPath "$INSTDIR"
128  File /a /x x2goclient.debug.exe /x pageant.exe /x puttygen.exe "x2goclient\*.*"
129  File /r "x2goclient\pulse"
130  File /r /x "fonts" "x2goclient\VcXsrv"
131  File "..\res\audio\startup.wav"
132
133  ;Store installation folder
134  WriteRegStr HKLM "Software\x2goclient" "" $INSTDIR
135
136  ;Create uninstaller
137  WriteUninstaller "$INSTDIR\Uninstall.exe"
138  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
139  CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER"
140  CreateShortCut "$INSTDIR\X2Go Client.lnk" "$INSTDIR\x2goclient.exe"
141  CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\X2Go Client.lnk" "$INSTDIR\x2goclient.exe"
142
143  ;Cleanup previous icon names (prior to X2Go Client 4.0.1.2)
144  Delete "$INSTDIR\X2GoClient.lnk"
145  Delete "$SMPROGRAMS\$STARTMENU_FOLDER\X2GoClient.lnk"
146  Delete "$DESKTOP\X2GoClient.lnk"
147
148  !insertmacro MUI_STARTMENU_WRITE_END
149
150  ;Add uninstall information to Add/Remove Programs
151  ;https://nsis.sourceforge.net/Add_uninstall_information_to_Add/Remove_Programs
152  WriteRegStr HKLM ${UNINSTALL_REGKEY} "InstallLocation"  "$INSTDIR"
153  WriteRegStr HKLM ${UNINSTALL_REGKEY} "UninstallString"  "$\"$INSTDIR\Uninstall.exe$\""
154  WriteRegStr HKLM ${UNINSTALL_REGKEY} "DisplayIcon"      "$INSTDIR\x2goclient.exe"
155  WriteRegStr HKLM ${UNINSTALL_REGKEY} "DisplayName"      "${UNINSTALL_DISPLAYNAME}"
156  WriteRegStr HKLM ${UNINSTALL_REGKEY} "Publisher"        "${UNINSTALL_PUBLISHER}"
157  WriteRegStr HKLM ${UNINSTALL_REGKEY} "DisplayVersion"   "${UNINSTALL_DISPLAYVERSION}"
158  WriteRegStr HKLM ${UNINSTALL_REGKEY} "HelpLink"         "${UNINSTALL_URL}"
159  WriteRegStr HKLM ${UNINSTALL_REGKEY} "URLInfoAbout"     "${UNINSTALL_URL}"
160  WriteRegStr HKLM ${UNINSTALL_REGKEY} "URLUpdateInfo"    "${UNINSTALL_URL}"
161  WriteRegDWORD HKLM ${UNINSTALL_REGKEY} "NoModify"       1
162  WriteRegDWORD HKLM ${UNINSTALL_REGKEY} "NoRepair"       1
163
164SectionEnd
165
166;x2goclient bug 108 fix
167SectionGroup "Fonts" fonts
168
169  ;Empirical testing shows that "misc" fixes compatibility for the majority
170  ;of applications with font compatibility programs.
171  ;So lets make "misc" be part of "recommended", and therefore the default.
172  ;
173  ;As of VcXsrv-xp 1.14.3.2
174  ;misc is 412 files at 6.80 MB (7.94 MB on disk)
175  Section "misc" fonts-misc
176    SectionIn 1 2
177    SetOutPath "$INSTDIR\VcXsrv\fonts\"
178    File "x2goclient\VcXsrv\fonts\fonts.conf"
179    File /r "x2goclient\VcXsrv\fonts\misc"
180  SectionEnd
181
182  ;As of VcXsrv-xp 1.14.3.2
183  ;75dpi is 1,897 files at 10.7 MB (15.6 MB on disk)
184  Section "75dpi" fonts-75dpi
185    SectionIn 2
186    SetOutPath "$INSTDIR\VcXsrv\fonts\"
187    File "x2goclient\VcXsrv\fonts\fonts.conf"
188    File /r "x2goclient\VcXsrv\fonts\75dpi"
189  SectionEnd
190
191  ;As of VcXsrv-xp 1.14.3.2
192  ;100dpi is 1,897 files at 12.3 MB (16.8 MB on disk)
193  Section "100dpi" fonts-100dpi
194    SectionIn 2
195    SetOutPath "$INSTDIR\VcXsrv\fonts\"
196    File "x2goclient\VcXsrv\fonts\fonts.conf"
197    File /r "x2goclient\VcXsrv\fonts\100dpi"
198  SectionEnd
199
200  ;As of VcXsrv-xp 1.14.3.2
201  ;everything else is 466 files at 12.8MB (13.8 MB on disk)
202  Section "others" fonts-others
203    SectionIn 2
204    SetOutPath "$INSTDIR\VcXsrv\fonts\"
205    File "x2goclient\VcXsrv\fonts\fonts.conf"
206    File /r "x2goclient\VcXsrv\fonts\cyrillic"
207    File /r "x2goclient\VcXsrv\fonts\encodings"
208    File /r "x2goclient\VcXsrv\fonts\OTF"
209    File /r "x2goclient\VcXsrv\fonts\Speedo"
210    File /r "x2goclient\VcXsrv\fonts\terminus-font"
211    File /r "x2goclient\VcXsrv\fonts\TTF"
212    File /r "x2goclient\VcXsrv\fonts\Type1"
213  SectionEnd
214
215SectionGroupEnd
216
217SectionGroup "PuTTY Key Utilities" puttykeyutils
218
219  Section "Pageant" pageant
220    SectionIn 1 2
221    SetOutPath "$INSTDIR"
222    File "x2goclient\pageant.exe"
223    CreateShortCut "$INSTDIR\Pageant.lnk" "$INSTDIR\pageant.exe"
224    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Pageant.lnk" "$INSTDIR\pageant.exe"
225  SectionEnd
226
227  Section "PuTTYgen" puttygen
228    SectionIn 1 2
229    SetOutPath "$INSTDIR"
230    File "x2goclient\puttygen.exe"
231    CreateShortCut "$INSTDIR\PuTTYgen.lnk" "$INSTDIR\puttygen.exe"
232    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\PuTTYgen.lnk" "$INSTDIR\puttygen.exe"
233  SectionEnd
234
235SectionGroupEnd
236
237Section "Desktop Shortcut" desktopshortcut
238  SectionIn 1 2
239  # When you run SetOutPath,you set the "Start in" dir for the shortcut.
240  # This "Start in" dir must exist for the shortcut to work.
241  SetOutPath "$INSTDIR"
242  CreateShortCut "$DESKTOP\X2Go Client.lnk" "$INSTDIR\x2goclient.exe"
243SectionEnd
244
245Section "Debug Build" debugbuild
246    SectionIn 2
247    SetOutPath "$INSTDIR"
248    File "x2goclient\x2goclient.debug.exe"
249    CreateShortCut "$INSTDIR\X2Go Client (Debug).lnk" "$INSTDIR\x2goclient.debug.exe" "--debug"
250    CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\X2Go Client (Debug).lnk" "$INSTDIR\x2goclient.debug.exe" "--debug"
251SectionEnd
252
253Section -EstimatedSize
254  SectionIn RO
255  ${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
256  IntFmt $0 "0x%08X" $0
257  WriteRegDWORD HKLM ${UNINSTALL_REGKEY} "EstimatedSize" "$0"
258SectionEnd
259
260;-------------------------------------------
261;Descriptions
262
263
264LangString ADM_RIGHT ${LANG_ENGLISH} "You have to be Administrator on this computer to install X2Go Client"
265LangString ADM_RIGHT ${LANG_GERMAN} "Sie brauchen Administratorenrechte um X2Go Client zu installieren"
266LangString ADM_RIGHT ${LANG_RUSSIAN} "��� ����, ����� ���������� X2Go Client, ���������� ���� ��������������� ����� ����������"
267
268LangString DESC_base            ${LANG_ENGLISH} "The regular build of X2Go Client and all its required dependencies"
269LangString DESC_fonts           ${LANG_ENGLISH} "Fonts are required for certain legacy/proprietary apps to run properly."
270LangString DESC_puttykeyutils   ${LANG_ENGLISH} "Utilities from the PuTTY project for SSH public key authentication"
271LangString DESC_pageant         ${LANG_ENGLISH} "PuTTY SSH authentication agent. Use this to load private keys into RAM so that you are not repeatedly prompted for the key's password."
272LangString DESC_puttygen        ${LANG_ENGLISH} "PuTTY key generator && converter. Note that keys for Pageant must be in PuTTY format, but key files on disk must be in OpenSSH format."
273LangString DESC_desktopshortcut ${LANG_ENGLISH} "Desktop shortcut"
274LangString DESC_debugbuild      ${LANG_ENGLISH} "A build of X2Go Client with console debugging output. Install and use this if you are reporting a bug."
275
276!Insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
277  !insertmacro MUI_DESCRIPTION_TEXT ${base}            $(DESC_base)
278  !insertmacro MUI_DESCRIPTION_TEXT ${fonts}           $(DESC_fonts)
279  !insertmacro MUI_DESCRIPTION_TEXT ${fonts-misc}      $(DESC_fonts)
280  !insertmacro MUI_DESCRIPTION_TEXT ${fonts-75dpi}     $(DESC_fonts)
281  !insertmacro MUI_DESCRIPTION_TEXT ${fonts-100dpi}    $(DESC_fonts)
282  !insertmacro MUI_DESCRIPTION_TEXT ${fonts-others}    $(DESC_fonts)
283  !insertmacro MUI_DESCRIPTION_TEXT ${puttykeyutils}   $(DESC_puttykeyutils)
284  !insertmacro MUI_DESCRIPTION_TEXT ${pageant}         $(DESC_pageant)
285  !insertmacro MUI_DESCRIPTION_TEXT ${puttygen}        $(DESC_puttygen)
286  !insertmacro MUI_DESCRIPTION_TEXT ${desktopshortcut} $(DESC_desktopshortcut)
287  !insertmacro MUI_DESCRIPTION_TEXT ${debugbuild}      $(DESC_debugbuild)
288!Insertmacro MUI_FUNCTION_DESCRIPTION_END
289
290;--------------------------------
291;Installer Functions
292
293Function .onInit
294
295  !insertmacro MUI_LANGDLL_DISPLAY
296FunctionEnd
297
298;--------------------------------
299;Uninstaller Section
300
301Section "Uninstall"
302
303  SetShellVarContext all
304
305  !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
306  Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk"
307  Delete "$SMPROGRAMS\$MUI_TEMP\X2Go Client.lnk"
308  Delete "$SMPROGRAMS\$MUI_TEMP\X2Go Client (Debug).lnk"
309  Delete "$SMPROGRAMS\$MUI_TEMP\Pageant.lnk"
310  Delete "$SMPROGRAMS\$MUI_TEMP\PuTTYgen.lnk"
311  Delete "$DESKTOP\X2Go Client.lnk"
312  StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP"
313  startMenuDeleteLoop:
314    ClearErrors
315    RMDir $MUI_TEMP
316    GetFullPathName $MUI_TEMP "$MUI_TEMP\.."
317    IfErrors startMenuDeleteLoopDone
318    StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
319  startMenuDeleteLoopDone:
320
321  RMDir /r "$INSTDIR"
322
323  DeleteRegKey HKLM "Software\x2goclient"
324  DeleteRegKey HKLM "${UNINSTALL_REGKEY}"
325
326SectionEnd
327
328;--------------------------------
329;Uninstaller Functions
330
331Function un.onInit
332
333  !insertmacro MUI_UNGETLANGUAGE
334
335FunctionEnd
336