]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/LyXInstaller-small.nsi
installer:
[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 DelPythonFiles
39 Var GhostscriptPath
40 Var AiksaurusPath
41 Var AspellPath
42 Var Acrobat
43 Var PSVPath
44 Var DelGSDir
45 Var EditorPath
46 Var ImageEditorPath
47 Var BibTeXEditorPath
48 Var LangEncoding
49 Var LangSysEncoding
50 Var MissedProg
51 Var LaTeXName
52 Var MiKTeXVersion
53 Var MiKTeXUser
54 Var State
55 Var SVGPath
56 # Variables used by all installer versions
57 Var AspellInstallYes
58 Var AspellBaseReg
59 Var AspellMessage
60 Var ImageMagickPath
61 Var JabRefInstalled
62 Var LatexPath
63 Var MiKTeXInstalled
64 Var PythonPath
65 Var Answer
66 Var AppPre
67 Var AppSuff
68 Var AppPath
69 Var CreateDesktopIcon
70 Var CreateFileAssociations
71 Var DictCode
72 Var FileName
73 Var LangCode
74 Var LangCodeSys
75 Var LangName
76 Var LangNameSys
77 Var NewString
78 Var OldString
79 Var PathPrefix
80 Var Pointer
81 Var ProductRootKey
82 Var RunNumber
83 Var StartmenuFolder
84 Var String
85 Var Search
86 Var UserList
87 Var UserName
88
89 #--------------------------------
90 # load some NSIS libraries
91 !include "MUI.nsh"
92 !include "LogicLib.nsh"
93 !include "FileFunc.nsh"
94 !include "StrFunc.nsh"
95 !include "TextFunc.nsh"
96 !insertmacro LineFind
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 # Function for page to manually select LaTeX's installation folder
108 !include "LaTeXFolder.nsh"
109
110 # Functions for page to set installer language
111 # and LyX's menu language
112 !include "LanguageSettings.nsh"
113
114 # Function to configure LyX
115 !include "ConfigLyX.nsh"
116
117 # Function to configure needed third-party programs
118 !include "InstallThirdPartyProgs.nsh"
119
120 # Function for page to install Aspell dictionaries
121 !include "Aspell.nsh"
122
123 #--------------------------------
124 # Remember the installer language
125 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
126 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
127 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
128
129 !define MUI_ABORTWARNING
130 !define MUI_HEADERIMAGE
131 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
132 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
133 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
134 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
135
136 # Welcome page
137 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
138 !insertmacro MUI_PAGE_WELCOME
139
140 # Show the license.
141 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
142
143 # Specify the installation directory.
144 !insertmacro MUI_PAGE_DIRECTORY
145
146 # Specify LyX's menu language.
147 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
148
149 # Define which components to install.
150 !insertmacro MUI_PAGE_COMPONENTS
151
152 # Specify where to install program shortcuts.
153 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
154 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
155 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
156 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
157 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
158
159 # Select latex.exe manually
160 Page custom LatexFolder LatexFolder_LeaveFunction
161
162 # Check for needed programs
163 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
164
165 # Watch the components being installed.
166 !insertmacro MUI_PAGE_INSTFILES
167
168 # Finish page
169 !define MUI_FINISHPAGE_RUN 
170 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
171 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
172 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
173 !insertmacro MUI_PAGE_FINISH
174
175 # The uninstaller.
176 !insertmacro MUI_UNPAGE_COMPONENTS
177 !insertmacro MUI_UNPAGE_INSTFILES
178
179 #--------------------------------
180 # Languages
181
182 !insertmacro MUI_LANGUAGE "English" # first language is the default language
183 !insertmacro MUI_LANGUAGE "Czech"
184 !insertmacro MUI_LANGUAGE "Danish"
185 !insertmacro MUI_LANGUAGE "Dutch"
186 !insertmacro MUI_LANGUAGE "French"
187 !insertmacro MUI_LANGUAGE "German"
188 !insertmacro MUI_LANGUAGE "Galician"
189 !insertmacro MUI_LANGUAGE "Hungarian"
190 !insertmacro MUI_LANGUAGE "Italian"
191 !insertmacro MUI_LANGUAGE "Norwegian"
192 !insertmacro MUI_LANGUAGE "Polish"
193 !insertmacro MUI_LANGUAGE "Portuguese"
194 !insertmacro MUI_LANGUAGE "Romanian"
195 !insertmacro MUI_LANGUAGE "Slovak"
196 !insertmacro MUI_LANGUAGE "Spanish"
197 !insertmacro MUI_LANGUAGE "Swedish"
198 !insertmacro MUI_LANGUAGE "Turkish"
199
200 !include "lyx_languages\english.nsh"
201 !include "lyx_languages\czech.nsh"
202 !include "lyx_languages\danish.nsh"
203 !include "lyx_languages\dutch.nsh"
204 !include "lyx_languages\french.nsh"
205 !include "lyx_languages\german.nsh"
206 !include "lyx_languages\galician.nsh"
207 !include "lyx_languages\hungarian.nsh"
208 !include "lyx_languages\italian.nsh"
209 !include "lyx_languages\norwegian.nsh"
210 !include "lyx_languages\polish.nsh"
211 !include "lyx_languages\portuguese.nsh"
212 !include "lyx_languages\romanian.nsh"
213 !include "lyx_languages\slovak.nsh"
214 !include "lyx_languages\spanish.nsh"
215 !include "lyx_languages\swedish.nsh"
216 !include "lyx_languages\turkish.nsh"
217
218 LicenseData "$(LyXLicenseData)"
219
220 #--------------------------------
221 # Reserve Files
222
223 # These files are inserted before other files in the data block
224 !insertmacro MUI_RESERVEFILE_LANGDLL
225 ReserveFile "io_ui_language.ini"
226 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
227
228 #--------------------------------
229 # Installer sections
230
231 Section "!${PRODUCT_NAME}" SecCore
232   SectionIn RO
233 SectionEnd
234 Section "$(SecAllUsersTitle)" SecAllUsers
235   SetShellVarContext all
236   StrCpy $ProductRootKey "HKLM"
237 SectionEnd
238 Section "$(SecFileAssocTitle)" SecFileAssoc
239   StrCpy $CreateFileAssociations "true"
240 SectionEnd
241 Section "$(SecDesktopTitle)" SecDesktop
242   StrCpy $CreateDesktopIcon "true"
243 SectionEnd
244
245 # Section descriptions
246 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
247 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
248 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
249 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
250 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
251 !insertmacro MUI_FUNCTION_DESCRIPTION_END
252
253 # the installation section
254 !include "InstallActions-complete-small.nsh"
255
256 #--------------------------------
257 # This hook function is called internally by NSIS on installer startup
258 Function .onInit
259
260   # set the installer language to the Windows locale language
261   System::Call "kernel32::GetUserDefaultLangID()i.a"
262
263   # check that the installer is not currently running
264   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
265   Pop $R0
266   ${if} $R0 != "0"
267    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
268    Abort
269   ${endif}
270   FindProcDLL::FindProc "${INSTALLER2_EXE}"
271   ${if} $R0 == "1"
272    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
273    Abort
274   ${endif}
275
276   # check if LyX is already installed
277   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
278   ${if} $0 != ""
279    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
280    Abort
281   ${endif}
282
283   # default settings
284   # these can be reset to "all" in section SecAllUsers
285   SetShellVarContext current
286   StrCpy $ProductRootKey "HKCU"
287
288   # this can be reset to "true" in section SecDesktop
289   StrCpy $CreateDesktopIcon "false"
290   StrCpy $CreateFileAssociations "false"
291
292   # if the user does *not* have administrator privileges, abort
293   StrCpy $Answer ""
294   StrCpy $UserName ""
295   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
296   ${if} $Answer == "yes"
297     !define ENABLE 0x00000001
298     SectionGetFlags ${SecAllUsers} $0
299     IntOp $0 $0 | ${ENABLE}
300     SectionSetFlags ${SecAllUsers} $0
301     !undef ENABLE
302   ${else}
303     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
304     Abort
305   ${endif}
306
307   # check the LaTeX-system
308   Call LaTeXActions # Function from LaTeX.nsh
309
310   # check which programs are installed or not
311   Call MissingPrograms # function from MissingPrograms.nsh
312
313   # used later in the function LatexFolder
314   StrCpy $State "0"
315
316   ClearErrors
317 FunctionEnd
318
319 #--------------------------------
320
321 Function LaunchProduct
322   Exec ${PRODUCT_BAT}
323 FunctionEnd
324
325 #--------------------------------
326 # The Uninstaller
327
328 !include "Uninstall.nsh"
329
330 # eof