]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/LyXWinInstaller/LyXInstaller-complete.nsi
installer:
[features.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 !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 for page to install Aspell dictionaries
113 !include "Aspell.nsh"
114
115 #--------------------------------
116 # Remember the installer language
117 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
118 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
119 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
120
121 !define MUI_ABORTWARNING
122 !define MUI_HEADERIMAGE
123 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
124 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
125 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
126 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
127
128 # Welcome page
129 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
130 !insertmacro MUI_PAGE_WELCOME
131
132 # Show the license.
133 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
134
135 # Specify the installation directory.
136 !insertmacro MUI_PAGE_DIRECTORY
137
138 # Specify LyX's menu language.
139 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
140
141 # Define which components to install.
142 !insertmacro MUI_PAGE_COMPONENTS
143
144 # Specify where to install program shortcuts.
145 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
146 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
147 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
148 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
149 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
150
151 # Check for needed programs
152 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
153
154 # Watch the components being installed.
155 !insertmacro MUI_PAGE_INSTFILES
156
157 # Finish page
158 !define MUI_FINISHPAGE_RUN 
159 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
160 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
161 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
162 !insertmacro MUI_PAGE_FINISH
163
164 # The uninstaller.
165 !insertmacro MUI_UNPAGE_COMPONENTS
166 !insertmacro MUI_UNPAGE_INSTFILES
167
168 #--------------------------------
169 # Languages
170
171 !insertmacro MUI_LANGUAGE "English" # first language is the default language
172 !insertmacro MUI_LANGUAGE "Danish"
173 !insertmacro MUI_LANGUAGE "Dutch"
174 !insertmacro MUI_LANGUAGE "French"
175 !insertmacro MUI_LANGUAGE "German"
176 !insertmacro MUI_LANGUAGE "Galician"
177 !insertmacro MUI_LANGUAGE "Hungarian"
178 !insertmacro MUI_LANGUAGE "Italian"
179 !insertmacro MUI_LANGUAGE "Norwegian"
180 !insertmacro MUI_LANGUAGE "Polish"
181 !insertmacro MUI_LANGUAGE "Portuguese"
182 !insertmacro MUI_LANGUAGE "Slovak"
183 !insertmacro MUI_LANGUAGE "Spanish"
184 !insertmacro MUI_LANGUAGE "Swedish"
185 !insertmacro MUI_LANGUAGE "Turkish"
186
187 !include "lyx_languages\english.nsh"
188 !include "lyx_languages\danish.nsh"
189 !include "lyx_languages\dutch.nsh"
190 !include "lyx_languages\french.nsh"
191 !include "lyx_languages\german.nsh"
192 !include "lyx_languages\galician.nsh"
193 !include "lyx_languages\hungarian.nsh"
194 !include "lyx_languages\italian.nsh"
195 !include "lyx_languages\norwegian.nsh"
196 !include "lyx_languages\polish.nsh"
197 !include "lyx_languages\portuguese.nsh"
198 !include "lyx_languages\slovak.nsh"
199 !include "lyx_languages\spanish.nsh"
200 !include "lyx_languages\swedish.nsh"
201 !include "lyx_languages\turkish.nsh"
202
203 LicenseData "$(LyXLicenseData)"
204
205 #--------------------------------
206 # Reserve Files
207
208 # These files are inserted before other files in the data block
209 !insertmacro MUI_RESERVEFILE_LANGDLL
210 ReserveFile "io_ui_language.ini"
211 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
212
213 #--------------------------------
214 # Installer sections
215
216 Section "!${PRODUCT_NAME}" SecCore
217   SectionIn RO
218 SectionEnd
219 Section "$(SecAllUsersTitle)" SecAllUsers
220   SetShellVarContext all
221   StrCpy $ProductRootKey "HKLM"
222 SectionEnd
223 Section "$(SecFileAssocTitle)" SecFileAssoc
224   StrCpy $CreateFileAssociations "true"
225 SectionEnd
226 Section "$(SecDesktopTitle)" SecDesktop
227   StrCpy $CreateDesktopIcon "true"
228 SectionEnd
229 Section /o "$(SecInstGSviewTitle)" SecInstGSview
230  AddSize 4000
231  StrCpy $InstallGSview "true"
232 SectionEnd
233 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
234  AddSize 5000
235  StrCpy $InstallJabRef "true"
236 SectionEnd
237
238 # Section descriptions
239 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
240 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
241 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
242 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
243 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
244 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstGSview} "$(SecInstGSviewDescription)"
245 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
246 !insertmacro MUI_FUNCTION_DESCRIPTION_END
247
248 # the installation section
249 !include "InstallActions-complete.nsh"
250
251 #--------------------------------
252 # This hook function is called internally by NSIS on installer startup
253 Function .onInit
254
255   # set the installer language to the Windows locale language
256   System::Call "kernel32::GetUserDefaultLangID()i.a"
257
258   # check that the installer is not currently running
259   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
260   Pop $R0
261   ${if} $R0 != "0"
262    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
263    Abort
264   ${endif}
265   FindProcDLL::FindProc "${INSTALLER2_EXE}"
266   ${if} $R0 == "1"
267    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
268    Abort
269   ${endif}
270
271   # check if LyX is already installed
272   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
273   ${if} $0 != ""
274    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
275    Abort
276   ${endif}
277
278   # default settings
279   # these can be reset to "all" in section SecAllUsers
280   SetShellVarContext current
281   StrCpy $ProductRootKey "HKCU"
282
283   # this can be reset to "true" in section SecDesktop
284   StrCpy $CreateDesktopIcon "false"
285   StrCpy $CreateFileAssociations "false"
286
287   # if the user does *not* have administrator privileges, abort
288   StrCpy $Answer ""
289   StrCpy $UserName ""
290   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
291   ${if} $Answer == "yes"
292     !define ENABLE 0x00000001
293     SectionGetFlags ${SecAllUsers} $0
294     IntOp $0 $0 | ${ENABLE}
295     SectionSetFlags ${SecAllUsers} $0
296     !undef ENABLE
297   ${else}
298     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
299     Abort
300   ${endif}
301
302   # check the LaTeX-system
303   Call LaTeXActions # Function from LaTeX.nsh
304
305   # check which programs are installed or not
306   Call MissingPrograms # function from MissingPrograms.nsh
307
308   # don't let the installer sections appear when the programs are already installed
309   ${if} $PSVPath != ""
310    SectionSetText 4 "" # hides the corresponding uninstaller section, ${SecInstGSview}
311   ${endif}
312   ${if} $BibTeXEditorPath != ""
313    SectionSetText 5 "" # hides the corresponding uninstaller section, ${SecInstJabRef}
314   ${endif}
315
316   ClearErrors
317 FunctionEnd
318
319 #--------------------------------
320
321 Function LaunchProduct
322   Exec ${PRODUCT_BAT}
323 FunctionEnd
324
325 #--------------------------------
326 # The Uninstaller
327
328 !include "Uninstall.nsh"
329
330 # eof