]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/LyXWinInstaller/InstallActions-complete.nsh
installer:
[features.git] / development / Win32 / packaging / installer / LyXWinInstaller / InstallActions-complete.nsh
1 # this file contains the main installer section
2
3 # The '-' makes the section invisible.
4 Section "-Installation actions" SecInstallation
5
6   # dummy actions to avoid NSIS warnings
7   StrCpy $FileName ""
8   StrCpy $NewString ""
9   StrCpy $OldString ""
10   
11   # extract all files
12   SetOutPath "$INSTDIR"
13   File /r "${PRODUCT_SOURCEDIR}\bin"
14   File /r "${PRODUCT_SOURCEDIR}\etc"
15   File /r "${PRODUCT_SOURCEDIR}\Resources"
16   File /r "${PRODUCT_SOURCEDIR}\external"
17
18   # install MiKTeX if not already installed
19   Call InstallMiKTeX # function from LaTeX.nsh
20
21   # install Ghostscript if not already installed
22   Call Ghostscript
23
24   # install ImageMagick if not already installed
25   Call ImageMagick
26
27   # install Aspell if not already installed
28   Call InstallAspell # function from Aspell.nsh
29
30   # install Aiksaurus if not already installed
31   Call Aiksaurus
32
33   # install GSview if not already installed and the user selected it
34   Call PostScript
35
36   # install JabRef if not already installed and the user selected it
37   Call BibTeX
38
39   # install the LaTeX class files that are delivered with LyX
40   # and enable MiKTeX's automatic package installation
41   Call ConfigureMiKTeX # Function from LaTeX.nsh
42
43   # install Aspell dictionaries
44   ${if} $LangCode == "nb_NO"
45    StrCpy $LangCode "no_NO" # we only have a norwegian dictionary available
46   ${endif}
47   Call InstallAspellDictionary # function from Aspell.nsh
48
49   # configure LyX
50   Call ConfigureLyX # Function from ConfigLyX.nsh
51
52   # delete unnecessary files
53   ${if} $DelPythonFiles == "True"
54    Delete $INSTDIR\bin\python.exe
55    Delete $INSTDIR\bin\python25.dll
56    Delete $INSTDIR\bin\Python-License.txt
57    RMDir /r $INSTDIR\bin\Lib
58    RMDir /r $INSTDIR\bin\DLLs
59   ${endif}
60   RMDir /r $INSTDIR\external
61
62   # create Uninstaller
63   WriteUninstaller "${PRODUCT_UNINSTALL_EXE}"
64
65   # run LyX's configure script
66   # create a bat-file to start configure in a console window so that the user see the progress
67   # of the configuration and to have a signal when the configuration is ready to start LyX
68   # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
69   # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
70   # a batch file is needed because simply calling ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
71   # creates the config files in $PythonPath
72   ${if} $PythonPath == ""
73    StrCpy $PythonPath "$INSTDIR\bin"
74   ${endif}
75   StrCpy $1 $INSTDIR 2 # get drive letter
76   FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
77   FileWrite $R1 '$1$\r$\n\
78                  cd $INSTDIR\Resources\$\r$\n\
79                  "$PythonPath\python.exe" configure.py'
80   FileClose $R1
81   MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
82   ExecWait '"$INSTDIR\Resources\configLyX.bat"'
83   Delete "$INSTDIR\Resources\configLyX.bat"
84
85   # ask to update MiKTeX
86   ${if} $MiKTeXInstalled == "yes"
87    MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" IDYES UpdateNow IDNO UpdateLater
88    UpdateNow:
89     StrCpy $0 $LaTeXPath -4 # remove "\bin"
90     ExecWait '"$LaTeXPath\copystart.exe" "$0\config\update.dat"' # run MiKTeX's update wizard
91    UpdateLater:
92   ${endif}
93
94   # save MiKTeX's install path to be able to remove LyX's LaTeX-files in the uninstaller
95   FileOpen $R1 "$INSTDIR\Resources\uninstallPaths.dat" w
96   FileWrite $R1 '$LaTeXPath'
97   FileClose $R1
98
99 SectionEnd
100
101 # -------------------------------------------
102
103 Function Ghostscript
104
105   # if GhostScript is not installed
106   ${if} $GhostscriptPath == ""
107    # register Ghostscript
108    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_DLL" "${GhostscriptDir}\bin\gsdll32.dll"
109    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_LIB" "${GhostscriptDir}\lib;${GhostscriptDir}\fonts;${GhostscriptDir}\Resource"
110    
111    WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to tell the uninstaller that it was installed with LyX
112    StrCpy $GhostscriptPath "${GhostscriptDir}\bin"
113   ${else}
114    # delete unnecessary files
115    RMDir /r ${GhostscriptDir}
116   ${endif}
117
118 FunctionEnd
119
120 # -------------------------------------------
121
122 Function ImageMagick
123
124   # if ImageMagick is not installed
125   ${if} $ImageMagickPath == ""
126    # register ImageMagick
127    WriteRegStr HKLM "SOFTWARE\Classes\Applications" "AutoRun" "${ImageMagickDir}\convert.exe $$"
128    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "${ImageMagickDir}"
129    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
130    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "${ImageMagickDir}\config"
131    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
132    WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "${ImageMagickDir}"
133    
134    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "BinPath" "${ImageMagickDir}"
135    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
136    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "ConfigurePath" "${ImageMagickDir}\config"
137    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
138    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "LibPath" "${ImageMagickDir}"
139    WriteRegDWORD HKLM "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010   
140    WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
141    
142    WriteRegStr HKLM "Software\ImageMagick" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to tell the uninstaller that it was installed with LyX
143    StrCpy $ImageMagickPath ${ImageMagickDir}
144   ${else}
145    # delete unnecessary files
146    RMDir /r ${ImageMagickDir}
147   ${endif}
148
149 FunctionEnd
150
151 # -------------------------------------------
152
153 Function Aiksaurus
154
155   # if Aiksaurus is not installed
156   ${if} $AiksaurusPath == ""
157    # extract Aiksaurus' program files
158    SetOutPath "$INSTDIR\external"
159    File /r "${PRODUCT_SOURCEDIR}\${AiksaurusInstall}"
160    # copy the files and register Aiksaurus
161    CopyFiles "$INSTDIR\${AiksaurusInstall}" "$APPDATA"
162 #   WriteRegStr HKLM "Software\Aiksaurus" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to tell the uninstaller that it was installed with LyX
163 #   WriteRegStr HKLM "Software\Aiksaurus" "Data Path" "${AiksaurusDir}"
164   ${endif}
165
166 FunctionEnd
167
168 # -------------------------------------------
169
170 Function PostScript
171
172 # if no PostScript viewer is installed
173   ${if} $PSVPath == ""
174    ${if} $InstallGSview == "true"
175     # launch installer
176     MessageBox MB_OK|MB_ICONINFORMATION "$(GSviewInfo)"
177     ExecWait "$INSTDIR\${GSviewInstall}"
178     # test if GSview is installed
179     StrCpy $PSVPath ""
180     ReadRegStr $PSVPath HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\gsview32.exe" "Path"    
181     ${if} $PSVPath == ""
182      MessageBox MB_OK|MB_ICONEXCLAMATION "$(GSviewError)"
183     ${endif}
184    ${endif}
185   ${endif}
186
187 FunctionEnd
188
189 # -------------------------------------------
190
191 Function BibTeX
192
193 # if no BibTeX editor is installed
194   ${if} $BibTeXEditorPath == ""
195    ${if} $InstallJabRef == "true"
196     # launch installer
197     MessageBox MB_OK|MB_ICONINFORMATION "$(JabRefInfo)"
198     ExecWait "$INSTDIR\${JabRefInstall}"
199     # test if JabRef is installed
200     StrCpy $BibTeXEditorPath ""
201     ReadRegStr $BibTeXEditorPath HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "UninstallString"    
202     ${if} $BibTeXEditorPath == ""
203      MessageBox MB_OK|MB_ICONEXCLAMATION "$(JabRefError)"
204     ${else}
205      WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersion}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}" # special entry to tell the uninstaller that it was installed with LyX
206     ${endif}
207    ${endif}
208   ${endif}
209
210 FunctionEnd
211