1 # The '-' makes the section invisible.
2 # Sections are entered in order, so the settings above are all
3 # available to SecInstallation
4 Section "-Installation actions" SecInstallation
7 File /r "${PRODUCT_SOURCEDIR}\bin"
8 File /r "${PRODUCT_SOURCEDIR}\etc"
9 File /r "${PRODUCT_SOURCEDIR}\Resources"
11 ${if} $GhostscriptPath == ""
12 # register Ghostscript
13 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_DLL" "${GhostscriptDir}\bin\gsdll32.dll"
14 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion}" "GS_LIB" "${GhostscriptDir}\lib;${GhostscriptDir}\fonts;${GhostscriptDir}\Resource"
16 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes" ; special entry to tell the uninstaller that it was installed with LyX
17 StrCpy $GhostscriptPath "${GhostscriptDir}\bin"
19 # delete unnecessary files
20 RMDir /r ${GhostscriptDir}
23 ${if} $ImageMagickPath == ""
24 # register ImageMagick
25 WriteRegStr HKLM "SOFTWARE\Classes\Applications" "AutoRun" "${ImageMagickDir}\convert.exe $$"
26 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "${ImageMagickDir}"
27 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
28 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "${ImageMagickDir}\config"
29 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
30 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "${ImageMagickDir}"
32 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "BinPath" "${ImageMagickDir}"
33 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "${ImageMagickDir}\modules\coders"
34 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "ConfigurePath" "${ImageMagickDir}\config"
35 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "${ImageMagickDir}\modules\filters"
36 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "LibPath" "${ImageMagickDir}"
37 WriteRegDWORD HKLM "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
38 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
40 WriteRegStr HKLM "Software\ImageMagick" "OnlyWithLyX" "Yes" ; special entry to tell the uninstaller that it was installed with LyX
41 StrCpy $ImageMagickPath ${ImageMagickDir}
43 # delete unnecessary files
44 RMDir /r ${ImageMagickDir}
47 ${if} $AspellPath == ""
48 # extract Aspell's program files
49 SetOutPath "$INSTDIR\external"
50 File /r "${PRODUCT_SOURCEDIR}\${AspellInstall}"
51 # copy the files and register Aspell
52 CopyFiles "$INSTDIR\${AspellInstall}" "$APPDATA"
54 WriteRegStr HKLM "SOFTWARE\Aspell" "Base Path" "${AspellDir}"
55 WriteRegStr HKLM "SOFTWARE\Aspell" "Dictionary Path" "${AspellDictPath}"
56 WriteRegStr HKLM "SOFTWARE\Aspell" "Personal Path" "${AspellPersonalPath}"
58 WriteRegStr HKLM "Software\Aspell" "OnlyWithLyX" "Yes" ; special entry to tell the uninstaller that it was installed with LyX
60 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "DisplayName" "${AspellDisplay}"
61 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "NoModify" 0x00000001
62 WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "NoRepair" 0x00000001
63 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Aspell" "UninstallString" "${AspellDir}\${AspellUninstall}"
66 ${if} $AiksaurusPath == ""
67 # extract Aiksaurus' program files
68 SetOutPath "$INSTDIR\external"
69 File /r "${PRODUCT_SOURCEDIR}\${AiksaurusInstall}"
70 # copy the files and register Aiksaurus
71 CopyFiles "$INSTDIR\${AiksaurusInstall}" "$APPDATA"
72 # WriteRegStr HKLM "Software\Aiksaurus" "OnlyWithLyX" "Yes" ; special entry to tell the uninstaller that it was installed with LyX
73 # WriteRegStr HKLM "Software\Aiksaurus" "Data Path" "${AiksaurusDir}"
76 # create the PathPrefix
77 StrCpy $PathPrefix "$INSTDIR\bin"
78 ${if} $PythonPath != ""
79 StrCpy $PathPrefix "$PathPrefix;$PythonPath"
81 ${if} $LatexPath != ""
82 StrCpy $PathPrefix "$PathPrefix;$LatexPath"
84 ${if} $GhostscriptPath != ""
85 StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
87 ${if} $ImageMagickPath != ""
88 StrCpy $PathPrefix "$PathPrefix;$ImageMagickPath"
91 StrCpy $PathPrefix "$PathPrefix;$PSVPath"
93 ${if} $EditorPath != ""
94 StrCpy $PathPrefix "$PathPrefix;$EditorPath"
96 ${if} $ImageEditorPath != ""
97 StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
100 # install the LaTeX class files that are delivered with LyX
101 # and enable MiKTeX's automatic package installation
102 StrCpy $String $LatexPath
103 StrCpy $Search "miktex\bin"
105 Call StrPoint ; search the LaTeXPath for the phrase "miktex\bin" (function from LyXUtils.nsh)
106 ${if} $Pointer != "-1" ; if something was found
107 IntOp $Pointer $Pointer - 1 ; jump before the first "\" of "\miktex\bin"
108 StrCpy $String $String "$Pointer" ; $String is now the part before "\miktex\bin"
109 # install LaTeX class files
110 SetOutPath "$String\tex\latex"
111 File "${ClassFileDir}\cv.cls"
112 CreateDirectory "$String\tex\latex\lyx"
113 SetOutPath "$String\tex\latex\lyx"
114 File "${ClassFileDir}\lyxchess.sty"
115 File "${ClassFileDir}\lyxskak.sty"
116 CreateDirectory "$String\tex\latex\revtex"
117 SetOutPath "$String\tex\latex\revtex"
118 File "${ClassFileDir}\revtex.cls"
119 CreateDirectory "$String\tex\latex\hollywood"
120 SetOutPath "$String\tex\latex\hollywood"
121 File "${ClassFileDir}\hollywood.cls"
122 CreateDirectory "$String\tex\latex\broadway"
123 SetOutPath "$String\tex\latex\broadway"
124 File "${ClassFileDir}\broadway.cls"
125 # install LaTeX-package dvipost (dvipost is not available for MiKTeX)
126 SetOutPath "$String\tex\latex\"
127 File /r "${DVIPostFileDir}"
129 ${if} $MiKTeXVersion == "2.4"
130 # refresh MiKTeX's file name database
131 ExecWait "$String\miktex\bin\initexmf --update-fndb"
132 # delete MiKTeX 2.4's dvipng executable as it is an old broken version. Then install a working one.
133 Delete "$String\miktex\bin\dvipng.exe"
135 SetOutPath "$String\miktex\bin"
136 File "${PRODUCT_DIR}\LyX\external\dvipng.exe"
137 # enable package installation without asking (1=Yes, 0=No, 2=Always Ask Before Installing)
138 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MiKTeX" "InstallPackagesOnTheFly" "1"
139 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM\Settings" "" ""
140 # Setting package repository (MiKTeX's primary package repository)
141 WriteRegStr HKCU "SOFTWARE\MiK\MiKTeX\CurrentVersion\MPM" "RemotePackageRepository" "${MiKTeXRepo}"
143 ${else} ; if MiKTeX 2.5
144 # refresh MiKTeX's file name database
145 ExecWait "$LaTeXPath\initexmf --update-fndb"
146 # enable package installation without asking (t = Yes, f = No)
147 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "AutoInstall" "1" ; if only for curent user
148 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_AUTOINSTALL" "t"
149 # set package repository (MiKTeX's primary package repository)
150 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "RemoteRepository" "${MiKTeXRepo}" ; if only for curent user
151 WriteRegStr HKCU "SOFTWARE\MiKTeX.org\MiKTeX\2.5\MPM" "RepositoryType" "remote" ; if only for curent user
152 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "MIKTEX_REPOSITORY" "${MiKTeXRepo}"
155 # enable MiKTeX's automatic package installation
156 ExecWait '$LaTeXPath\mpm.com --update-fndb'
157 ${endif} ; end ${if} $Pointer
159 # install Aspell dictionaries
160 ${if} $LangCode == "nb_NO"
161 StrCpy $LangCode "no_NO" ; we only have a norwegian dictionary available
163 Call InstallAspellDictionary ; function from aspell.nsh
166 # Set a path prefix in lyxrc.dist
168 ${if} "$PathPrefix" != ""
169 Delete "$INSTDIR\Resources\lyxrc.dist"
170 FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
171 FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
174 MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
177 # Create a batch file to start LyX with the environment variables set
179 Delete "${PRODUCT_BAT}"
180 FileOpen $R1 "${PRODUCT_BAT}" w
181 FileWrite $R1 '@echo off$\r$\n\
182 SET LANG=$LangCode$\r$\n\
183 SET AIK_DATA_DIR=${AiksaurusDir}$\r$\n\
184 start "LyX" "lyx.exe" %*$\r$\n'
187 MessageBox MB_OK|MB_ICONEXCLAMATION "$(CreateCmdFilesFailed)"
189 # set the preferences file
190 # having one preferences file that is modified to fit the needs isn't possible because the command
191 # ${LineFind} "$INSTDIR\Resources\preferences" "" "-16:-11" "DeleteLines" ; macro from TextFunc.nsh
192 # removes the file permissions for Users, so that it can later not be read (bug in ${LineFind} of TextFunc.nsh)
193 # if not Acrobat or Adobe Reader is used
194 ${if} $Acrobat == "None" ; clear the entries in the preferences file that define PDFViewWin7 or 8 as viewer
195 Rename "$INSTDIR\Resources\preferencesGSview" "$INSTDIR\Resources\preferences"
196 Delete "$INSTDIR\Resources\preferences7"
197 Delete "$INSTDIR\Resources\preferences8"
199 # if Acrobat or Adobe Reader is used
200 ${if} $Acrobat == "7" ; clear the entries in the preferences file that define PDFViewWin8 as viewer
201 Rename "$INSTDIR\Resources\preferences7" "$INSTDIR\Resources\preferences"
202 Delete "$INSTDIR\Resources\preferences8"
203 Delete "$INSTDIR\Resources\preferencesGSview"
205 ${if} $Acrobat == "8" ; clear the entries in the preferences filethat define PDFViewWin7 as viewer
206 Rename "$INSTDIR\Resources\preferences8" "$INSTDIR\Resources\preferences"
207 Delete "$INSTDIR\Resources\preferences7"
208 Delete "$INSTDIR\Resources\preferencesGSview"
212 WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
213 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
214 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
215 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
216 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
217 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
218 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
219 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
220 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
221 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
222 WriteRegStr ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
223 WriteRegDWORD ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
224 WriteRegDWORD ${PRODUCT_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
226 SetOutPath "$INSTDIR\bin"
227 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
228 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
229 SetOutPath "$INSTDIR"
230 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
232 ${if} $CreateDesktopIcon == "true"
233 SetOutPath "$INSTDIR\bin"
234 CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
237 # register the extension .lyx
238 ${if} $CreateFileAssociations == "true"
239 ${CreateApplicationAssociation} "${PRODUCT_NAME}" "${PRODUCT_NAME}" "$(FileTypeTitle)" "${PRODUCT_EXE}" "${PRODUCT_BAT}"
240 ${CreateFileAssociation} "${PRODUCT_EXT}" "${PRODUCT_NAME}" "${PRODUCT_MIME_TYPE}"
243 # create the LyX Application Data folder for all users
244 # this folder is automatically created by LyX when it is first started but we want to start LyX with a specific session file,
245 # so we create this folder before LyX starts and copy there the session file
246 Call CreateAppPathSub ; function from LyXUtils.nsh
248 # delete unnecessary files
249 ${if} $DelPythonFiles == "True"
250 Delete $INSTDIR\bin\python.exe
251 Delete $INSTDIR\bin\python25.dll
252 Delete $INSTDIR\bin\Python-License.txt
253 RMDir /r $INSTDIR\bin\Lib
254 RMDir /r $INSTDIR\bin\DLLs
256 RMDir /r $INSTDIR\external
259 WriteUninstaller "${PRODUCT_UNINSTALL_EXE}"
261 # run LyX's configure script
262 # create a bat-file to start configure in a console window so that the user see the progress
263 # of the configuration and to have a signal when the configuration is ready to start LyX
264 # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
265 # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
266 # a batch file is needed because simply calling ExecWait '"$INSTDIR\bin\python.exe" "$INSTDIR\Resources\configure.py"'
267 # creates the config files in $INSTDIR\bin
268 StrCpy $1 $INSTDIR 2 ; get drive letter
269 FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
270 FileWrite $R1 'cd $INSTDIR\Resources\$\r$\n\
272 "$INSTDIR\bin\python.exe" configure.py'
274 MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
275 ExecWait '"$INSTDIR\Resources\configLyX.bat"'
276 Delete "$INSTDIR\Resources\configLyX.bat"
278 # ask to update MiKTeX
279 ${if} $MiKTeXInstalled == "yes"
280 MessageBox MB_YESNO|MB_ICONINFORMATION "$(MiKTeXInfo)" IDYES UpdateNow IDNO UpdateLater
282 StrCpy $0 $LaTeXPath -4 ; remove "\bin"
283 ExecWait '"$LaTeXPath\copystart.exe" "$0\config\update.dat"' ; run MiKTeX's update wizard
287 # save MiKTeX's install path to be able to remove LyX's LaTeX-files in the uninstaller
288 FileOpen $R1 "$INSTDIR\Resources\uninstallPaths.dat" w
289 FileWrite $R1 '$LaTeXPath'