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 ""
11 StrCpy $LangNameSys ""
13 # init, this variable is later only set to a value in function InstDirChange
14 # when the $INSTDIR is changed
15 StrCpy $INSTDIR_OLD ""
17 # extract modified files
18 Call UpdateModifiedFiles # macro from Updated.nsh
21 Call DeleteFiles # macro from Deleted.nsh
23 # delete old uninstaller
24 Delete "${PRODUCT_UNINSTALL_EXE}"
26 # delete old start menu folder
27 ReadRegStr $0 SHCTX "${PRODUCT_UNINST_KEY_OLD}" "StartMenu"
30 Delete "$DESKTOP\${PRODUCT_VERSION_OLD}.lnk"
32 # delete old registry entries
33 ${if} $CreateFileAssociations == "true"
34 DeleteRegKey SHCTX "${PRODUCT_DIR_REGKEY}"
35 # remove file extension .lyx
36 ReadRegStr $R0 SHCTX "Software\Classes\${PRODUCT_EXT}" ""
37 ${if} $R0 == "${PRODUCT_REGNAME}"
38 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_EXT}"
39 DeleteRegKey SHCTX "Software\Classes\${PRODUCT_REGNAME}"
42 DeleteRegKey SHCTX "${PRODUCT_UNINST_KEY_OLD}"
43 DeleteRegKey HKCR "Applications\lyx.bat"
44 DeleteRegKey HKCR "${PRODUCT_NAME}"
46 # determine the new name of the install location,
47 # Change the old install path to the new one (currently only when the user
48 # has used the default path settings of the previous LyX-version)
51 # Refresh registry setings for the uninstaller
54 # Create a batch file to start LyX with the environment variables set
55 # !only needed in this version! remove it for the next release
57 Delete "${PRODUCT_BAT}"
58 FileOpen $R1 "${PRODUCT_BAT}" w
59 FileWrite $R1 '@echo off$\r$\n\
60 SET LANG=$LangCode$\r$\n\
61 SET AIK_DATA_DIR=${AiksaurusDir}$\r$\n\
62 start "${PRODUCT_NAME}" "${LAUNCHER_NAME}" %*$\r$\n'
65 MessageBox MB_OK|MB_ICONEXCLAMATION "$(CreateCmdFilesFailed)"
68 ${if} $CreateFileAssociations == "true"
69 WriteRegStr SHCTX "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
71 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
72 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "LyX ${PRODUCT_VERSION}"
73 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
74 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
75 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
76 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
77 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
78 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
79 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
80 WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
81 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
82 WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
84 # create start menu entry
85 SetOutPath "$INSTDIR\bin"
86 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
87 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
89 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
92 ${if} $CreateDesktopIcon == "true"
93 SetOutPath "$INSTDIR\bin"
94 CreateShortCut "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
97 # register the extension .lyx
98 ${if} $CreateFileAssociations == "true"
99 # write informations about file type
100 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
101 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE}"
102 WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${LAUNCHER_EXE}" "%1"'
103 # write informations about file extensions
104 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
105 WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "Content Type" "${PRODUCT_MIME_TYPE}"
107 System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
111 WriteUninstaller "${PRODUCT_UNINSTALL_EXE}"
113 # test if Python is installed
114 # only use an existing python when it is version 2.5 because many Compaq and Dell PC are delivered
115 # with outdated Python interpreters
116 ReadRegStr $PythonPath HKLM "Software\Python\PythonCore\2.5\InstallPath" ""
117 ${if} $PythonPath == ""
118 StrCpy $PythonPath "$INSTDIR\bin"
120 StrCpy $PythonPath $PythonPath -1 # remove the "\" at the end
123 # run LyX's configure script
124 # create a bat-file to start configure in a console window so that the user see the progress
125 # of the configuration and to have a signal when the configuration is ready to start LyX
126 # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
127 # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
128 # a batch file is needed because simply calling ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
129 # creates the config files in $INSTDIR\bin
130 StrCpy $1 $INSTDIR 2 # get drive letter
131 FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
132 FileWrite $R1 '$1$\r$\n\
133 cd $INSTDIR\Resources\$\r$\n\
134 "$PythonPath\python.exe" configure.py'
136 MessageBox MB_OK|MB_ICONINFORMATION "$(LatexConfigInfo)"
137 ExecWait '"$INSTDIR\Resources\configLyX.bat"'
138 Delete "$INSTDIR\Resources\configLyX.bat"
140 # for some unknown odd reason the folder $INSTDIR_OLD\Resources\ui
141 # is not deleted in function InstDirChange, so the deletion has to be called
142 # again to make it work
143 ${if} $INSTDIR_OLD != ""
144 RMDir /r $INSTDIR_OLD
149 # -------------------------------------------
151 Function InstDirChange
153 # determine the new name of the install location,
154 # Change the old install path to the new one (currently only when the user
155 # has used the default path settings of the previous LyX-version)
156 StrCpy $String $INSTDIR
157 StrCpy $Search "${PRODUCT_VERSION_OLD}"
159 Call StrPoint # search the $INSTDIR for the phrase in ${PRODUCT_VERSION_OLD} ; function from LyXUtils.nsh
160 ${if} $Pointer != "-1" # if something was found
162 IntOp $Pointer $Pointer - 1 # jump before the first "\" of "\${PRODUCT_VERSION_OLD}"
163 StrCpy $String $String "$Pointer" # $String is now the part before "\${PRODUCT_VERSION_OLD}"
164 # rename the installation folder by copying LyX files
165 StrCpy $INSTDIR_NEW "$String\LyX ${PRODUCT_VERSION}"
166 CreateDirectory "$INSTDIR_NEW"
167 CopyFiles "$INSTDIR\*.*" "$INSTDIR_NEW"
168 # delete the old folder
170 StrCpy $INSTDIR_OLD $INSTDIR
171 StrCpy $INSTDIR $INSTDIR_NEW
173 # set new PATH_PREFIX in the file lyxrc.dist
174 FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" a
175 FileRead $R1 $PathPrefix
176 ${WordReplace} $PathPrefix "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $PathPrefix
177 FileSeek $R1 0 # set file pointer to the beginning
178 FileWrite $R1 '$PathPrefix' # overwrite the existing path with the actual one
181 # set the new path to the preferences file for all users
182 StrCpy $FileName "preferences"
183 StrCpy $OldString "${PRODUCT_VERSION_OLD}"
184 StrCpy $NewString "LyX ${PRODUCT_VERSION}"
185 Call CheckAppPathPreferences # function from LyXUtils.nsh
187 # set the new path to the session file for all users
188 StrCpy $FileName "session"
189 Call CheckAppPathPreferences # function from LyXUtils.nsh
191 # set new path to ImageMagick
192 ReadRegStr $ImageMagickPath SHCTX "SOFTWARE\Classes\Applications" "AutoRun"
193 ${if} $ImageMagickPath != ""
194 ${WordReplace} $ImageMagickPath "${PRODUCT_VERSION_OLD}" "LyX ${PRODUCT_VERSION}" "+" $ImageMagickPath # macro from WordFunc.nsh
195 WriteRegStr SHCTX "SOFTWARE\Classes\Applications" "AutoRun" "$ImageMagickPath"
198 ${endif} # end ${if} $Pointer != "-1" (if the folder is renamed)
202 # -------------------------------------------
204 Function RefreshRegUninst
206 # Refresh registry setings for the uninstaller
209 ReadRegStr $0 SHCTX "Software\Aspell" "OnlyWithLyX" # special entry to test if it was installed with LyX
210 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
211 WriteRegStr HKLM "SOFTWARE\Aspell" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
215 ReadRegStr $0 HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX"
216 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
217 WriteRegStr HKLM "SOFTWARE\MiKTeX.org\MiKTeX" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
218 StrCpy $MiKTeXVersionVar ${MiKTeXDeliveredVersionOld}
222 ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersionOld}" "OnlyWithLyX"
223 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT}"
224 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${JabRefVersionOld}" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
225 StrCpy $JabRefVersionVar ${JabRefVersionOld}
229 ReadRegStr $0 SHCTX "Software\Aiksaurus" "OnlyWithLyX" # special entry to test if it was installed with LyX
230 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
231 WriteRegStr HKLM "SOFTWARE\Aiksaurus" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
235 ReadRegStr $0 SHCTX "Software\ImageMagick" "OnlyWithLyX"
236 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
237 WriteRegStr HKLM "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"
240 # Ghostscript and GSview
241 ReadRegStr $0 HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX"
242 ${if} $0 == "Yes${PRODUCT_VERSION_SHORT_OLD}"
243 WriteRegStr HKLM "SOFTWARE\GPL Ghostscript" "OnlyWithLyX" "Yes${PRODUCT_VERSION_SHORT}"