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