]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/LyXInstaller-small.nsi
installer: - support for Hebrew and Japanese
[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 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 "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 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 State
54 Var SVGPath
55 # Variables used by all installer versions
56 Var AspellInstallYes
57 Var AspellBaseReg
58 Var AspellMessage
59 Var ImageMagickPath
60 Var JabRefInstalled
61 Var LatexPath
62 Var MiKTeXInstalled
63 Var PythonPath
64 Var Answer
65 Var AppPre
66 Var AppSuff
67 Var AppPath
68 Var CreateDesktopIcon
69 Var CreateFileAssociations
70 Var DictCode
71 Var FileName
72 Var LangCode
73 Var LangCodeSys
74 Var LangName
75 Var LangNameSys
76 Var NewString
77 Var OldString
78 Var PathPrefix
79 Var Pointer
80 Var ProductRootKey
81 Var RunNumber
82 Var StartmenuFolder
83 Var String
84 Var Search
85 Var UserList
86 Var UserName
87
88 #--------------------------------
89 # load some NSIS libraries
90 !include "MUI.nsh"
91 !include "LogicLib.nsh"
92 !include "FileFunc.nsh"
93 !include "StrFunc.nsh"
94 !include "TextFunc.nsh"
95 !insertmacro LineFind
96
97 # Set of various macros and functions
98 !include "LyXUtils.nsh"
99
100 # Functions to check and configure the LaTeX-system
101 !include "LaTeX.nsh"
102
103 # Function to check if needed programs are missing or not
104 !include "MissingPrograms.nsh"
105
106 # Function for page to manually select LaTeX's installation folder
107 !include "LaTeXFolder.nsh"
108
109 # Functions for page to set installer language
110 # and LyX's menu language
111 !include "LanguageSettings.nsh"
112
113 # Function to configure LyX
114 !include "ConfigLyX.nsh"
115
116 # Function to configure needed third-party programs
117 !include "InstallThirdPartyProgs.nsh"
118
119 # Function for page to install Aspell dictionaries
120 !include "Aspell.nsh"
121
122 #--------------------------------
123 # Remember the installer language
124 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
125 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
126 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
127
128 !define MUI_ABORTWARNING
129 !define MUI_HEADERIMAGE
130 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
131 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
132 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
133 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
134
135 # Welcome page
136 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
137 !insertmacro MUI_PAGE_WELCOME
138
139 # Show the license.
140 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
141
142 # Specify the installation directory.
143 !insertmacro MUI_PAGE_DIRECTORY
144
145 # Specify LyX's menu language.
146 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
147
148 # Define which components to install.
149 !insertmacro MUI_PAGE_COMPONENTS
150
151 # Specify where to install program shortcuts.
152 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
153 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
154 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
155 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
156 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
157
158 # Select latex.exe manually
159 Page custom LatexFolder LatexFolder_LeaveFunction
160
161 # Check for needed programs
162 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
163
164 # Watch the components being installed.
165 !insertmacro MUI_PAGE_INSTFILES
166
167 # Finish page
168 !define MUI_FINISHPAGE_RUN 
169 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
170 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
171 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
172 !insertmacro MUI_PAGE_FINISH
173
174 # The uninstaller.
175 !insertmacro MUI_UNPAGE_COMPONENTS
176 !insertmacro MUI_UNPAGE_INSTFILES
177
178 #--------------------------------
179 # Languages
180
181 !insertmacro MUI_LANGUAGE "English" # first language is the default language
182 !insertmacro MUI_LANGUAGE "Czech"
183 !insertmacro MUI_LANGUAGE "Danish"
184 !insertmacro MUI_LANGUAGE "Dutch"
185 !insertmacro MUI_LANGUAGE "French"
186 !insertmacro MUI_LANGUAGE "German"
187 !insertmacro MUI_LANGUAGE "Galician"
188 !insertmacro MUI_LANGUAGE "Hungarian"
189 !insertmacro MUI_LANGUAGE "Italian"
190 !insertmacro MUI_LANGUAGE "Norwegian"
191 !insertmacro MUI_LANGUAGE "Polish"
192 !insertmacro MUI_LANGUAGE "Portuguese"
193 !insertmacro MUI_LANGUAGE "Slovak"
194 !insertmacro MUI_LANGUAGE "Spanish"
195 !insertmacro MUI_LANGUAGE "Swedish"
196 !insertmacro MUI_LANGUAGE "Turkish"
197
198 !include "lyx_languages\english.nsh"
199 !include "lyx_languages\czech.nsh"
200 !include "lyx_languages\danish.nsh"
201 !include "lyx_languages\dutch.nsh"
202 !include "lyx_languages\french.nsh"
203 !include "lyx_languages\german.nsh"
204 !include "lyx_languages\galician.nsh"
205 !include "lyx_languages\hungarian.nsh"
206 !include "lyx_languages\italian.nsh"
207 !include "lyx_languages\norwegian.nsh"
208 !include "lyx_languages\polish.nsh"
209 !include "lyx_languages\portuguese.nsh"
210 !include "lyx_languages\slovak.nsh"
211 !include "lyx_languages\spanish.nsh"
212 !include "lyx_languages\swedish.nsh"
213 !include "lyx_languages\turkish.nsh"
214
215 LicenseData "$(LyXLicenseData)"
216
217 #--------------------------------
218 # Reserve Files
219
220 # These files are inserted before other files in the data block
221 !insertmacro MUI_RESERVEFILE_LANGDLL
222 ReserveFile "io_ui_language.ini"
223 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
224
225 #--------------------------------
226 # Installer sections
227
228 Section "!${PRODUCT_NAME}" SecCore
229   SectionIn RO
230 SectionEnd
231 Section "$(SecAllUsersTitle)" SecAllUsers
232   SetShellVarContext all
233   StrCpy $ProductRootKey "HKLM"
234 SectionEnd
235 Section "$(SecFileAssocTitle)" SecFileAssoc
236   StrCpy $CreateFileAssociations "true"
237 SectionEnd
238 Section "$(SecDesktopTitle)" SecDesktop
239   StrCpy $CreateDesktopIcon "true"
240 SectionEnd
241
242 # Section descriptions
243 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
244 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
245 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
246 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
247 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
248 !insertmacro MUI_FUNCTION_DESCRIPTION_END
249
250 # the installation section
251 !include "InstallActions-complete-small.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   # used later in the function LatexFolder
311   StrCpy $State "0"
312
313   ClearErrors
314 FunctionEnd
315
316 #--------------------------------
317
318 Function LaunchProduct
319   Exec ${PRODUCT_BAT}
320 FunctionEnd
321
322 #--------------------------------
323 # The Uninstaller
324
325 !include "Uninstall.nsh"
326
327 # eof