]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/LyXInstaller-complete.nsi
Changed comment character from ';' to '#*
[lyx.git] / development / Win32 / packaging / installer / LyXWinInstaller / LyXInstaller-complete.nsi
1 # Lyx for Windows, NSIS v2 series installer script
2
3 # File LyXInstaller-complete.nsi
4 # This file is part of LyX, the document processor.
5 # http://www.lyx.org/
6 # Licence details can be found in the file COPYING or copy at
7 # http://www.lyx.org/about/license.php3
8
9 # Author Uwe Stöhr based on the work of Angus Leeming and Joost Verburg
10 # Full author contact details are available in file CREDITS or copy at
11 # http://www.lyx.org/about/credits.php
12
13 # This script requires NSIS 2.25 and newer
14 # http://nsis.sourceforge.net/
15 #--------------------------------
16
17 # Do a Cyclic Redundancy Check to make sure the installer
18 # was not corrupted by the download.
19 CRCCheck force
20
21 # Make the installer as small as possible.
22 #SetCompressor lzma
23
24 #--------------------------------
25 # You should need to change only these macros...
26
27 !define INSTALLER_VERSION "Complete"
28 !define INSTALLER2_VERSION "Small"
29 !define INSTALLER3_VERSION "Update"
30
31 # load the settings
32 !include "Settings.nsh"
33
34 #--------------------------------
35 # variables only used in this installer version
36
37 Var DelPythonFiles
38 Var GhostscriptPath
39 Var AiksaurusPath
40 Var AspellPath
41 Var Acrobat
42 Var PSVPath
43 Var EditorPath
44 Var ImageEditorPath
45 Var BibTeXEditorPath
46 Var LangEncoding
47 Var LangSysEncoding
48 Var MissedProg
49 Var LaTeXName
50 Var MiKTeXVersion
51 Var MiKTeXUser
52 Var MiKTeXPath
53 Var InstallGSview
54 Var InstallJabRef
55 # Variables used by all installer versions
56 Var AspellInstallYes
57 Var AspellBaseReg
58 Var AspellMessage
59 Var ImageMagickPath
60 Var JabRefInstalled
61 Var JabRefVersionVar
62 Var LatexPath
63 Var MiKTeXInstalled
64 Var MiKTeXVersionVar
65 Var PythonPath
66 Var Answer
67 Var AppPre
68 Var AppSuff
69 Var AppPath
70 Var CreateDesktopIcon
71 Var CreateFileAssociations
72 Var DictCode
73 Var FileName
74 Var LangCode
75 Var LangCodeSys
76 Var LangName
77 Var LangNameSys
78 Var NewString
79 Var OldString
80 Var PathPrefix
81 Var Pointer
82 Var ProductRootKey
83 Var RunNumber
84 Var StartmenuFolder
85 Var String
86 Var Search
87 Var UserList
88 Var UserName
89
90 #--------------------------------
91 # load some NSIS libraries
92 !include "MUI.nsh"
93 !include "LogicLib.nsh"
94 !include "FileFunc.nsh"
95 !include "StrFunc.nsh"
96 !include "TextFunc.nsh"
97 !insertmacro LineFind
98 !include "WordFunc.nsh"
99 !insertmacro WordReplace
100
101 # Set of various macros and functions
102 !include "LyXUtils.nsh"
103
104 # Functions to check and configure the LaTeX-system
105 !include "LaTeX.nsh"
106
107 # Function to check if needed programs are missing or not
108 !include "MissingPrograms.nsh"
109
110 # Functions for page to set installer language
111 # and LyX's menu language
112 !include "LanguageSettings.nsh"
113
114 # Function to configure LyX
115 !include "ConfigLyX.nsh"
116
117 # Function for page to install Aspell dictionaries
118 !include "Aspell.nsh"
119
120 #--------------------------------
121 # Remember the installer language
122 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
123 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
124 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
125
126 !define MUI_ABORTWARNING
127 !define MUI_HEADERIMAGE
128 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
129 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
130 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
131 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
132
133 # Welcome page
134 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
135 !insertmacro MUI_PAGE_WELCOME
136
137 # Show the license.
138 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
139
140 # Specify the installation directory.
141 !insertmacro MUI_PAGE_DIRECTORY
142
143 # Specify LyX's menu language.
144 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
145
146 # Define which components to install.
147 !insertmacro MUI_PAGE_COMPONENTS
148
149 # Specify where to install program shortcuts.
150 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
151 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
152 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
153 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
154 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
155
156 # Check for needed programs
157 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
158
159 # Watch the components being installed.
160 !insertmacro MUI_PAGE_INSTFILES
161
162 # Finish page
163 !define MUI_FINISHPAGE_RUN 
164 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
165 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
166 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
167 !insertmacro MUI_PAGE_FINISH
168
169 # The uninstaller.
170 !insertmacro MUI_UNPAGE_COMPONENTS
171 !insertmacro MUI_UNPAGE_INSTFILES
172
173 #--------------------------------
174 # Languages
175
176 !insertmacro MUI_LANGUAGE "English" # first language is the default language
177 !insertmacro MUI_LANGUAGE "Danish"
178 !insertmacro MUI_LANGUAGE "Dutch"
179 !insertmacro MUI_LANGUAGE "French"
180 !insertmacro MUI_LANGUAGE "German"
181 !insertmacro MUI_LANGUAGE "Galician"
182 !insertmacro MUI_LANGUAGE "Hungarian"
183 !insertmacro MUI_LANGUAGE "Italian"
184 !insertmacro MUI_LANGUAGE "Norwegian"
185 !insertmacro MUI_LANGUAGE "Polish"
186 !insertmacro MUI_LANGUAGE "Portuguese"
187 !insertmacro MUI_LANGUAGE "Slovak"
188 !insertmacro MUI_LANGUAGE "Spanish"
189 !insertmacro MUI_LANGUAGE "Swedish"
190 !insertmacro MUI_LANGUAGE "Turkish"
191
192 !include "lyx_languages\english.nsh"
193 !include "lyx_languages\danish.nsh"
194 !include "lyx_languages\dutch.nsh"
195 !include "lyx_languages\french.nsh"
196 !include "lyx_languages\german.nsh"
197 !include "lyx_languages\galician.nsh"
198 !include "lyx_languages\hungarian.nsh"
199 !include "lyx_languages\italian.nsh"
200 !include "lyx_languages\norwegian.nsh"
201 !include "lyx_languages\polish.nsh"
202 !include "lyx_languages\portuguese.nsh"
203 !include "lyx_languages\slovak.nsh"
204 !include "lyx_languages\spanish.nsh"
205 !include "lyx_languages\swedish.nsh"
206 !include "lyx_languages\turkish.nsh"
207
208 LicenseData "$(LyXLicenseData)"
209
210 #--------------------------------
211 # Reserve Files
212
213 # These files are inserted before other files in the data block
214 !insertmacro MUI_RESERVEFILE_LANGDLL
215 ReserveFile "io_ui_language.ini"
216 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
217
218 #--------------------------------
219 # Installer sections
220
221 Section "!${PRODUCT_NAME}" SecCore
222   SectionIn RO
223 SectionEnd
224 Section "$(SecAllUsersTitle)" SecAllUsers
225   SetShellVarContext all
226   StrCpy $ProductRootKey "HKLM"
227 SectionEnd
228 Section "$(SecFileAssocTitle)" SecFileAssoc
229   StrCpy $CreateFileAssociations "true"
230 SectionEnd
231 Section "$(SecDesktopTitle)" SecDesktop
232   StrCpy $CreateDesktopIcon "true"
233 SectionEnd
234 Section /o "$(SecInstGSviewTitle)" SecInstGSview
235  AddSize 4000
236  StrCpy $InstallGSview "true"
237 SectionEnd
238 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
239  AddSize 5000
240  StrCpy $InstallJabRef "true"
241 SectionEnd
242
243 # Section descriptions
244 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
245 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
246 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
247 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
248 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
249 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstGSview} "$(SecInstGSviewDescription)"
250 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
251 !insertmacro MUI_FUNCTION_DESCRIPTION_END
252
253 # the installation section
254 !include "InstallActions-complete.nsh"
255
256 #--------------------------------
257 # This hook function is called internally by NSIS on installer startup
258 Function .onInit
259
260   # set the installer language to the Windows locale language
261   System::Call "kernel32::GetUserDefaultLangID()i.a"
262
263   # check that the installer is not currently running
264   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
265   Pop $R0
266   ${if} $R0 != "0"
267    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
268    Abort
269   ${endif}
270   FindProcDLL::FindProc "${INSTALLER2_EXE}"
271   ${if} $R0 == "1"
272    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
273    Abort
274   ${endif}
275
276   # check if LyX is already installed
277   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
278   ${if} $0 != ""
279    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
280    Abort
281   ${endif}
282
283   # default settings
284   # these can be reset to "all" in section SecAllUsers
285   SetShellVarContext current
286   StrCpy $ProductRootKey "HKCU"
287
288   # this can be reset to "true" in section SecDesktop
289   StrCpy $CreateDesktopIcon "false"
290   StrCpy $CreateFileAssociations "false"
291
292   # if the user does *not* have administrator privileges, abort
293   StrCpy $Answer ""
294   StrCpy $UserName ""
295   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
296   ${if} $Answer == "yes"
297     !define ENABLE 0x00000001
298     SectionGetFlags ${SecAllUsers} $0
299     IntOp $0 $0 | ${ENABLE}
300     SectionSetFlags ${SecAllUsers} $0
301     !undef ENABLE
302   ${else}
303     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
304     Abort
305   ${endif}
306
307   # check the LaTeX-system
308   Call LaTeXActions # Function from LaTeX.nsh
309
310   # check which programs are installed or not
311   Call MissingPrograms # function from MissingPrograms.nsh
312
313   # don't let the installer sections appear when the programs are already installed
314   ${if} $PSVPath != ""
315    SectionSetText 4 "" # hides the corresponding uninstaller section, ${SecInstGSview}
316   ${endif}
317   ${if} $BibTeXEditorPath != ""
318    SectionSetText 5 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
319   ${endif}
320
321   ClearErrors
322 FunctionEnd
323
324 #--------------------------------
325
326 Function LaunchProduct
327   Exec ${PRODUCT_BAT}
328 FunctionEnd
329
330 #--------------------------------
331 # The Uninstaller
332
333 !include "Uninstall.nsh"
334
335 # eof