]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/LyXInstaller-update.nsi
installer: install a Perl interpreter to MiKTeX to fix bug #8181
[lyx.git] / development / Win32 / packaging / AltInstaller / 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.45 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 "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 Var AppPath
41 # Variables used by all installer versions
42 !include "Variables.nsh"
43
44 #--------------------------------
45 # load some NSIS libraries
46 !include "MUI.nsh"
47 !include "LogicLib.nsh"
48 !include "FileFunc.nsh"
49 !include "StrFunc.nsh"
50 !include "TextFunc.nsh"
51 !include "WinVer.nsh"
52 !insertmacro LineFind
53 !include "WordFunc.nsh"
54 !insertmacro WordReplace
55
56 # Set of various macros and functions
57 !include "LyXUtils.nsh"
58
59 # list with modified files
60 !include "Updated.nsh"
61
62 # list with deleted files
63 !include "Deleted.nsh"
64
65 # Function for page to install Aspell dictionaries
66 !include "Aspell.nsh"
67
68 #--------------------------------
69
70 # Remember the installer language
71 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
72 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
73 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
74
75 !define MUI_ABORTWARNING
76 !define MUI_HEADERIMAGE
77 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
78 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
79 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
80 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
81
82 # Welcome page
83 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
84 !insertmacro MUI_PAGE_WELCOME
85
86 # Show the license.
87 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
88
89 # Define which components to install.
90 !insertmacro MUI_PAGE_COMPONENTS
91
92 # Specify where to install program shortcuts.
93 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
94 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
95 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
96 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
97 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
98
99 # Watch the components being installed.
100 !insertmacro MUI_PAGE_INSTFILES
101
102 # Finish page
103 !define MUI_FINISHPAGE_RUN 
104 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
105 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
106 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
107 !insertmacro MUI_PAGE_FINISH
108
109 # The uninstaller.
110 !insertmacro MUI_UNPAGE_COMPONENTS
111 !insertmacro MUI_UNPAGE_INSTFILES
112
113 #--------------------------------
114 # List of languages the installers are translated to
115
116 !include "TranslatedLanguages.nsh"
117
118 LicenseData "$(LyXLicenseData)"
119
120 #--------------------------------
121 # Reserve Files
122
123 # These files are inserted before other files in the data block
124 !insertmacro MUI_RESERVEFILE_LANGDLL
125 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
126
127 #--------------------------------
128 # Installer sections
129
130 Section "!${PRODUCT_NAME}" SecCore
131   SectionIn RO
132 SectionEnd
133 Section "$(SecFileAssocTitle)" SecFileAssoc
134   StrCpy $CreateFileAssociations "true"
135 SectionEnd
136 Section "$(SecDesktopTitle)" SecDesktop
137   StrCpy $CreateDesktopIcon "true"
138 SectionEnd
139
140 # Section descriptions
141 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
142 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
143 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
144 !insertmacro MUI_FUNCTION_DESCRIPTION_END
145
146 # the installation section
147 !include "InstallActions-update.nsh"
148
149 #--------------------------------
150 # This hook function is called internally by NSIS on installer startup
151 Function .onInit
152
153   # Check that LyX is not currently running
154   FindProcDLL::FindProc "lyx.exe"
155   ${if} $R0 == "1"
156    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
157    Abort
158   ${endif}
159   
160   # set the installer language to the Windows locale language
161   System::Call "kernel32::GetUserDefaultLangID()i.a"
162   
163   # Check that the installer is not currently running
164   System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
165   Pop $R0
166   ${if} $R0 != "0"
167    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
168    Abort
169   ${endif}
170   FindProcDLL::FindProc "${INSTALLER2_EXE}"
171   ${if} $R0 == "1"
172    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
173    Abort
174   ${endif}
175   FindProcDLL::FindProc "${INSTALLER3_EXE}"
176   ${if} $R0 == "1"
177    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
178    Abort
179   ${endif}
180   
181   # printer settings, needed to install the Metafile2eps printer
182   ${if} ${AtLeastWinVista}
183     StrCpy $PrinterConf "printui.exe"
184   ${else}
185     StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
186   ${endif}
187   
188   # check where LyX is installed
189   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
190   ${if} $0 != ""
191     SetShellVarContext all
192     StrCpy $ProductRootKey "HKLM"
193   ${endif}
194   ${if} $0 == ""
195    ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
196    ${if} $0 != ""
197     SetShellVarContext current
198     StrCpy $ProductRootKey "HKCU"
199    ${endif}
200    ${if} $0 == ""
201     MessageBox MB_OK|MB_ICONSTOP "$(UpdateNotAllowed)"
202     Abort
203    ${endif}
204   ${endif} # end if $0 == 0
205   ${if} $0 != "" # if it is found
206    StrCpy $INSTDIR $0
207    StrCpy $INSTDIR $INSTDIR -12 # delete the string "\bin\lyx.exe" or "\bin\lyx.bat"
208   ${endif}
209   
210   # abort if the user doesn't have administrator privileges but LyX was installed as admin
211   StrCpy $Answer ""
212   StrCpy $UserName ""
213   !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
214   ${if} $Answer != "yes"
215   ${andif} $ProductRootKey == "HKLM"
216     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
217     Abort
218   ${endif}
219   
220   # This can be reset to "true" in section SecDesktop.
221   StrCpy $CreateDesktopIcon "false"
222   
223   ClearErrors
224 FunctionEnd
225
226 #--------------------------------
227
228 Function LaunchProduct
229   Exec ${PRODUCT_BAT}
230 FunctionEnd
231
232 #--------------------------------
233 # The Uninstaller
234
235  !include "Uninstall.nsh"
236   
237
238 # eof