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