1 # this file contains the main installer section
3 # The '-' makes the section invisible.
4 Section "-Installation actions" SecInstallation
6 # dummy actions to avoid NSIS warnings
7 StrCpy $AspellBaseReg ""
8 StrCpy $AspellMessage ""
11 StrCpy $LangCodeSys ""
13 StrCpy $LangNameSys ""
16 # init, this variable is later only set to a value in function InstDirChange
17 # when the $INSTDIR is changed
18 StrCpy $INSTDIR_OLD ""
20 # extract modified files
21 Call UpdateModifiedFiles # macro from Updated.nsh
24 Call DeleteFiles # macro from Deleted.nsh
26 # delete old uninstaller
27 Delete "${PRODUCT_UNINSTALL_EXE}"
29 # delete old start menu folder
30 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY_OLD}" "StartMenu"
33 Delete "$DESKTOP\${PRODUCT_VERSION_OLD}.lnk"
35 # delete old registry entries
36 ${if} $CreateFileAssociations == "true"
37 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
38 # remove file extension .lyx
39 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
40 ${if} $R0 == "${PRODUCT_REGNAME}"
41 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
42 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
45 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY_OLD}"
46 DeleteRegKey HKCR "Applications\lyx.bat"
47 DeleteRegKey HKCR "${PRODUCT_NAME}"
49 # determine the new name of the install location,
50 # Change the old install path to the new one (currently only when the user
51 # has used the default path settings of the previous LyX-version)
54 # Refresh registry setings for the uninstaller
58 ${if} $CreateFileAssociations == "true"
59 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
61 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
62 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "LyX ${PRODUCT_VERSION}"
63 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
64 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
65 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
66 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
67 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
68 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
69 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
70 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
71 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
72 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
74 # create start menu entry
75 SetOutPath "$INSTDIR\bin"
76 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
77 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
79 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
82 ${if} $CreateDesktopIcon == "true"
83 SetOutPath "$INSTDIR\bin"
84 CreateShortCut "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
87 # register the extension .lyx
88 ${if} $CreateFileAssociations == "true"
89 # write informations about file type
90 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
91 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE}"
92 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_BAT}" "%1"'
93 # write informations about file extensions
94 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
95 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "Content Type" "${PRODUCT_MIME_TYPE}"
97 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
101 WriteUninstaller "${PRODUCT_UNINSTALL_EXE}"
103 # test if Python is installed
104 # only use an existing python when it is version 2.5 because some Compaq and Dell PC are delivered
105 # with outdated Python interpreters
106 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
107 ${if} $PythonPath == ""
108 StrCpy $PythonPath "$INSTDIR\bin"
110 StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
113 # run LyX's configure script
114 # create a bat-file to start configure in a console window so that the user see the progress
115 # of the configuration and to have a signal when the configuration is ready to start LyX
116 # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
117 # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
118 # a batch file is needed because simply calling ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
119 # creates the config files in $INSTDIR\bin
120 StrCpy $1 $INSTDIR 2 # get drive letter
121 FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
122 FileWrite $R1 '$1$\r$\n\
123 cd $INSTDIR\Resources\$\r$\n\
124 "$PythonPath\python.exe" configure.py'
126 MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
127 ExecWait '"$INSTDIR\Resources\configLyX.bat"'
128 Delete "$INSTDIR\Resources\configLyX.bat"
130 # there might be the case that python files need to be updated
131 # but this should only be done when Python is not installed
132 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
133 ${if} $PythonPath == ""
134 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
136 ${if} $PythonPath != ""
137 RMDir /r $INSTDIR\bin\Lib
138 RMDir /r $INSTDIR\bin\DLLs
141 # for some unknown odd reason the folder $INSTDIR_OLD\Resources\ui
142 # is not deleted in function InstDirChange, so the deletion has to be called
143 # again to make it work
144 ${if} $INSTDIR_OLD != ""
145 RMDir /r $INSTDIR_OLD
150 # -------------------------------------------
152 Function InstDirChange
154 # determine the new name of the install location,
155 # Change the old install path to the new one (only when the user
156 # has used the default path settings of the previous LyX-version, otherwise leave the path as is)
157 StrCpy $String $INSTDIR
158 StrCpy $Search "${PRODUCT_VERSION_OLD}"
160 Call StrPoint # search the $INSTDIR for the phrase in ${PRODUCT_VERSION_OLD} ; function from LyXUtils.nsh
161 ${if} $Pointer != "-1" # if something was found
163 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\${PRODUCT_VERSION_OLD}"
164 StrCpy $String $String "$Pointer" # $String is now the part before "\${PRODUCT_VERSION_OLD}"
165 # rename the installation folder by copying LyX files
166 StrCpy $INSTDIR_NEW "$String\LyX ${PRODUCT_VERSION}"
167 CreateDirectory "$INSTDIR_NEW"
168 CopyFiles "$INSTDIR\*.*" "$INSTDIR_NEW"
169 # delete the old folder
171 StrCpy $INSTDIR_OLD $INSTDIR
172 StrCpy $INSTDIR $INSTDIR_NEW
174 # set new path_prefix in the file lyxrc.dist
175 StrCpy $OldString "${PRODUCT_VERSION_OLD}"
176 StrCpy $NewString "LyX ${PRODUCT_VERSION}"
177 # following macro from TextFunc.nsh # calls Function ReplaceLineContent from LyXUtils.nsh
178 ${LineFind} "$INSTDIR\Resources\lyxrc.dist" "" "1:-1" "ReplaceLineContent"
180 # set the new path to the preferences file for all users
181 StrCpy $FileName "preferences"
182 StrCpy $OldString "${PRODUCT_VERSION_OLD}"
183 StrCpy $NewString "LyX ${PRODUCT_VERSION}"
184 Call CheckAppPathPreferences # function from LyXUtils.nsh
186 # set the new path to the session file for all users
187 StrCpy $FileName "session"
188 Call CheckAppPathPreferences # function from LyXUtils.nsh
190 # set new path to ImageMagick
191 ReadRegStr $ImageMagickPath SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
192 ${if} $ImageMagickPath != ""
193 ${WordReplace} $ImageMagickPath "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $ImageMagickPath # macro from WordFunc.nsh
194 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$ImageMagickPath"
197 ${endif} # end ${if} $Pointer != "-1" (if the folder is renamed)
201 # -------------------------------------------
203 Function RefreshRegUninst
205 # Refresh registry setings for the uninstaller
208 ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
209 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
210 WriteRegStr HKLM "SOFTWARE\Aspell" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
214 # first test if Python is installed
215 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
216 ${if} $PythonPath == ""
217 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.6\InstallPath" ""
219 ${if} $PythonPath == ""
220 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\3.0\InstallPath" ""
222 ${if} $PythonPath == ""
223 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\3.1\InstallPath" ""
225 ${if} $PythonPath != ""
226 StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
228 # now install eLyXer as Python module
229 ${if} $PythonPath != ""
230 # a Python module cannot simply started with
231 # ExecWait '$PythonPath\python.exe "$INSTDIR\bin\setup.py" install'
232 # therefore run a script
233 StrCpy $1 $INSTDIR 2 # get drive letter
234 FileOpen $R1 "$INSTDIR\bin\eLyXer.bat" w
235 FileWrite $R1 '$1$\r$\n\
236 cd "$INSTDIR\bin"$\r$\n\
237 "$PythonPath\python.exe" setup.py install'
239 ExecWait '"$INSTDIR\bin\eLyXer.bat"'
240 Delete "$INSTDIR\bin\eLyXer.bat"
242 ExecWait '"$INSTDIR\bin\python.exe" "$INSTDIR\bin\setup.py" install'
246 Var /GLOBAL RegLocation
247 StrCpy $RegLocation "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Metafile to EPS Converter"
248 ReadRegStr $0 SHCTX "$RegLocation" "OnlyWithLyX"
249 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
250 WriteRegStr HKLM "$RegLocation" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
252 ReadRegStr $0 HKLM "SOFTWARE\InkNote Selector" ""
253 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0 # macro from WordFunc.nsh
254 WriteRegStr HKLM "SOFTWARE\InkNote Selector" "" "$0"
255 ReadRegStr $0 HKLM "$RegLocation" "InstallLocation"
256 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
257 WriteRegStr HKLM "$RegLocation" "InstallLocation" "$0"
261 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
262 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
263 WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
267 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX"
268 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
269 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\JabRef ${JabRefVersion}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
272 # Aiksaurus currently not needed
273 #ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX"
274 #${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
275 # WriteRegStr HKLM "SOFTWARE\Aiksaurus" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
279 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX"
280 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
281 WriteRegStr HKLM "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
283 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\Current" "BinPath"
284 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0 # macro from WordFunc.nsh
285 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "BinPath" "$0"
286 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\Current" "CoderModulesPath"
287 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
288 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$0"
289 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\Current" "ConfigurePath"
290 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
291 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$0"
292 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\Current" "FilterModulesPath"
293 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
294 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$0"
295 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\Current" "LibPath"
296 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
297 WriteRegStr HKLM "SOFTWARE\ImageMagick\Current" "LibPath" "$0"
299 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "BinPath"
300 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
301 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "BinPath" "$0"
302 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "CoderModulesPath"
303 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
304 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "CoderModulesPath" "$0"
305 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "ConfigurePath"
306 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
307 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "ConfigurePath" "$0"
308 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "FilterModulesPath"
309 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
310 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "FilterModulesPath" "$0"
311 ReadRegStr $0 HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "LibPath"
312 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
313 WriteRegStr HKLM "SOFTWARE\ImageMagick\${ImageMagickVersion_Old}\Q:16" "LibPath" "$0"
316 # Ghostscript and GSview
317 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX"
318 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
319 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
321 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion_Old}" "GS_DLL"
322 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
323 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion_Old}" "GS_DLL" "$0"
324 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion_Old}" "GS_LIB"
325 ${WordReplace} $0 "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $0
326 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript\${GhostscriptVersion_Old}" "GS_LIB" "$0"