]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/installer/setup/configure.nsh
Windows installer: Bump preferences format
[lyx.git] / development / Win32 / packaging / installer / setup / configure.nsh
1 /*
2
3 configure.nsh
4
5 Write registry information and configure LyX
6
7 */
8
9 Var PathPrefix
10
11 #!define SHORTCUT '${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"'
12
13 #--------------------------------
14 # Registry information
15
16 Section -InstallData
17
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
22   
23   # Start Menu shortcut
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}"
28   ${endif}
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}"
34   # create desktop icon
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}"
38   ${endif}
39   
40   # Uninstaller information
41   ${If} $MultiUser.InstallMode == "CurrentUser"
42     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
43   ${Else}
44     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION}"
45   ${EndIf}
46   
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"
57   
58   # if we install over an existing version, remove the old uninstaller information
59   ${if} $OldVersionNumber != ""
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"
63   ${endif}
64   
65 SectionEnd
66
67 #--------------------------------
68 # Write LyX configuration file
69
70 Section -Configure
71
72   # Associate .lyx files with LyX for current user of all users
73
74   ${if} $CreateFileAssociations == "true"
75    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
76   ${endif}
77
78   # Write information about file type
79   #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
80   
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    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
87    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
88    # .lyx13
89    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
90    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
91    # .lyx14
92    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
93    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
94    # .lyx15
95    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
96    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
97    # .lyx16
98    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "" "${APP_REGNAME_DOC}"
99    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "Content Type" "${APP_MIME_TYPE}"
100    # .lyx20 don't set this, because this is designed to be opened with LyX 2.0.x
101   
102    # Refresh shell
103    ${RefreshShellIcons}
104   ${endif}
105   
106   # Install standard lyxrc.dist file
107   #SetOutPath "$INSTDIR\Resources"
108   #File "${FILES_DEPS}\Resources\lyxrc.dist"
109
110   # create the path prefix
111   # $$ represents a literal $ in an NSIS string
112   StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\Python;$$LyXDir\Python\Lib;$$LyXDir\Perl\bin;$$LyXDir\imagemagick"
113   
114   ${if} $PathLaTeX != ""
115     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
116   ${EndIf}
117   ${if} $PSVPath != ""
118     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
119   ${endif}
120   ${if} $EditorPath != ""
121     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
122   ${endif}
123   ${if} $ImageEditorPath != ""
124     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
125   ${endif}
126   ${if} $GhostscriptPath != ""
127    StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
128   ${endif}
129   ${if} $SVGPath != ""
130    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
131   ${endif}
132   ${if} $GnumericPath != ""
133    StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
134   ${endif}
135   ${if} $PathBibTeXEditor != ""
136     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
137   ${EndIf}
138   ${if} $LilyPondPath != ""
139    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
140   ${endif}
141   
142   # Set the path prefix in lyxrc.dist
143   ClearErrors
144   Delete "$INSTDIR\Resources\lyxrc.dist"
145   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
146   # set the format to the latest LyXRC format
147   FileWrite $R1 'Format 15$\r$\n'
148   # set some general things
149   FileWrite $R1 '\screen_zoom 120$\r$\n'
150   ${if} "$PathPrefix" != ""
151    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
152   ${endif}
153   
154   # set path to eLyXer
155   FileWrite $R1 '\converter "lyx" "html" "python -tt \"$INSTDIR\Python\Lib\elyxer.py\" --directory $$$$r $$$$i $$$$o" ""$\r$\n\
156                  \converter "lyx" "wordhtml" "python -tt \"$INSTDIR\Python\Lib\elyxer.py\" --html --directory $$$$r $$$$i $$$$o" ""$\r$\n'
157   
158   # use pdfview for all types of PDF files
159   FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
160                  \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
161                  \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
162                  \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
163                  \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n'
164
165   # if LilyPondPath was found
166   # we need to add these entris because python scripts can only be executed
167   # if the full path is given
168   ${if} $LilyPondPath != ""
169    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export" ""$\r$\n\
170                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
171                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
172                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
173                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
174   ${endif}
175   FileClose $R1
176   IfErrors 0 +2
177    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)" /SD IDOK
178   ClearErrors
179
180 SectionEnd
181
182 #--------------------------------
183 # Postscript printer for metafile to EPS converter
184
185 Section -PSPrinter
186
187   ${if} $MultiUser.Privileges == "Admin"
188   ${orif} $MultiUser.Privileges == "Power"
189    # Delete printer
190    ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
191    # Install printer and driver
192    ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
193   ${else}
194    MessageBox MB_OK|MB_ICONINFORMATION "$(MetafileNotAvailable)" /SD IDOK
195   ${endif}
196
197 SectionEnd
198
199 #--------------------------------
200 # Run the LyX configure.py script, so MiKTeX can download its packages
201
202 Var ConfigureReturn
203
204 Section -ConfigureScript
205
206   SetOutPath "$INSTDIR\Resources"
207   
208   # ask to update MiKTeX
209   ${if} $LaTeXInstalled == "MiKTeX"
210    Call UpdateMiKTeX # function from latex.nsh
211    # install all necessary packages at once
212    DetailPrint $(TEXT_CONFIGURE_LYX)
213    ${if} $MultiUser.Privileges != "Admin"
214    ${andif} $MultiUser.Privileges != "Power"
215     # call the non-admin version
216     nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
217    ${else}
218     ${if} $MiKTeXUser != "HKCU" # call the admin version
219      nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--admin" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
220     ${else}
221      nsExec::ExecToLog '"$PathLaTeX\mpm.exe" "--verbose" "--install-some=$INSTDIR\Resources\Packages.txt"'
222     ${endif}
223    ${endif}
224   ${endif}
225   
226   DetailPrint $(TEXT_CONFIGURE_LYX)
227   nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
228   # $ConfigureReturn is "0" if successful, otherwise "1"
229   Pop $ConfigureReturn # Return value
230
231 SectionEnd
232
233 #--------------------------------
234 # Desktop shortcut
235
236 Function StartLyX
237
238   # run LyX in a command line window to give the users feedback about
239   # the time consuming LaTeX package installation
240   
241   #Exec 'cmd /K " "$INSTDIR\bin\lyx.exe""'
242   Exec "$INSTDIR\${APP_RUN}"
243
244 FunctionEnd
245
246 /*Function CheckDesktopShortcut
247
248   # Enable desktop icon creation when there is an icon already
249   # Old shortcuts need to be updated
250   
251   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
252     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
253   ${EndIf}
254
255 FunctionEnd
256
257 Function CreateDesktopShortcut
258
259   # Desktop icon creation is an option on the finish page
260   SetOutPath "$INSTDIR\bin"
261   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
262
263 FunctionEnd*/
264