]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
installer: another fix
[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 don't set this, because this is designed to be opened with LyX 1.5.x
82    #WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${PRODUCT_REGNAME}"
83    #WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${PRODUCT_MIME_TYPE}"
84    # .lyx16 don't set this, because this is designed to be opened with LyX 1.6.x
85    #WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "" "${PRODUCT_REGNAME}"
86    #WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "Content Type" "${PRODUCT_MIME_TYPE}"
87   
88    # Refresh shell
89    ${RefreshShellIcons}
90   ${endif}
91   
92   # Set path prefix in lyxrc.dist
93
94   # Install standard lyxrc.dist file
95   #SetOutPath "$INSTDIR\Resources"
96   #File "${FILES_DEPS}\Resources\lyxrc.dist"
97
98   # create the path prefix
99   # $$ represents a literal $ in an NSIS string
100   StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\python;$$LyXDir\imagemagick;$$LyXDir\ghostscript"
101   
102   ${If} $PathLaTeX != ""
103     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
104   ${EndIf}
105   ${if} $PSVPath != ""
106     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
107   ${endif}
108   ${if} $EditorPath != ""
109     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
110   ${endif}
111   ${if} $ImageEditorPath != ""
112     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
113   ${endif}
114   ${if} $SVGPath != ""
115    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
116   ${endif}
117   ${if} $WMFPath != ""
118    StrCpy $PathPrefix "$PathPrefix;$WMFPath"
119   ${endif}
120   ${If} $PathBibTeXEditor != ""
121     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
122   ${EndIf}  
123
124   # Set the path prefix in lyxrc.dist
125   ClearErrors
126   Delete "$INSTDIR\Resources\lyxrc.dist"
127   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
128   # set some general things
129   FileWrite $R1 '\screen_zoom "120"$\r$\n\
130                  \accept_compound true$\r$\n'
131   ${if} "$PathPrefix" != ""
132    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
133   ${endif}
134   # if Acrobat or Adobe Reader is used
135   ${if} $Acrobat == "Yes" # used for Acrobat / Adobe Reader
136    FileWrite $R1 '\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector"$\r$\n\
137                   \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector"$\r$\n\
138                   \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector"$\r$\n'
139   ${endif}
140   # if a SVG to PDF converter ws found (e.g. Inkscape)
141   ${if} $SVGPath != ""
142    FileWrite $R1 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
143                   \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
144                   \converter "svg" "pdf" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-pdf=$$$$p/$$$$o" ""$\r$\n\
145                   \converter "svg" "eps" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-eps=$$$$p/$$$$o" ""'
146   ${endif}
147   FileClose $R1
148   IfErrors 0 +2
149    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
150   ClearErrors
151
152 SectionEnd
153
154 #--------------------------------
155 # LaTeX files
156
157 /*Var UpdateFNDBReturn
158
159 Section -LaTeXFiles
160
161   # Install files in local root
162
163   ${If} $PathLaTeXLocal != ""
164     # dvipost
165     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
166     File "${FILES_DVIPOST_PKG}\dvipost.sty"
167     # LyX files in Resources\tex
168     SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
169     CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
170   ${EndIf}
171
172   # Update file name database
173
174   ${If} $PathLaTeX != ""
175     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
176     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
177     Pop $UpdateFNDBReturn # Return value
178   ${EndIf}
179   
180 SectionEnd*/
181
182 #--------------------------------
183 # Postscript printer for metafile to EPS converter
184
185 Section -PSPrinter
186
187   ${If} $MultiUser.Privileges == "Admin"
188     ${OrIf} $MultiUser.Privileges == "Power"
189
190     # Delete printer
191     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
192     # Install printer and driver
193     ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
194     # Restore DEVMODE with proper settings
195     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\bin\metafile2eps.dat" g'
196
197   ${EndIf}
198
199 SectionEnd
200
201 #--------------------------------
202 # Run the LyX configure.py script, so MiKTeX can download its packages
203
204 Var ConfigureReturn
205
206 Section -ConfigureScript
207
208   SetOutPath "$INSTDIR\Resources"
209   DetailPrint $(TEXT_CONFIGURE_LYX)
210   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
211   Pop $ConfigureReturn # Return value
212
213   # ask to update MiKTeX
214   ${if} $LaTeXInstalled == "MiKTeX"
215    Call UpdateMiKTeX # function from latex.nsh
216   ${endif}
217
218 SectionEnd
219
220 #--------------------------------
221 # Desktop shortcut
222
223 Function StartLyX
224
225   # Enable desktop icon creation when there is an icon already
226   # Old shortcuts need to be updated
227   
228   Exec "$INSTDIR\${APP_RUN}"
229
230 FunctionEnd
231
232 /*Function CheckDesktopShortcut
233
234   # Enable desktop icon creation when there is an icon already
235   # Old shortcuts need to be updated
236   
237   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
238     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
239   ${EndIf}
240
241 FunctionEnd
242
243 Function CreateDesktopShortcut
244
245   # Desktop icon creation is an option on the finish page
246   SetOutPath "$INSTDIR\bin"
247   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
248
249 FunctionEnd*/
250