]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/LyXInstaller-complete.nsi
update installer: update also lyx.bat file (needed for new launcher)
[lyx.git] / development / Win32 / packaging / AltInstaller / 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 !define INSTALLER_TYPE "NotUpdate"
31
32 # load the settings
33 !include "Settings.nsh"
34
35 #--------------------------------
36 # variables only used in this installer version
37
38 Var DelPythonFiles
39 Var GhostscriptPath
40 Var AiksaurusPath
41 Var AspellPath
42 Var Acrobat
43 Var PSVPath
44 Var EditorPath
45 Var ImageEditorPath
46 Var BibTeXEditorPath
47 Var LangEncoding
48 Var LangSysEncoding
49 Var MissedProg
50 Var LaTeXName
51 Var MiKTeXVersion
52 Var MiKTeXUser
53 Var MiKTeXPath
54 Var InstallGSview
55 Var InstallJabRef
56 Var SVGPath
57 # Variables used by all installer versions
58 Var AspellInstallYes
59 Var AspellBaseReg
60 Var AspellMessage
61 Var ImageMagickPath
62 Var JabRefInstalled
63 Var LatexPath
64 Var MiKTeXInstalled
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
99 # Set of various macros and functions
100 !include "LyXUtils.nsh"
101
102 # Functions to check and configure the LaTeX-system
103 !include "LaTeX.nsh"
104
105 # Function to check if needed programs are missing or not
106 !include "MissingPrograms.nsh"
107
108 # Functions for page to set installer language
109 # and LyX's menu language
110 !include "LanguageSettings.nsh"
111
112 # Function to configure LyX
113 !include "ConfigLyX.nsh"
114
115 # Function to configure needed third-party programs
116 !include "InstallThirdPartyProgs.nsh"
117
118 # Function for page to install Aspell dictionaries
119 !include "Aspell.nsh"
120
121 #--------------------------------
122 # Remember the installer language
123 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
124 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
125 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
126
127 !define MUI_ABORTWARNING
128 !define MUI_HEADERIMAGE
129 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
130 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
131 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
132 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
133
134 # Welcome page
135 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
136 !insertmacro MUI_PAGE_WELCOME
137
138 # Show the license.
139 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
140
141 # Specify the installation directory.
142 !insertmacro MUI_PAGE_DIRECTORY
143
144 # Specify LyX's menu language.
145 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
146
147 # Define which components to install.
148 !insertmacro MUI_PAGE_COMPONENTS
149
150 # Specify where to install program shortcuts.
151 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
152 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
153 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
154 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
155 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
156
157 # Check for needed programs
158 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
159
160 # Watch the components being installed.
161 !insertmacro MUI_PAGE_INSTFILES
162
163 # Finish page
164 !define MUI_FINISHPAGE_RUN 
165 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
166 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
167 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
168 !insertmacro MUI_PAGE_FINISH
169
170 # The uninstaller.
171 !insertmacro MUI_UNPAGE_COMPONENTS
172 !insertmacro MUI_UNPAGE_INSTFILES
173
174 #--------------------------------
175 # Languages
176
177 !insertmacro MUI_LANGUAGE "English" # first language is the default language
178 !insertmacro MUI_LANGUAGE "Czech"
179 !insertmacro MUI_LANGUAGE "Danish"
180 !insertmacro MUI_LANGUAGE "Dutch"
181 !insertmacro MUI_LANGUAGE "French"
182 !insertmacro MUI_LANGUAGE "German"
183 !insertmacro MUI_LANGUAGE "Galician"
184 !insertmacro MUI_LANGUAGE "Hungarian"
185 !insertmacro MUI_LANGUAGE "Italian"
186 !insertmacro MUI_LANGUAGE "Norwegian"
187 !insertmacro MUI_LANGUAGE "Polish"
188 !insertmacro MUI_LANGUAGE "Portuguese"
189 !insertmacro MUI_LANGUAGE "Slovak"
190 !insertmacro MUI_LANGUAGE "Spanish"
191 !insertmacro MUI_LANGUAGE "Swedish"
192 !insertmacro MUI_LANGUAGE "Turkish"
193
194 !include "lyx_languages\english.nsh"
195 !include "lyx_languages\czech.nsh"
196 !include "lyx_languages\danish.nsh"
197 !include "lyx_languages\dutch.nsh"
198 !include "lyx_languages\french.nsh"
199 !include "lyx_languages\german.nsh"
200 !include "lyx_languages\galician.nsh"
201 !include "lyx_languages\hungarian.nsh"
202 !include "lyx_languages\italian.nsh"
203 !include "lyx_languages\norwegian.nsh"
204 !include "lyx_languages\polish.nsh"
205 !include "lyx_languages\portuguese.nsh"
206 !include "lyx_languages\slovak.nsh"
207 !include "lyx_languages\spanish.nsh"
208 !include "lyx_languages\swedish.nsh"
209 !include "lyx_languages\turkish.nsh"
210
211 LicenseData "$(LyXLicenseData)"
212
213 #--------------------------------
214 # Reserve Files
215
216 # These files are inserted before other files in the data block
217 !insertmacro MUI_RESERVEFILE_LANGDLL
218 ReserveFile "io_ui_language.ini"
219 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
220
221 #--------------------------------
222 # Installer sections
223
224 Section "!${PRODUCT_NAME}" SecCore
225   SectionIn RO
226 SectionEnd
227 Section "$(SecAllUsersTitle)" SecAllUsers
228   SetShellVarContext all
229   StrCpy $ProductRootKey "HKLM"
230 SectionEnd
231 Section "$(SecFileAssocTitle)" SecFileAssoc
232   StrCpy $CreateFileAssociations "true"
233 SectionEnd
234 Section "$(SecDesktopTitle)" SecDesktop
235   StrCpy $CreateDesktopIcon "true"
236 SectionEnd
237 Section /o "$(SecInstGSviewTitle)" SecInstGSview
238  AddSize 4000
239  StrCpy $InstallGSview "true"
240 SectionEnd
241 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
242  AddSize 5000
243  StrCpy $InstallJabRef "true"
244 SectionEnd
245
246 # Section descriptions
247 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
248 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
249 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
250 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
251 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
252 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstGSview} "$(SecInstGSviewDescription)"
253 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
254 !insertmacro MUI_FUNCTION_DESCRIPTION_END
255
256 # the installation section
257 !include "InstallActions-complete-small.nsh"
258
259 #--------------------------------
260 # This hook function is called internally by NSIS on installer startup
261 Function .onInit
262
263   # set the installer language to the Windows locale language
264   System::Call "kernel32::GetUserDefaultLangID()i.a"
265
266   # check that the installer is not currently running
267   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
268   Pop $R0
269   ${if} $R0 != "0"
270    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
271    Abort
272   ${endif}
273   FindProcDLL::FindProc "${INSTALLER2_EXE}"
274   ${if} $R0 == "1"
275    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
276    Abort
277   ${endif}
278
279   # check if LyX is already installed
280   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
281   ${if} $0 != ""
282    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
283    Abort
284   ${endif}
285
286   # default settings
287   # these can be reset to "all" in section SecAllUsers
288   SetShellVarContext current
289   StrCpy $ProductRootKey "HKCU"
290
291   # this can be reset to "true" in section SecDesktop
292   StrCpy $CreateDesktopIcon "false"
293   StrCpy $CreateFileAssociations "false"
294
295   # if the user does *not* have administrator privileges, abort
296   StrCpy $Answer ""
297   StrCpy $UserName ""
298   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
299   ${if} $Answer == "yes"
300     !define ENABLE 0x00000001
301     SectionGetFlags ${SecAllUsers} $0
302     IntOp $0 $0 | ${ENABLE}
303     SectionSetFlags ${SecAllUsers} $0
304     !undef ENABLE
305   ${else}
306     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
307     Abort
308   ${endif}
309
310   # check the LaTeX-system
311   Call LaTeXActions # Function from LaTeX.nsh
312
313   # check which programs are installed or not
314   Call MissingPrograms # function from MissingPrograms.nsh
315
316   # don't let the installer sections appear when the programs are already installed
317   ${if} $PSVPath != ""
318    SectionSetText 4 "" # hides the corresponding uninstaller section, ${SecInstGSview}
319   ${endif}
320   ${if} $BibTeXEditorPath != ""
321    SectionSetText 5 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
322   ${endif}
323
324   ClearErrors
325 FunctionEnd
326
327 #--------------------------------
328
329 Function LaunchProduct
330   # call the lyx.exe and not the lyx.bat to show the console window. This is
331   # necessary because sometimes LyX's configure run that is started by the
332   # installer fails when MiKTeX was installed together with this installer.
333   # Showing the console gives the user feedback otherwise he would wonder why
334   # LyX won't start for minutes while it is downloading LaTeX-packages in the
335   # background 
336   Exec ${PRODUCT_EXE}  
337 FunctionEnd
338
339 #--------------------------------
340 # The Uninstaller
341
342 !include "Uninstall.nsh"
343
344 # eof