]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/LyXWinInstaller/LyX-Installer-Complete.nsi
LyXWinInstaller: reflect LyX's beta state
[features.git] / development / Win32 / packaging / installer / LyXWinInstaller / LyX-Installer-Complete.nsi
1 ; Lyx for Windows, NSIS v2 series installer script
2
3 ; File LyXWinInstaller.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 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
12
13 ; This script requires NSIS 2.22 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 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/"
42
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"
48
49 ; Replaced by HKLM or HKCU depending on SetShellVarContext.
50 !define PRODUCT_ROOT_KEY "SHCTX"
51
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}"
54
55 !define ClassFileDir "${PRODUCT_SOURCEDIR}\Resources\tex"
56
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"
81
82 ;--------------------------------
83 ; Make some of the information above available to NSIS.
84
85 Name "${PRODUCT_NAME}"
86 OutFile "${INSTALLER_EXE}"
87 InstallDir "$PROGRAMFILES\${PRODUCT_NAME} ${PRODUCT_VERSION}"
88
89 ;--------------------------------
90 ; Variables
91
92 Var LatexPath
93 Var PythonPath
94 Var DelPythonFiles
95 Var GhostscriptPath
96 Var ImageMagickPath
97 Var AiksaurusPath
98 Var AspellPath
99 Var AspellInstallYes
100 Var AspellBaseReg
101 Var AspellMessage
102 Var Acrobat
103 Var PSVPath
104 Var EditorPath
105 Var ImageEditorPath
106 Var BibTeXEditorPath
107 Var JabRefInstalled
108 Var PathPrefix
109 Var Answer
110 Var UserName
111 Var LangName
112 Var LangNameSys
113 Var LangCode
114 Var LangCodeSys
115 Var LangEncoding
116 Var LangSysEncoding
117 Var DictCode
118 Var MissedProg
119 Var LaTeXName
120 Var MiKTeXVersion
121 Var MiKTeXInstalled
122 Var MiKTeXUser
123 Var MiKTeXPath
124 Var InstallGSview
125 Var InstallJabRef
126 Var CreateFileAssociations
127 Var CreateDesktopIcon
128 Var StartmenuFolder
129 Var ProductRootKey
130 Var AppPre
131 Var AppSuff
132 Var AppPath
133 Var String
134 Var Search
135 Var Pointer
136 Var UserList
137 Var RunNumber
138
139 ;--------------------------------
140 ; load some NSIS libraries
141 !include "MUI.nsh"
142 !include "LogicLib.nsh"
143 !include "FileFunc.nsh"
144 !include "StrFunc.nsh"
145 ;!include "TextFunc.nsh"
146 ;!insertmacro LineFind
147
148 ; Set of various macros and functions
149 !include "LyXUtils.nsh"
150
151 ; Function to check if needed programs are missing or not
152 !include "MissingPrograms.nsh"
153
154 ; Functions for page to set installer language
155 ; and LyX's menu language
156 !include "LanguageSettings.nsh"
157
158 ; Function for page to install Aspell dictionaries
159 !include "Aspell.nsh"
160
161 ; Use the Abiword macros to help set up associations with the file extension in the Registry.
162 ; Grabbed from
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"
165
166 ;--------------------------------
167
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"
172
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}"
179
180 ; Welcome page
181 !define MUI_WELCOMEPAGE_TEXT "$(WelcomePageText)"
182 !insertmacro MUI_PAGE_WELCOME
183
184 ; Show the license.
185 !insertmacro MUI_PAGE_LICENSE "${PRODUCT_LICENSE_FILE}"
186
187 ; Specify the installation directory.
188 !insertmacro MUI_PAGE_DIRECTORY
189
190 ; Specify LyX's menu language.
191 Page custom SelectMenuLanguage SelectMenuLanguage_LeaveFunction
192
193 ; Define which components to install.
194 !insertmacro MUI_PAGE_COMPONENTS
195
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
202
203 ; Check for needed programs
204 Page custom MissingProgramsPage MissingProgramsPage_LeaveFunction
205
206 ; Watch the components being installed.
207 !insertmacro MUI_PAGE_INSTFILES
208
209 ; Finish page
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
215
216 ; The uninstaller.
217 !insertmacro MUI_UNPAGE_COMPONENTS
218 !insertmacro MUI_UNPAGE_INSTFILES
219
220 ;--------------------------------
221 ; Languages
222
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"
238
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"
254
255 LicenseData "$(LyXLicenseData)"
256
257 ;--------------------------------
258 ; Reserve Files
259
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
264
265 ;--------------------------------
266 ; Installer sections
267
268 Section "!${PRODUCT_NAME}" SecCore
269   SectionIn RO
270 SectionEnd
271 Section "$(SecAllUsersTitle)" SecAllUsers
272   SetShellVarContext all
273   StrCpy $ProductRootKey "HKLM"
274 SectionEnd
275 Section "$(SecFileAssocTitle)" SecFileAssoc
276   StrCpy $CreateFileAssociations "true"
277 SectionEnd
278 Section "$(SecDesktopTitle)" SecDesktop
279   StrCpy $CreateDesktopIcon "true"
280 SectionEnd
281 Section /o "$(SecInstGSviewTitle)" SecInstGSview
282  AddSize 4000
283  StrCpy $InstallGSview "true"
284 SectionEnd
285 Section /o "$(SecInstJabRefTitle)" SecInstJabRef
286  AddSize 5000
287  StrCpy $InstallJabRef "true"
288 SectionEnd
289
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
299
300 !include "InstallActions-complete.nsh"
301
302 ;--------------------------------
303 ; This hook function is called internally by NSIS on installer startup
304 Function .onInit
305
306   ; set the installer language to the Windows locale language  
307   System::Call "kernel32::GetUserDefaultLangID()i.a"
308
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'
311   Pop $R0
312   ${if} $R0 != "0"
313    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
314    Abort
315   ${endif}
316   FindProcDLL::FindProc "${INSTALLER2_EXE}"
317   ${if} $R0 == "1"
318    MessageBox MB_OK|MB_ICONSTOP "$(InstallRunning)"
319    Abort
320   ${endif}
321
322   ; Check if LyX is already installed
323   ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "Publisher"
324   ${if} $0 != ""
325    MessageBox MB_OK|MB_ICONSTOP "$(StillInstalled)"
326    Abort
327   ${endif}
328
329   ; Default settings
330   ; These can be reset to "all" in section SecAllUsers.
331   SetShellVarContext current
332   StrCpy $ProductRootKey "HKCU"
333
334   ; This can be reset to "true" in section SecDesktop.
335   StrCpy $CreateDesktopIcon "false"
336   StrCpy $CreateFileAssociations "false"
337
338   ; If the user does *not* have administrator privileges, abort
339   StrCpy $Answer ""
340   StrCpy $UserName ""
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
347     !undef ENABLE
348   ${else}
349     MessageBox MB_OK|MB_ICONSTOP "$(NotAdmin)"
350     Abort
351   ${endif}
352
353   ; check which programs are installed or not
354   Call MissingPrograms ; function from MissingPrograms.nsh
355
356   ; don't let the installer sections appear when the programs are already installed
357   ${if} $PSVPath != ""
358    SectionSetText 4 "" ; hides the corresponding uninstaller section, ${SecInstGSview}
359   ${endif}
360   ${if} $BibTeXEditorPath != ""
361    SectionSetText 5 "" ; hides the corresponding uninstaller section, ${SecInstJabRef}
362   ${endif}
363
364   ClearErrors
365 FunctionEnd
366
367 ;--------------------------------
368
369 Function LaunchProduct
370   Exec ${PRODUCT_BAT}
371 FunctionEnd
372
373 ;--------------------------------
374
375 ;Function DeleteLines
376 ;       StrCpy $0 SkipWrite
377 ;       Push $0
378 ;FunctionEnd
379
380 ;--------------------------------
381 ; The Uninstaller
382
383 Function un.onInit
384
385   ; Check that LyX is not currently running
386   FindProcDLL::FindProc "lyx.exe"
387   ${if} $R0 == "1"
388    MessageBox MB_OK|MB_ICONSTOP "$(UnInstallRunning)"
389    Abort
390   ${endif}
391
392   ; Ascertain whether the user has sufficient privileges to uninstall.
393   SetShellVarContext current
394
395   ReadRegStr $0 HKCU "${PRODUCT_UNINST_KEY}" "RootKey"
396   ${if} $0 == ""
397     ReadRegStr $0 HKLM "${PRODUCT_UNINST_KEY}" "RootKey"
398     ${if} $0 == ""
399       MessageBox MB_OK|MB_ICONEXCLAMATION "$(UnNotInRegistryLabel)"
400     ${endif}
401   ${endif}
402
403   ; If the user does *not* have administrator privileges, abort
404   StrCpy $Answer ""
405   !insertmacro IsUserAdmin $Answer $UserName ; macro from LyXUtils.nsh
406   ${if} $Answer == "yes"
407     SetShellVarContext all
408   ${else}
409     MessageBox MB_OK|MB_ICONSTOP "$(UnNotAdminLabel)"
410     Abort
411   ${endif}
412
413   ; Macro to investigate name of LyX's preferences folders to be able remove them
414   !insertmacro UnAppPreSuff $AppPre $AppSuff ; macro from LyXUtils.nsh
415
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
418   ${if} $0 == "Yes"
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"
421   ${else}
422    SectionSetText 2 "" ; hides the corresponding uninstaller section
423   ${endif}
424
425   ; test if MiKTeX was installed together with LyX
426   ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
427   ${if} $0 == "Yes"
428    SectionSetText 3 "MiKTeX" ; names the corersponding uninstaller section
429    StrCpy $MiKTeXInstalled "MiKTeX"
430   ${else}
431    SectionSetText 3 "" ; hides the corresponding uninstaller section
432   ${endif}
433
434   ; test if JabRef was installed together with LyX
435   ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "OnlyWithLyX"
436   ${if} $0 == "Yes"
437    SectionSetText 4 "JabRef" ; names the corersponding uninstaller section
438    StrCpy $JabRefInstalled "JabRef"
439   ${else}
440    SectionSetText 4 "" ; hides the corresponding uninstaller section
441   ${endif}
442
443   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "$(UnReallyRemoveLabel)" IDYES +2
444   Abort
445
446 FunctionEnd
447
448
449 Function un.onUninstSuccess
450   HideWindow
451   MessageBox MB_ICONINFORMATION|MB_OK "$(UnRemoveSuccessLabel)"
452   
453 FunctionEnd
454
455 ;----------------------
456 ;Installer sections
457 !include "Uninstall.nsh"
458
459 ; eof