]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
installer:
[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\LyXLauncher,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
122   # Set the path prefix in lyxrc.dist
123   ClearErrors
124   Delete "$INSTDIR\Resources\lyxrc.dist"
125   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
126   # set some general things
127   FileWrite $R1 '\screen_zoom "120$\r$\n"'
128   ${if} "$PathPrefix" != ""
129    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
130   ${endif}
131   ${if} $Acrobat == "Yes" # use pdfview for Acrobat / Adobe Reader
132    FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export"$\r$\n\
133                   \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export"$\r$\n\
134                   \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export"$\r$\n\
135                   \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export"$\r$\n\
136                   \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export"$\r$\n'
137   ${endif}
138   # if a SVG to PDF converter ws found (e.g. Inkscape)
139   ${if} $SVGPath != ""
140    FileWrite $R1 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
141                   \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
142                   \converter "svg" "pdf" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-pdf=$$$$p/$$$$o" ""$\r$\n\
143                   \converter "svg" "eps" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-eps=$$$$p/$$$$o" ""'
144   ${endif}
145   FileClose $R1
146   IfErrors 0 +2
147    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
148   ClearErrors
149
150 SectionEnd
151
152 #--------------------------------
153 # LaTeX files
154
155 /*Var UpdateFNDBReturn
156
157 Section -LaTeXFiles
158
159   # Install files in local root
160
161   ${If} $PathLaTeXLocal != ""
162     # dvipost
163     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
164     File "${FILES_DVIPOST_PKG}\dvipost.sty"
165     # LyX files in Resources\tex
166     SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
167     CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
168   ${EndIf}
169
170   # Update file name database
171
172   ${If} $PathLaTeX != ""
173     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
174     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
175     Pop $UpdateFNDBReturn # Return value
176   ${EndIf}
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
188     # Delete printer
189     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
190     # Install printer and driver
191     ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
192     # Restore DEVMODE with proper settings
193     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\bin\metafile2eps.dat" g'
194
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   DetailPrint $(TEXT_CONFIGURE_LYX)
208   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
209   Pop $ConfigureReturn # Return value
210
211   # ask to update MiKTeX
212   ${if} $LaTeXInstalled == "MiKTeX"
213    Call UpdateMiKTeX # function from latex.nsh
214   ${endif}
215
216 SectionEnd
217
218 #--------------------------------
219 # Desktop shortcut
220
221 Function StartLyX
222
223   # Enable desktop icon creation when there is an icon already
224   # Old shortcuts need to be updated
225   
226   Exec "$INSTDIR\${APP_RUN}"
227
228 FunctionEnd
229
230 /*Function CheckDesktopShortcut
231
232   # Enable desktop icon creation when there is an icon already
233   # Old shortcuts need to be updated
234   
235   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
236     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
237   ${EndIf}
238
239 FunctionEnd
240
241 Function CreateDesktopShortcut
242
243   # Desktop icon creation is an option on the finish page
244   SetOutPath "$INSTDIR\bin"
245   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
246
247 FunctionEnd*/
248