]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/LyXInstaller-small.nsi
installer: sync with branch
[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 Var AiksaurusPath
40 Var AspellPath
41 Var Acrobat
42 Var BibTeXEditorPath
43 Var DelGSDir
44 Var DelPythonFiles
45 Var DelWMFDir
46 Var EditorPath
47 Var GhostscriptPath
48 Var ImageEditorPath
49 Var LangEncoding
50 Var LangSysEncoding
51 Var LaTeXName
52 Var MiKTeXVersion
53 Var MiKTeXUser
54 Var MissedProg
55 Var PSVPath
56 Var State
57 Var SVGPath
58 Var WMFPath
59
60 # Variables used by all installer versions
61 !include "Variables.nsh"
62
63 #--------------------------------
64 # load some NSIS libraries
65 !include "MUI.nsh"
66 !include "LogicLib.nsh"
67 !include "FileFunc.nsh"
68 !include "StrFunc.nsh"
69 !include "TextFunc.nsh"
70 !include "WinVer.nsh"
71
72 # Set of various macros and functions
73 !include "LyXUtils.nsh"
74
75 # Functions to check and configure the LaTeX-system
76 !include "LaTeX.nsh"
77
78 # Function to check if needed programs are missing or not
79 !include "MissingPrograms.nsh"
80
81 # Function for page to manually select LaTeX's installation folder
82 !include "LaTeXFolder.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 # Function 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 # Select latex.exe manually
134 Page custom LatexFolder LatexFolder_LeaveFunction
135
136 # Check for needed programs
137 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
138
139 # Watch the components being installed.
140 !insertmacro MUI_PAGE_INSTFILES
141
142 # Finish page
143 !define MUI_FINISHPAGE_RUN 
144 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
145 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
146 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
147 !insertmacro MUI_PAGE_FINISH
148
149 # The uninstaller.
150 !insertmacro MUI_UNPAGE_COMPONENTS
151 !insertmacro MUI_UNPAGE_INSTFILES
152
153 #--------------------------------
154 # List of languages the installers are translated to
155
156 !include "TranslatedLanguages.nsh"
157
158 LicenseData "$(LyXLicenseData)"
159
160 #--------------------------------
161 # Reserve Files
162
163 # These files are inserted before other files in the data block
164 !insertmacro MUI_RESERVEFILE_LANGDLL
165 ReserveFile "io_ui_language.ini"
166 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
167
168 #--------------------------------
169 # Installer sections
170
171 Section "!${PRODUCT_NAME}" SecCore
172   SectionIn RO
173 SectionEnd
174 Section "$(SecAllUsersTitle)" SecAllUsers
175   SetShellVarContext all
176   StrCpy $ProductRootKey "HKLM"
177 SectionEnd
178 Section "$(SecFileAssocTitle)" SecFileAssoc
179   StrCpy $CreateFileAssociations "true"
180 SectionEnd
181 Section "$(SecDesktopTitle)" SecDesktop
182   StrCpy $CreateDesktopIcon "true"
183 SectionEnd
184
185 # Section descriptions
186 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
187 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
188 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
189 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
190 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
191 !insertmacro MUI_FUNCTION_DESCRIPTION_END
192
193 # the installation section
194 !include "InstallActions-complete-small.nsh"
195
196 #--------------------------------
197 # This hook function is called internally by NSIS on installer startup
198 Function .onInit
199
200   # set the installer language to the Windows locale language
201   System::Call "kernel32::GetUserDefaultLangID()i.a"
202
203   # check that the installer is not currently running
204   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
205   Pop $R0
206   ${if} $R0 != "0"
207    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
208    Abort
209   ${endif}
210   FindProcDLL::FindProc "${INSTALLER2_EXE}"
211   ${if} $R0 == "1"
212    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
213    Abort
214   ${endif}
215
216   # check if LyX is already installed
217   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
218   ${if} $0 != ""
219    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
220    Abort
221   ${endif}
222   
223   # printer settings, needed to install the Metafile2eps printer
224   !insertmacro PrinterInit # macro from InstallThirdPartyProgs.nsh
225
226   # default settings
227   # these can be reset to "all" in section SecAllUsers
228   SetShellVarContext current
229   StrCpy $ProductRootKey "HKCU"
230
231   # this can be reset to "true" in section SecDesktop
232   StrCpy $CreateDesktopIcon "false"
233   StrCpy $CreateFileAssociations "false"
234
235   # if the user does *not* have administrator privileges, abort
236   StrCpy $Answer ""
237   StrCpy $UserName ""
238   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
239   ${if} $Answer == "yes"
240     !define ENABLE 0x00000001
241     SectionGetFlags ${SecAllUsers} $0
242     IntOp $0 $0 | ${ENABLE}
243     SectionSetFlags ${SecAllUsers} $0
244     !undef ENABLE
245   ${else}
246     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
247     Abort
248   ${endif}
249
250   # check the LaTeX-system
251   Call LaTeXActions # Function from LaTeX.nsh
252
253   # check which programs are installed or not
254   Call MissingPrograms # function from MissingPrograms.nsh
255
256   # used later in the function LatexFolder
257   StrCpy $State "0"
258
259   ClearErrors
260 FunctionEnd
261
262 #--------------------------------
263
264 Function LaunchProduct
265   Exec ${PRODUCT_BAT}
266 FunctionEnd
267
268 #--------------------------------
269 # The Uninstaller
270
271 !include "Uninstall.nsh"
272
273 # eof