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