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