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