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 many 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 # for some unknown odd reason the folder $INSTDIR_OLD\Resources\ui
131 # is not deleted in function InstDirChange, so the deletion has to be called
132 # again to make it work
133 ${if} $INSTDIR_OLD != ""
134 RMDir /r $INSTDIR_OLD
139 # -------------------------------------------
141 Function InstDirChange
143 # determine the new name of the install location,
144 # Change the old install path to the new one (currently only when the user
145 # has used the default path settings of the previous LyX-version)
146 StrCpy $String $INSTDIR
147 StrCpy $Search "${PRODUCT_VERSION_OLD}"
149 Call StrPoint # search the $INSTDIR for the phrase in ${PRODUCT_VERSION_OLD} ; function from LyXUtils.nsh
150 ${if} $Pointer != "-1" # if something was found
152 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\${PRODUCT_VERSION_OLD}"
153 StrCpy $String $String "$Pointer" # $String is now the part before "\${PRODUCT_VERSION_OLD}"
154 # rename the installation folder by copying LyX files
155 StrCpy $INSTDIR_NEW "$String\LyX ${PRODUCT_VERSION}"
156 CreateDirectory "$INSTDIR_NEW"
157 CopyFiles "$INSTDIR\*.*" "$INSTDIR_NEW"
158 # delete the old folder
160 StrCpy $INSTDIR_OLD $INSTDIR
161 StrCpy $INSTDIR $INSTDIR_NEW
163 # set new PATH_PREFIX in the file lyxrc.dist
164 FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" a
165 FileRead $R1 $PathPrefix # the whole file content is now in $PathPrefix
166 ${WordReplace} $PathPrefix "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $PathPrefix
167 FileSeek $R1 0 # set file pointer to the beginning
168 FileWrite $R1 '$PathPrefix' # overwrite the existing path with the actual one
171 # set the new path to the preferences file for all users
172 StrCpy $FileName "preferences"
173 StrCpy $OldString "${PRODUCT_VERSION_OLD}"
174 StrCpy $NewString "LyX ${PRODUCT_VERSION}"
175 Call CheckAppPathPreferences # function from LyXUtils.nsh
177 # set the new path to the session file for all users
178 StrCpy $FileName "session"
179 Call CheckAppPathPreferences # function from LyXUtils.nsh
181 # set new path to ImageMagick
182 ReadRegStr $ImageMagickPath SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
183 ${if} $ImageMagickPath != ""
184 ${WordReplace} $ImageMagickPath "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $ImageMagickPath # macro from WordFunc.nsh
185 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$ImageMagickPath"
188 ${endif} # end ${if} $Pointer != "-1" (if the folder is renamed)
192 # -------------------------------------------
194 Function RefreshRegUninst
196 # Refresh registry setings for the uninstaller
199 ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
200 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
201 WriteRegStr HKLM "SOFTWARE\Aspell" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
205 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
206 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
207 WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
208 StrCpy $MiKTeXVersionVar ${MiKTeXDeliveredVersionOld}
212 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersionOld}" "OnlyWithLyX"
213 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
214 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersionOld}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
215 StrCpy $JabRefVersionVar ${JabRefVersionOld}
219 ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
220 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
221 WriteRegStr HKLM "SOFTWARE\Aiksaurus" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
225 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX"
226 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
227 WriteRegStr HKLM "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
230 # Ghostscript and GSview
231 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX"
232 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
233 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"