]> 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                  \accept_compound true$\r$\n'
129   ${if} "$PathPrefix" != ""
130    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
131   ${endif}
132   # if a SVG to PDF converter ws found (e.g. Inkscape)
133   ${if} $SVGPath != ""
134    FileWrite $R1 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
135                   \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
136                   \converter "svg" "pdf" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-pdf=$$$$p/$$$$o" ""$\r$\n\
137                   \converter "svg" "eps" "inkscape --file=$$$$p/$$$$i --export-area-drawing --without-gui --export-eps=$$$$p/$$$$o" ""'
138   ${endif}
139   FileClose $R1
140   IfErrors 0 +2
141    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
142   ClearErrors
143
144 SectionEnd
145
146 #--------------------------------
147 # LaTeX files
148
149 /*Var UpdateFNDBReturn
150
151 Section -LaTeXFiles
152
153   # Install files in local root
154
155   ${If} $PathLaTeXLocal != ""
156     # dvipost
157     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
158     File "${FILES_DVIPOST_PKG}\dvipost.sty"
159     # LyX files in Resources\tex
160     SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
161     CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
162   ${EndIf}
163
164   # Update file name database
165
166   ${If} $PathLaTeX != ""
167     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
168     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
169     Pop $UpdateFNDBReturn # Return value
170   ${EndIf}
171   
172 SectionEnd*/
173
174 #--------------------------------
175 # Postscript printer for metafile to EPS converter
176
177 Section -PSPrinter
178
179   ${If} $MultiUser.Privileges == "Admin"
180     ${OrIf} $MultiUser.Privileges == "Power"
181
182     # Delete printer
183     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
184     # Install printer and driver
185     ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
186     # Restore DEVMODE with proper settings
187     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\bin\metafile2eps.dat" g'
188
189   ${EndIf}
190
191 SectionEnd
192
193 #--------------------------------
194 # Run the LyX configure.py script, so MiKTeX can download its packages
195
196 Var ConfigureReturn
197
198 Section -ConfigureScript
199
200   SetOutPath "$INSTDIR\Resources"
201   DetailPrint $(TEXT_CONFIGURE_LYX)
202   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
203   Pop $ConfigureReturn # Return value
204
205   # ask to update MiKTeX
206   ${if} $LaTeXInstalled == "MiKTeX"
207    Call UpdateMiKTeX # function from latex.nsh
208   ${endif}
209
210 SectionEnd
211
212 #--------------------------------
213 # Desktop shortcut
214
215 Function StartLyX
216
217   # Enable desktop icon creation when there is an icon already
218   # Old shortcuts need to be updated
219   
220   Exec "$INSTDIR\${APP_RUN}"
221
222 FunctionEnd
223
224 /*Function CheckDesktopShortcut
225
226   # Enable desktop icon creation when there is an icon already
227   # Old shortcuts need to be updated
228   
229   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
230     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
231   ${EndIf}
232
233 FunctionEnd
234
235 Function CreateDesktopShortcut
236
237   # Desktop icon creation is an option on the finish page
238   SetOutPath "$INSTDIR\bin"
239   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
240
241 FunctionEnd*/
242