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