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