1 ; Lyx for Windows, NSIS v2 series installer script
3 ; File LyXWinInstaller.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
9 ; Author Uwe Stöhr based on the work of Angus Leeming and Joost Verburg
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.22 and 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 PRODUCT_DIR "D:\LyXPackage1.5"
28 !define PRODUCT_NAME "LyX"
29 !define PRODUCT_VERSION "1.5beta1-19-02-2007"
30 !define PRODUCT_VERSION_SHORT "150svn"
31 !define PRODUCT_SUBFOLDER "lyx15"
32 !define PRODUCT_LICENSE_FILE "${PRODUCT_DIR}\License.txt"
33 !define PRODUCT_SOURCEDIR "${PRODUCT_DIR}\LyX"
34 !define PRODUCT_EXE "$INSTDIR\bin\lyx.exe"
35 !define PRODUCT_BAT "$INSTDIR\bin\lyx.bat"
36 !define PRODUCT_EXT ".lyx"
37 !define PRODUCT_MIME_TYPE "application/lyx"
38 !define PRODUCT_UNINSTALL_EXE "$INSTDIR\LyXWinUninstall.exe"
39 !define PRODUCT_HELP_LINK "http://www.lyx.org/internet/mailing.php"
40 !define PRODUCT_ABOUT_URL "http://www.lyx.org/about/"
41 !define PRODUCT_INFO_URL "http://www.lyx.org/"
43 BrandingText "LyXWinInstaller v3.09 - Complete"
44 !define INSTALLER_VERSION "Complete"
45 !define INSTALLER_EXE "LyXWin150beta1Complete-3-09.exe"
46 !define INSTALLER2_EXE "LyXWin150beta1Small-3-09.exe" ; to check later if this installer version is running at the same time
47 !define VERSION_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_vert${PRODUCT_VERSION_SHORT}.bmp"
49 ; Replaced by HKLM or HKCU depending on SetShellVarContext.
50 !define PRODUCT_ROOT_KEY "SHCTX"
52 !define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\lyx.exe"
53 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\LyX${PRODUCT_VERSION_SHORT}"
55 !define ClassFileDir "${PRODUCT_SOURCEDIR}\Resources\tex"
57 !define ImageMagickVersion "6.3.2"
58 !define ImageMagickDir "$INSTDIR\etc\ImageMagick" ; for some odd reason the ImageMagick folder may not be a subfolder of $INSTDIR\bin!
59 !define GhostscriptDir "$INSTDIR\etc\Ghostscript"
60 !define GhostscriptVersion "8.54"
61 !define AiksaurusDir "$APPDATA\Aiksaurus"
62 !define AiksaurusInstall "external\Aiksaurus"
63 !define AspellDir "$APPDATA\Aspell"
64 !define AspellDisplay "Aspell 0.60.4 Data"
65 !define AspellInstall "external\Aspell"
66 !define AspellUninstall "Uninstall-AspellData.exe"
67 !define AspellDictPath "${AspellDir}\Dictionaries"
68 !define AspellPersonalPath "${AspellDir}\Personal"
69 !define AspellLocationExact "http://developer.berlios.de/project/showfiles.php?group_id=5117&release_id=9651"
70 !define AspellLocation "http://developer.berlios.de/projects/lyxwininstall/"
71 !define GSviewInstall "external\gsv48w32.exe"
72 !define JabRefInstall "external\JabRef-2.2-Setup.exe"
73 !define JabRefVersion "JabRef 2.2"
74 !define DVIPostFileDir "${PRODUCT_SOURCEDIR}\external\dvipost"
75 ; the following variable is needed for a possible CD-version, see InstallActions.nsh, around line 213
76 ;!define LaTeXPackagesDir "${PRODUCT_SOURCEDIR}\latex"
77 !define MiKTeXRepo "ftp://ftp.tu-chemnitz.de/pub/tex/systems/win32/miktex/tm/packages/"
78 !define MiKTeXConfigFolder "MiKTeX\2.5\miktex\config"
79 !define MiKTeXDeliveredVersion "MiKTeX 2.5"
80 !define MiKTeXInstall "$INSTDIR\external\basic-miktex-2.5.2580.exe"
82 ;--------------------------------
83 ; Make some of the information above available to NSIS.
85 Name "${PRODUCT_NAME}"
86 OutFile "${INSTALLER_EXE}"
87 InstallDir "$PROGRAMFILES\${PRODUCT_NAME} ${PRODUCT_VERSION}"
89 ;--------------------------------
126 Var CreateFileAssociations
127 Var CreateDesktopIcon
139 ;--------------------------------
140 ; load some NSIS libraries
142 !include "LogicLib.nsh"
143 !include "FileFunc.nsh"
144 !include "StrFunc.nsh"
145 ;!include "TextFunc.nsh"
146 ;!insertmacro LineFind
148 ; Set of various macros and functions
149 !include "LyXUtils.nsh"
151 ; Function to check if needed programs are missing or not
152 !include "MissingPrograms.nsh"
154 ; Functions for page to set installer language
155 ; and LyX's menu language
156 !include "LanguageSettings.nsh"
158 ; Function for page to install Aspell dictionaries
159 !include "Aspell.nsh"
161 ; Use the Abiword macros to help set up associations with the file extension in the Registry.
163 ; http://abiword.pchasm.org/source/cvs/abiword-cvs/abi/src/pkg/win/setup/NSISv2/abi_util_fileassoc.nsh
164 !include "abi_util_fileassoc.nsh"
166 ;--------------------------------
168 ; Remember the installer language
169 !define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
170 !define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
171 !define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
173 !define MUI_ABORTWARNING
174 !define MUI_HEADERIMAGE
175 !define MUI_HEADERIMAGE_BITMAP "${PRODUCT_DIR}\icons\lyx_logo_hi.bmp"
176 !define MUI_ICON "${PRODUCT_DIR}\icons\lyx.ico"
177 !define MUI_UNICON "${PRODUCT_DIR}\icons\lyx.ico"
178 !define MUI_WELCOMEFINISHPAGE_BITMAP "${VERSION_BITMAP}"
181 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
182 !insertmacro MUI_PAGE_WELCOME
185 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
187 ; Specify the installation directory.
188 !insertmacro MUI_PAGE_DIRECTORY
190 ; Specify LyX's menu language.
191 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
193 ; Define which components to install.
194 !insertmacro MUI_PAGE_COMPONENTS
196 ; Specify where to install program shortcuts.
197 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "${PRODUCT_ROOT_KEY}"
198 !define MUI_STARTMENUPAGE_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
199 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
200 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "LyX ${PRODUCT_VERSION}"
201 !insertmacro MUI_PAGE_STARTMENU ${PRODUCT_NAME} $StartmenuFolder
203 ; Check for needed programs
204 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
206 ; Watch the components being installed.
207 !insertmacro MUI_PAGE_INSTFILES
210 !define MUI_FINISHPAGE_RUN
211 !define MUI_FINISHPAGE_TEXT "$(FinishPageMessage)"
212 !define MUI_FINISHPAGE_RUN_TEXT "$(FinishPageRun)"
213 !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchProduct"
214 !insertmacro MUI_PAGE_FINISH
217 !insertmacro MUI_UNPAGE_COMPONENTS
218 !insertmacro MUI_UNPAGE_INSTFILES
220 ;--------------------------------
223 !insertmacro MUI_LANGUAGE "English" # first language is the default language
224 !insertmacro MUI_LANGUAGE "Danish"
225 !insertmacro MUI_LANGUAGE "Dutch"
226 !insertmacro MUI_LANGUAGE "French"
227 !insertmacro MUI_LANGUAGE "German"
228 !insertmacro MUI_LANGUAGE "Galician"
229 !insertmacro MUI_LANGUAGE "Hungarian"
230 !insertmacro MUI_LANGUAGE "Italian"
231 !insertmacro MUI_LANGUAGE "Norwegian"
232 !insertmacro MUI_LANGUAGE "Polish"
233 !insertmacro MUI_LANGUAGE "Portuguese"
234 !insertmacro MUI_LANGUAGE "Slovak"
235 !insertmacro MUI_LANGUAGE "Spanish"
236 !insertmacro MUI_LANGUAGE "Swedish"
237 !insertmacro MUI_LANGUAGE "Turkish"
239 !include "lyx_languages\english.nsh"
240 !include "lyx_languages\danish.nsh"
241 !include "lyx_languages\dutch.nsh"
242 !include "lyx_languages\french.nsh"
243 !include "lyx_languages\german.nsh"
244 !include "lyx_languages\galician.nsh"
245 !include "lyx_languages\hungarian.nsh"
246 !include "lyx_languages\italian.nsh"
247 !include "lyx_languages\norwegian.nsh"
248 !include "lyx_languages\polish.nsh"
249 !include "lyx_languages\portuguese.nsh"
250 !include "lyx_languages\slovak.nsh"
251 !include "lyx_languages\spanish.nsh"
252 !include "lyx_languages\swedish.nsh"
253 !include "lyx_languages\turkish.nsh"
255 LicenseData "$(LyXLicenseData)"
257 ;--------------------------------
260 ; These files are inserted before other files in the data block
261 !insertmacro MUI_RESERVEFILE_LANGDLL
262 ReserveFile "io_ui_language.ini"
263 !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
265 ;--------------------------------
268 Section "!${PRODUCT_NAME}" SecCore
271 Section "$(SecAllUsersTitle)" SecAllUsers
272 SetShellVarContext all
273 StrCpy $ProductRootKey "HKLM"
275 Section "$(SecFileAssocTitle)" SecFileAssoc
276 StrCpy $CreateFileAssociations "true"
278 Section "$(SecDesktopTitle)" SecDesktop
279 StrCpy $CreateDesktopIcon "true"
281 Section /o "$(SecInstGSviewTitle)" SecInstGSview
283 StrCpy $InstallGSview "true"
285 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
287 StrCpy $InstallJabRef "true"
290 ; Section descriptions
291 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
292 !insertmacro MUI_DESCRIPTION_TEXT ${SecCore} "$(SecCoreDescription)"
293 !insertmacro MUI_DESCRIPTION_TEXT ${SecAllUsers} "$(SecAllUsersDescription)"
294 !insertmacro MUI_DESCRIPTION_TEXT ${SecFileAssoc} "$(SecFileAssocDescription)"
295 !insertmacro MUI_DESCRIPTION_TEXT ${SecDesktop} "$(SecDesktopDescription)"
296 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstGSview} "$(SecInstGSviewDescription)"
297 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstJabRef} "$(SecInstJabRefDescription)"
298 !insertmacro MUI_FUNCTION_DESCRIPTION_END
300 !include "InstallActions-complete.nsh"
302 ;--------------------------------
303 ; This hook function is called internally by NSIS on installer startup
306 ; set the installer language to the Windows locale language
307 System::Call "kernel32::GetUserDefaultLangID()i.a"
309 ; Check that the installer is not currently running
310 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "${INSTALLER_EXE}.Instance") i .r1 ?e'
313 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
316 FindProcDLL::FindProc "${INSTALLER2_EXE}"
318 MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
322 ; Check if LyX is already installed
323 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
325 MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
330 ; These can be reset to "all" in section SecAllUsers.
331 SetShellVarContext current
332 StrCpy $ProductRootKey "HKCU"
334 ; This can be reset to "true" in section SecDesktop.
335 StrCpy $CreateDesktopIcon "false"
336 StrCpy $CreateFileAssociations "false"
338 ; If the user does *not* have administrator privileges, abort
341 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
342 ${if} $Answer == "yes"
343 !define ENABLE 0x00000001
344 SectionGetFlags ${SecAllUsers} $0
345 IntOp $0 $0 | ${ENABLE}
346 SectionSetFlags ${SecAllUsers} $0
349 MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
353 ; check which programs are installed or not
354 Call MissingPrograms ; function from MissingPrograms.nsh
356 ; don't let the installer sections appear when the programs are already installed
358 SectionSetText 4 "" ; hides the corresponding uninstaller section, ${SecInstGSview}
360 ${if} $BibTeXEditorPath != ""
361 SectionSetText 5 "" ; hides the corresponding uninstaller section, ${SecInstJabRef}
367 ;--------------------------------
369 Function LaunchProduct
373 ;--------------------------------
375 ;Function DeleteLines
376 ; StrCpy $0 SkipWrite
380 ;--------------------------------
385 ; Check that LyX is not currently running
386 FindProcDLL::FindProc "lyx.exe"
388 MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
392 ; Ascertain whether the user has sufficient privileges to uninstall.
393 SetShellVarContext current
395 ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
397 ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
399 MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
403 ; If the user does *not* have administrator privileges, abort
405 !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
406 ${if} $Answer == "yes"
407 SetShellVarContext all
409 MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
413 ; Macro to investigate name of LyX's preferences folders to be able remove them
414 !insertmacro UnAppPreSuff $AppPre $AppSuff ; macro from LyXUtils.nsh
416 ; test if Aspell was installed together with LyX
417 ReadRegStr $0 HKLM "Software\Aspell" "OnlyWithLyX" ; special entry to test if it was installed with LyX
419 SectionSetText 2 "Aspell" ; names the corersponding uninstaller section (has the index "2" as it is the third section in Uninstall.nsh)
420 StrCpy $AspellInstallYes "Aspell"
422 SectionSetText 2 "" ; hides the corresponding uninstaller section
425 ; test if MiKTeX was installed together with LyX
426 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
428 SectionSetText 3 "MiKTeX" ; names the corersponding uninstaller section
429 StrCpy $MiKTeXInstalled "MiKTeX"
431 SectionSetText 3 "" ; hides the corresponding uninstaller section
434 ; test if JabRef was installed together with LyX
435 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "OnlyWithLyX"
437 SectionSetText 4 "JabRef" ; names the corersponding uninstaller section
438 StrCpy $JabRefInstalled "JabRef"
440 SectionSetText 4 "" ; hides the corresponding uninstaller section
443 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
449 Function un.onUninstSuccess
451 MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
455 ;----------------------
457 !include "Uninstall.nsh"