]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
Win Installer: LyXLauncher does no longer exist.
[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\imagemagick;$$LyXDir\ghostscript"
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} $SVGPath != ""
113    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
114   ${endif}
115   ${if} $WMFPath != ""
116    StrCpy $PathPrefix "$PathPrefix;$WMFPath"
117   ${endif}
118   ${if} $PathBibTeXEditor != ""
119     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
120   ${EndIf}
121   ${if} $LilyPondPath != ""
122    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
123   ${endif}  
124
125   # Set the path prefix in lyxrc.dist
126   ClearErrors
127   Delete "$INSTDIR\Resources\lyxrc.dist"
128   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
129   # set the format
130   FileWrite $R1 'Format 1$\r$\n'
131   # set some general things
132   FileWrite $R1 '\screen_zoom 120$\r$\n'
133   ${if} "$PathPrefix" != ""
134    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
135   ${endif}
136   ${if} $Acrobat == "Yes" # use pdfview for Acrobat / Adobe Reader
137    FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export"$\r$\n\
138                   \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export"$\r$\n\
139                   \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export"$\r$\n\
140                   \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export"$\r$\n\
141                   \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export"$\r$\n'
142   ${endif}
143   # if a SVG to PDF converter was found (e.g. Inkscape)
144   ${if} $SVGPath != ""
145    FileWrite $R1 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
146                   \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
147                   \converter "svg" "pdf" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-pdf=$$$$p/$$$$o" ""$\r$\n\
148                   \converter "svg" "eps" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-eps=$$$$p/$$$$o" ""$\r$\n'
149   ${endif}
150   # if LilyPondPath was found
151   # we need to add these entris because python scripts can only be executed
152   # if the full path is given
153   ${if} $LilyPondPath != ""
154    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export"$\r$\n\
155                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
156                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
157                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
158                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
159   ${endif}
160   FileClose $R1
161   IfErrors 0 +2
162    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
163   ClearErrors
164
165 SectionEnd
166
167 #--------------------------------
168 # LaTeX files
169
170 /*Var UpdateFNDBReturn
171
172 Section -LaTeXFiles
173
174   # Install files in local root
175
176   ${If} $PathLaTeXLocal != ""
177     # dvipost
178     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
179     File "${FILES_DVIPOST_PKG}\dvipost.sty"
180     # LyX files in Resources\tex
181     SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
182     CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
183   ${EndIf}
184
185   # Update file name database
186
187   ${If} $PathLaTeX != ""
188     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
189     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
190     Pop $UpdateFNDBReturn # Return value
191   ${EndIf}
192   
193 SectionEnd*/
194
195 #--------------------------------
196 # Postscript printer for metafile to EPS converter
197
198 Section -PSPrinter
199
200   ${If} $MultiUser.Privileges == "Admin"
201     ${OrIf} $MultiUser.Privileges == "Power"
202
203     # Delete printer
204     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
205     # Install printer and driver
206     ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
207     # Restore DEVMODE with proper settings
208     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\bin\metafile2eps.dat" g'
209
210   ${EndIf}
211
212 SectionEnd
213
214 #--------------------------------
215 # Run the LyX configure.py script, so MiKTeX can download its packages
216
217 Var ConfigureReturn
218
219 Section -ConfigureScript
220
221   SetOutPath "$INSTDIR\Resources"
222   DetailPrint $(TEXT_CONFIGURE_LYX)
223   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
224   Pop $ConfigureReturn # Return value
225
226   # ask to update MiKTeX
227   ${if} $LaTeXInstalled == "MiKTeX"
228    Call UpdateMiKTeX # function from latex.nsh
229   ${endif}
230
231 SectionEnd
232
233 #--------------------------------
234 # Desktop shortcut
235
236 Function StartLyX
237
238   # Enable desktop icon creation when there is an icon already
239   # Old shortcuts need to be updated
240   
241   Exec "$INSTDIR\${APP_RUN}"
242
243 FunctionEnd
244
245 /*Function CheckDesktopShortcut
246
247   # Enable desktop icon creation when there is an icon already
248   # Old shortcuts need to be updated
249   
250   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
251     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
252   ${EndIf}
253
254 FunctionEnd
255
256 Function CreateDesktopShortcut
257
258   # Desktop icon creation is an option on the finish page
259   SetOutPath "$INSTDIR\bin"
260   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
261
262 FunctionEnd*/
263