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