5 Write registry information and configure LyX
11 #!define SHORTCUT '${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"'
13 #--------------------------------
14 # Registry information
18 # Registry information
19 WriteRegStr SHCTX ${APP_REGKEY} "" $INSTDIR
20 WriteRegStr SHCTX ${APP_REGKEY} "Version" "${APP_VERSION_NUMBER}"
21 WriteRegStr SHCTX ${APP_REGKEY_SETUP} "LaTeX Path" $PathLaTeX
24 SetOutPath "$INSTDIR\bin" # this is the folder in which the shortcut is executed
25 # we must assure that the folder is not empty (happens on silent install and can accidentally happen)
26 ${if} $StartmenuFolder == ""
27 StrCpy $StartmenuFolder "${APP_DIR}"
29 CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
30 CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
31 # Link to www.lyx.org and to the Wiki
32 WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WEBPAGE_INFO}.url" "InternetShortcut" "URL" "${APP_WEBPAGE}"
33 WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WIKI_INFO}.url" "InternetShortcut" "URL" "${APP_WIKI}"
35 ${if} $CreateDesktopIcon == "true"
36 SetOutPath "$INSTDIR\bin"
37 CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
40 # Uninstaller information
41 ${If} $MultiUser.InstallMode == "CurrentUser"
42 WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
44 WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION}"
47 WriteRegStr SHCTX ${APP_UNINST_KEY} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
48 WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayVersion" "${APP_VERSION}"
49 WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayIcon" "$INSTDIR\bin\lyx,0"
50 WriteRegStr SHCTX ${APP_UNINST_KEY} "URLUpdateInfo" "http://www.lyx.org/"
51 WriteRegStr SHCTX ${APP_UNINST_KEY} "URLInfoAbout" "http://www.lyx.org/about/"
52 WriteRegStr SHCTX ${APP_UNINST_KEY} "Publisher" "LyX Team"
53 WriteRegStr SHCTX ${APP_UNINST_KEY} "HelpLink" "http://www.lyx.org/internet/mailing.php"
54 WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoModify" 0x00000001
55 WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoRepair" 0x00000001
56 WriteRegStr SHCTX ${APP_UNINST_KEY} "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
58 # if we install over an older existing version, remove the old uninstaller information
59 ${if} $OldVersionNumber < ${APP_SERIES_KEY}
60 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber"
61 # also delete in the case of an emergency release
62 DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber1"
67 #--------------------------------
68 # Write LyX configuration file
72 # Associate .lyx files with LyX for current user or all users
74 ${if} $CreateFileAssociations == "true"
75 WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
78 # Write information about file type
79 #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
81 ${if} $CreateFileAssociations == "true"
82 WriteRegStr SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
83 WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
84 WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
85 WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
86 # we need to update also the automatically created entry about the lyx.exe
87 # otherwise .lyx-files will could be opened with an older LyX version
88 ReadRegStr $0 SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" ""
89 ${if} $0 != "" # if something was found
90 WriteRegStr SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
93 WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
94 WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
96 WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
97 WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
99 WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
100 WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
102 WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
103 WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
105 WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "" "${APP_REGNAME_DOC}"
106 WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "Content Type" "${APP_MIME_TYPE}"
108 WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "" "${APP_REGNAME_DOC}"
109 WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "Content Type" "${APP_MIME_TYPE}"
110 # .lyx21 don't set this, because this is designed to be opened with LyX 2.1.x
116 # Install standard lyxrc.dist file
117 #SetOutPath "$INSTDIR\Resources"
118 #File "${FILES_DEPS}\Resources\lyxrc.dist"
120 # create the path prefix
121 # $$ represents a literal $ in an NSIS string
122 StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\Python;$$LyXDir\Python\Lib;$$LyXDir\Perl\bin;$$LyXDir\imagemagick"
124 ${if} $PathLaTeX != ""
125 StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
128 StrCpy $PathPrefix "$PathPrefix;$PSVPath"
130 ${if} $EditorPath != ""
131 StrCpy $PathPrefix "$PathPrefix;$EditorPath"
133 ${if} $ImageEditorPath != ""
134 StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
136 ${if} $GhostscriptPath != ""
137 StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
140 StrCpy $PathPrefix "$PathPrefix;$SVGPath"
142 ${if} $GnumericPath != ""
143 StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
145 ${if} $PathBibTeXEditor != ""
146 StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
148 ${if} $PandocPath != ""
149 StrCpy $PathPrefix "$PathPrefix;$PandocPath"
151 ${if} $LilyPondPath != ""
152 StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
155 # Set the path prefix in lyxrc.dist
157 Delete "$INSTDIR\Resources\lyxrc.dist"
158 FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
159 # set the format to the latest LyXRC format
160 FileWrite $R1 'Format 19$\r$\n'
161 # set some general things
162 FileWrite $R1 '\screen_zoom 120$\r$\n'
163 ${if} "$PathPrefix" != ""
164 FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
167 # use pdfview for all types of PDF files
168 FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
169 \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
170 \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
171 \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
172 \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n'
174 # use Inkscape to edit PDF and EPS images
176 FileWrite $R1 '\format "pdf6" "pdf" "PDF (graphics)" "" "auto" "inkscape" "vector" "application/pdf"$\r$\n\
177 \format "eps" "eps" "EPS" "" "auto" "inkscape" "vector" "image/x-eps"$\r$\n'
180 # if Inkscape is not available Imagemagick will be used to convert WMF/EMF files
181 # We need to specify a resolution for the converter otherwise 1024 dpi are used and
182 # eps2pdf takes ages. 300 dpi are a good compromise for speed and size.
184 FileWrite $R1 '\converter "wmf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n\
185 \converter "emf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n'
188 # if LilyPondPath was found
189 # We need to add these entris because python scripts can only be executed
190 # if the full path is given.
191 ${if} $LilyPondPath != ""
192 FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export" ""$\r$\n\
193 \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
194 \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
195 \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
196 \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
200 MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)" /SD IDOK
203 # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
204 ${if} $MultiUser.Privileges != "Admin"
205 ${andif} $MultiUser.Privileges != "Power"
206 # call the non-admin version
207 ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\Perl\bin"
209 ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\Perl\bin"
214 #--------------------------------
215 # Run the LyX configure.py script, so MiKTeX can download its packages
219 Section -ConfigureScript
221 SetOutPath "$INSTDIR\Resources"
223 # ask to update MiKTeX
224 ${if} $LaTeXInstalled == "MiKTeX"
225 Call UpdateMiKTeX # function from latex.nsh
226 # install all necessary packages at once because this is much faster then to install the packages one by one
227 DetailPrint $(TEXT_CONFIGURE_LYX)
228 ${if} $MultiUser.Privileges != "Admin"
229 ${andif} $MultiUser.Privileges != "Power"
230 # call the non-admin version
231 # at first we need to synchronize the package database
232 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--update-db"'
233 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
235 ${if} $MiKTeXUser != "HKCU" # call the admin version
236 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" "--verbose" "--update-db"'
237 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
239 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--update-db"'
240 nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
245 DetailPrint $(TEXT_CONFIGURE_LYX)
246 nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
247 # $ConfigureReturn is "0" if successful, otherwise "1"
248 Pop $ConfigureReturn # Return value
252 #--------------------------------
257 # run LyX in a command line window to give the users feedback about
258 # the time consuming LaTeX package installation
260 #Exec 'cmd /K " "$INSTDIR\bin\lyx.exe""'
261 Exec "$INSTDIR\${APP_RUN}"
265 /*Function CheckDesktopShortcut
267 # Enable desktop icon creation when there is an icon already
268 # Old shortcuts need to be updated
270 ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
271 ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
276 Function CreateDesktopShortcut
278 # Desktop icon creation is an option on the finish page
279 SetOutPath "$INSTDIR\bin"
280 CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"