]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/LyXWinInstaller/LyXInstaller-update.nsi
installer updates
[lyx.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 JabRefVersionVar
47 Var LatexPath
48 Var MiKTeXInstalled
49 Var MiKTeXVersionVar
50 Var PythonPath
51 Var Answer
52 Var AppPre
53 Var AppSuff
54 Var AppPath
55 Var CreateDesktopIcon
56 Var CreateFileAssociations
57 Var DictCode
58 Var FileName
59 Var LangCode
60 Var LangCodeSys
61 Var LangName
62 Var LangNameSys
63 Var NewString
64 Var OldString
65 Var PathPrefix
66 Var Pointer
67 Var ProductRootKey
68 Var RunNumber
69 Var StartmenuFolder
70 Var String
71 Var Search
72 Var UserList
73 Var UserName
74
75 #--------------------------------
76 # load some NSIS libraries
77 !include "MUI.nsh"
78 !include "LogicLib.nsh"
79 !include "FileFunc.nsh"
80 !include "StrFunc.nsh"
81 !include "TextFunc.nsh"
82 !insertmacro LineFind
83 !include "WordFunc.nsh"
84 !insertmacro WordReplace
85
86 # Set of various macros and functions
87 !include "LyXUtils.nsh"
88
89 # list with modified files
90 !include "Updated.nsh"
91
92 # list with deleted files
93 !include "Deleted.nsh"
94
95 # Function for page to install Aspell dictionaries
96 !include "Aspell.nsh"
97
98 #--------------------------------
99
100 # Remember the installer language
101 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
102 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
103 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
104
105 !define MUI_ABORTWARNING
106 !define MUI_HEADERIMAGE
107 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
108 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
109 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
110 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
111
112 # Welcome page
113 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
114 !insertmacro MUI_PAGE_WELCOME
115
116 # Show the license.
117 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
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 "SHCTX"
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 # Watch the components being installed.
130 !insertmacro MUI_PAGE_INSTFILES
131
132 # Finish page
133 !define MUI_FINISHPAGE_RUN 
134 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
135 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
136 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
137 !insertmacro MUI_PAGE_FINISH
138
139 # The uninstaller.
140 !insertmacro MUI_UNPAGE_COMPONENTS
141 !insertmacro MUI_UNPAGE_INSTFILES
142
143 #--------------------------------
144 # Languages
145
146 !insertmacro MUI_LANGUAGE "English" # first language is the default language
147 !insertmacro MUI_LANGUAGE "Danish"
148 !insertmacro MUI_LANGUAGE "Dutch"
149 !insertmacro MUI_LANGUAGE "French"
150 !insertmacro MUI_LANGUAGE "German"
151 !insertmacro MUI_LANGUAGE "Galician"
152 !insertmacro MUI_LANGUAGE "Hungarian"
153 !insertmacro MUI_LANGUAGE "Italian"
154 !insertmacro MUI_LANGUAGE "Norwegian"
155 !insertmacro MUI_LANGUAGE "Polish"
156 !insertmacro MUI_LANGUAGE "Portuguese"
157 !insertmacro MUI_LANGUAGE "Slovak"
158 !insertmacro MUI_LANGUAGE "Spanish"
159 !insertmacro MUI_LANGUAGE "Swedish"
160 !insertmacro MUI_LANGUAGE "Turkish"
161
162 !include "lyx_languages\english.nsh"
163 !include "lyx_languages\danish.nsh"
164 !include "lyx_languages\dutch.nsh"
165 !include "lyx_languages\french.nsh"
166 !include "lyx_languages\german.nsh"
167 !include "lyx_languages\galician.nsh"
168 !include "lyx_languages\hungarian.nsh"
169 !include "lyx_languages\italian.nsh"
170 !include "lyx_languages\norwegian.nsh"
171 !include "lyx_languages\polish.nsh"
172 !include "lyx_languages\portuguese.nsh"
173 !include "lyx_languages\slovak.nsh"
174 !include "lyx_languages\spanish.nsh"
175 !include "lyx_languages\swedish.nsh"
176 !include "lyx_languages\turkish.nsh"
177
178 LicenseData "$(LyXLicenseData)"
179
180 #--------------------------------
181 # Reserve Files
182
183 # These files are inserted before other files in the data block
184 !insertmacro MUI_RESERVEFILE_LANGDLL
185 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
186
187 #--------------------------------
188 # Installer sections
189
190 Section "!${PRODUCT_NAME}" SecCore
191   SectionIn RO
192 SectionEnd
193 Section "$(SecFileAssocTitle)" SecFileAssoc
194   StrCpy $CreateFileAssociations "true"
195 SectionEnd
196 Section "$(SecDesktopTitle)" SecDesktop
197   StrCpy $CreateDesktopIcon "true"
198 SectionEnd
199
200 # Section descriptions
201 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
202 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
203 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
204 !insertmacro MUI_FUNCTION_DESCRIPTION_END
205
206 # the installation section
207 !include "InstallActions-update.nsh"
208
209 #--------------------------------
210 # This hook function is called internally by NSIS on installer startup
211 Function .onInit
212
213   # Check that LyX is not currently running
214   FindProcDLL::FindProc "lyx.exe"
215   ${if} $R0 == "1"
216    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
217    Abort
218   ${endif}
219   
220   # set the installer language to the Windows locale language
221   System::Call "kernel32::GetUserDefaultLangID()i.a"
222   
223   # Check that the installer is not currently running
224   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
225   Pop $R0
226   ${if} $R0 != "0"
227    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
228    Abort
229   ${endif}
230   FindProcDLL::FindProc "${INSTALLER2_EXE}"
231   ${if} $R0 == "1"
232    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
233    Abort
234   ${endif}
235   FindProcDLL::FindProc "${INSTALLER3_EXE}"
236   ${if} $R0 == "1"
237    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
238    Abort
239   ${endif}
240   
241   # check where LyX is installed
242   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
243   ${if} $0 != ""
244     SetShellVarContext all
245     StrCpy $ProductRootKey "HKLM"
246   ${endif}
247   ${if} $0 == ""
248    ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
249    ${if} $0 != ""
250     SetShellVarContext current
251     StrCpy $ProductRootKey "HKCU"
252    ${endif}
253    ${if} $0 == ""
254     MessageBox MB_OK|MB_ICONSTOP "$(UpdateNotAllowed)"
255     Abort
256    ${endif}
257   ${endif} # end if $0 == 0
258   ${if} $0 != "" # if it is found
259    StrCpy $INSTDIR $0
260    StrCpy $INSTDIR $INSTDIR -12 # delete the string "\bin\lyx.exe" or "\bin\lyx.bat"
261   ${endif}
262   
263   # abort if the user doesn't have administrator privileges but LyX was installed as admin
264   StrCpy $Answer ""
265   StrCpy $UserName ""
266   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
267   ${if} $Answer != "yes"
268   ${andif} $ProductRootKey == "HKLM"
269     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
270     Abort
271   ${endif}
272   
273   # This can be reset to "true" in section SecDesktop.
274   StrCpy $CreateDesktopIcon "false"
275   
276   ClearErrors
277 FunctionEnd
278
279 #--------------------------------
280
281 Function LaunchProduct
282   Exec ${PRODUCT_BAT}
283 FunctionEnd
284
285 #--------------------------------
286 # The Uninstaller
287
288  !include "Uninstall.nsh"
289   
290
291 # eof