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