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