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