]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/LyXWinInstaller/LyXInstaller-update.nsi
installer:
[features.git] / development / Win32 / packaging / installer / LyXWinInstaller / LyXInstaller-update.nsi
1 # Lyx for Windows, NSIS v2 series installer script
2
3 # File LyXInstaller-update.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
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 "Update"
28 !define INSTALLER2_VERSION "Small"
29 !define INSTALLER3_VERSION "Complete"
30 !define INSTALLER_TYPE "Update"
31
32 # load the settings
33 !include "Settings.nsh"
34
35 #--------------------------------
36 # variables only used in this installer version
37
38 Var INSTDIR_NEW
39 Var INSTDIR_OLD
40 # Variables used by all installer versions
41 Var AspellInstallYes
42 Var AspellBaseReg
43 Var AspellMessage
44 Var ImageMagickPath
45 Var JabRefInstalled
46 Var LatexPath
47 Var MiKTeXInstalled
48 Var PythonPath
49 Var Answer
50 Var AppPre
51 Var AppSuff
52 Var AppPath
53 Var CreateDesktopIcon
54 Var CreateFileAssociations
55 Var DictCode
56 Var FileName
57 Var LangCode
58 Var LangCodeSys
59 Var LangName
60 Var LangNameSys
61 Var NewString
62 Var OldString
63 Var PathPrefix
64 Var Pointer
65 Var ProductRootKey
66 Var RunNumber
67 Var StartmenuFolder
68 Var String
69 Var Search
70 Var UserList
71 Var UserName
72
73 #--------------------------------
74 # load some NSIS libraries
75 !include "MUI.nsh"
76 !include "LogicLib.nsh"
77 !include "FileFunc.nsh"
78 !include "StrFunc.nsh"
79 !include "TextFunc.nsh"
80 !insertmacro LineFind
81 !include "WordFunc.nsh"
82 !insertmacro WordReplace
83
84 # Set of various macros and functions
85 !include "LyXUtils.nsh"
86
87 # list with modified files
88 !include "Updated.nsh"
89
90 # list with deleted files
91 !include "Deleted.nsh"
92
93 # Function for page to install Aspell dictionaries
94 !include "Aspell.nsh"
95
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 # Define which components to install.
118 !insertmacro MUI_PAGE_COMPONENTS
119
120 # Specify where to install program shortcuts.
121 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
122 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
123 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
124 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
125 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
126
127 # Watch the components being installed.
128 !insertmacro MUI_PAGE_INSTFILES
129
130 # Finish page
131 !define MUI_FINISHPAGE_RUN 
132 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
133 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
134 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
135 !insertmacro MUI_PAGE_FINISH
136
137 # The uninstaller.
138 !insertmacro MUI_UNPAGE_COMPONENTS
139 !insertmacro MUI_UNPAGE_INSTFILES
140
141 #--------------------------------
142 # Languages
143
144 !insertmacro MUI_LANGUAGE "English" # first language is the default language
145 !insertmacro MUI_LANGUAGE "Danish"
146 !insertmacro MUI_LANGUAGE "Dutch"
147 !insertmacro MUI_LANGUAGE "French"
148 !insertmacro MUI_LANGUAGE "German"
149 !insertmacro MUI_LANGUAGE "Galician"
150 !insertmacro MUI_LANGUAGE "Hungarian"
151 !insertmacro MUI_LANGUAGE "Italian"
152 !insertmacro MUI_LANGUAGE "Norwegian"
153 !insertmacro MUI_LANGUAGE "Polish"
154 !insertmacro MUI_LANGUAGE "Portuguese"
155 !insertmacro MUI_LANGUAGE "Slovak"
156 !insertmacro MUI_LANGUAGE "Spanish"
157 !insertmacro MUI_LANGUAGE "Swedish"
158 !insertmacro MUI_LANGUAGE "Turkish"
159
160 !include "lyx_languages\english.nsh"
161 !include "lyx_languages\danish.nsh"
162 !include "lyx_languages\dutch.nsh"
163 !include "lyx_languages\french.nsh"
164 !include "lyx_languages\german.nsh"
165 !include "lyx_languages\galician.nsh"
166 !include "lyx_languages\hungarian.nsh"
167 !include "lyx_languages\italian.nsh"
168 !include "lyx_languages\norwegian.nsh"
169 !include "lyx_languages\polish.nsh"
170 !include "lyx_languages\portuguese.nsh"
171 !include "lyx_languages\slovak.nsh"
172 !include "lyx_languages\spanish.nsh"
173 !include "lyx_languages\swedish.nsh"
174 !include "lyx_languages\turkish.nsh"
175
176 LicenseData "$(LyXLicenseData)"
177
178 #--------------------------------
179 # Reserve Files
180
181 # These files are inserted before other files in the data block
182 !insertmacro MUI_RESERVEFILE_LANGDLL
183 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
184
185 #--------------------------------
186 # Installer sections
187
188 Section "!${PRODUCT_NAME}" SecCore
189   SectionIn RO
190 SectionEnd
191 Section "$(SecFileAssocTitle)" SecFileAssoc
192   StrCpy $CreateFileAssociations "true"
193 SectionEnd
194 Section "$(SecDesktopTitle)" SecDesktop
195   StrCpy $CreateDesktopIcon "true"
196 SectionEnd
197
198 # Section descriptions
199 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
200 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
201 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
202 !insertmacro MUI_FUNCTION_DESCRIPTION_END
203
204 # the installation section
205 !include "InstallActions-update.nsh"
206
207 #--------------------------------
208 # This hook function is called internally by NSIS on installer startup
209 Function .onInit
210
211   # Check that LyX is not currently running
212   FindProcDLL::FindProc "lyx.exe"
213   ${if} $R0 == "1"
214    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
215    Abort
216   ${endif}
217   
218   # set the installer language to the Windows locale language
219   System::Call "kernel32::GetUserDefaultLangID()i.a"
220   
221   # Check that the installer is not currently running
222   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
223   Pop $R0
224   ${if} $R0 != "0"
225    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
226    Abort
227   ${endif}
228   FindProcDLL::FindProc "${INSTALLER2_EXE}"
229   ${if} $R0 == "1"
230    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
231    Abort
232   ${endif}
233   FindProcDLL::FindProc "${INSTALLER3_EXE}"
234   ${if} $R0 == "1"
235    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
236    Abort
237   ${endif}
238   
239   # check where LyX is installed
240   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
241   ${if} $0 != ""
242     SetShellVarContext all
243     StrCpy $ProductRootKey "HKLM"
244   ${endif}
245   ${if} $0 == ""
246    ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
247    ${if} $0 != ""
248     SetShellVarContext current
249     StrCpy $ProductRootKey "HKCU"
250    ${endif}
251    ${if} $0 == ""
252     MessageBox MB_OK|MB_ICONSTOP "$(UpdateNotAllowed)"
253     Abort
254    ${endif}
255   ${endif} # end if $0 == 0
256   ${if} $0 != "" # if it is found
257    StrCpy $INSTDIR $0
258    StrCpy $INSTDIR $INSTDIR -12 # delete the string "\bin\lyx.exe" or "\bin\lyx.bat"
259   ${endif}
260   
261   # abort if the user doesn't have administrator privileges but LyX was installed as admin
262   StrCpy $Answer ""
263   StrCpy $UserName ""
264   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
265   ${if} $Answer != "yes"
266   ${andif} $ProductRootKey == "HKLM"
267     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
268     Abort
269   ${endif}
270   
271   # This can be reset to "true" in section SecDesktop.
272   StrCpy $CreateDesktopIcon "false"
273   
274   ClearErrors
275 FunctionEnd
276
277 #--------------------------------
278
279 Function LaunchProduct
280   Exec ${PRODUCT_BAT}
281 FunctionEnd
282
283 #--------------------------------
284 # The Uninstaller
285
286  !include "Uninstall.nsh"
287   
288
289 # eof