1 # Lyx for Windows, NSIS v2 series installer script
3 # File LyXInstaller-update.nsi
4 # This file is part of LyX, the document processor.
6 # Licence details can be found in the file COPYING or copy at
7 # http://www.lyx.org/about/license.php3
10 # Full author contact details are available in file CREDITS or copy at
11 # http://www.lyx.org/about/credits.php
13 # This script requires NSIS 2.45 or newer
14 # http://nsis.sourceforge.net/
15 #--------------------------------
17 # Do a Cyclic Redundancy Check to make sure the installer
18 # was not corrupted by the download.
21 # Make the installer as small as possible.
24 #--------------------------------
25 # You should need to change only these macros...
27 !define INSTALLER_VERSION "Update"
28 !define INSTALLER2_VERSION "Small"
29 !define INSTALLER3_VERSION "Complete"
30 !define INSTALLER_TYPE "Update"
33 !include "Settings.nsh"
35 #--------------------------------
36 # variables only used in this installer version
41 # Variables used by all installer versions
42 !include "Variables.nsh"
44 #--------------------------------
45 # load some NSIS libraries
47 !include "LogicLib.nsh"
48 !include "FileFunc.nsh"
49 !include "StrFunc.nsh"
50 !include "TextFunc.nsh"
53 !include "WordFunc.nsh"
54 !insertmacro WordReplace
56 # Set of various macros and functions
57 !include "LyXUtils.nsh"
59 # list with modified files
60 !include "Updated.nsh"
62 # list with deleted files
63 !include "Deleted.nsh"
65 # Function for page to install Aspell dictionaries
68 #--------------------------------
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"
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}"
83 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
84 !insertmacro MUI_PAGE_WELCOME
87 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
89 # Define which components to install.
90 !insertmacro MUI_PAGE_COMPONENTS
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
99 # Watch the components being installed.
100 !insertmacro MUI_PAGE_INSTFILES
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
110 !insertmacro MUI_UNPAGE_COMPONENTS
111 !insertmacro MUI_UNPAGE_INSTFILES
113 #--------------------------------
114 # List of languages the installers are translated to
116 !include "TranslatedLanguages.nsh"
118 LicenseData "$(LyXLicenseData)"
120 #--------------------------------
123 # These files are inserted before other files in the data block
124 !insertmacro MUI_RESERVEFILE_LANGDLL
125 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
127 #--------------------------------
130 Section "!${PRODUCT_NAME}" SecCore
133 Section "$(SecFileAssocTitle)" SecFileAssoc
134 StrCpy $CreateFileAssociations "true"
136 Section "$(SecDesktopTitle)" SecDesktop
137 StrCpy $CreateDesktopIcon "true"
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
146 # the installation section
147 !include "InstallActions-update.nsh"
149 #--------------------------------
150 # This hook function is called internally by NSIS on installer startup
153 # Check that LyX is not currently running
154 FindProcDLL::FindProc "lyx.exe"
156 MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
160 # set the installer language to the Windows locale language
161 System::Call "kernel32::GetUserDefaultLangID()i.a"
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'
167 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
170 FindProcDLL::FindProc "${INSTALLER2_EXE}"
172 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
175 FindProcDLL::FindProc "${INSTALLER3_EXE}"
177 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
181 # printer settings, needed to install the Metafile2eps printer
182 ${if} ${AtLeastWinVista}
183 StrCpy $PrinterConf "printui.exe"
185 StrCpy $PrinterConf "rundll32.exe printui.dll,PrintUIEntry"
188 # check where LyX is installed
189 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
191 SetShellVarContext all
192 StrCpy $ProductRootKey "HKLM"
195 ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY_OLD}" "DisplayIcon"
197 SetShellVarContext current
198 StrCpy $ProductRootKey "HKCU"
201 MessageBox MB_OK|MB_ICONSTOP "$(UpdateNotAllowed)"
204 ${endif} # end if $0 == 0
205 ${if} $0 != "" # if it is found
207 StrCpy $INSTDIR $INSTDIR -12 # delete the string "\bin\lyx.exe" or "\bin\lyx.bat"
210 # abort if the user doesn't have administrator privileges but LyX was installed as admin
213 !insertmacro IsUserAdmin $Answer $UserName # macro from LyXUtils.nsh
214 ${if} $Answer != "yes"
215 ${andif} $ProductRootKey == "HKLM"
216 MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
220 # This can be reset to "true" in section SecDesktop.
221 StrCpy $CreateDesktopIcon "false"
226 #--------------------------------
228 Function LaunchProduct
232 #--------------------------------
235 !include "Uninstall.nsh"