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