]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
older Windows versions require a reference to ntprint.inf
[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 # File associations
16
17 Section -FileAssociations
18
19   # Associate .lyx files with LyX for current user of all users
20
21   # Write information about file type
22   !define REG_FILETYPE 'WriteRegStr SHELL_CONTEXT "Software\Classes\${APP_REGNAME_DOC}'
23   
24   ${REG_FILETYPE}" "" "${APP_NAME} Document"
25   ${REG_FILETYPE}\DefaultIcon" "" "$INSTDIR\bin\LyXLauncher.exe,0"
26   ${REG_FILETYPE}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
27   
28   !define REG_FILEEXT 'WriteRegStr SHELL_CONTEXT "Software\Classes\${APP_EXT}"'
29   
30   ${REG_FILEEXT} "" "${APP_REGNAME_DOC}"
31   ${REG_FILEEXT} "Content Type" "${APP_MIME_TYPE}"  
32   
33   # Refresh shell
34   ${RefreshShellIcons}
35
36 SectionEnd
37
38 #--------------------------------
39 # Registry information
40
41 Section -InstallData
42
43   # Registry information
44   WriteRegStr SHELL_CONTEXT ${APP_REGKEY} "" $INSTDIR
45   WriteRegStr SHELL_CONTEXT ${APP_REGKEY} "Version" "${APP_VERSION_NUMBER}"
46
47   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETUP} "LaTeX Path" $PathLaTeX
48   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETUP} "ImageMagick Path" $PathImageMagick
49   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETUP} "Ghostscript Path" $PathGhostscript
50   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETUP} "LyX Language" $LangName
51
52   # Start Menu shortcut
53   # There is only one shortcut to the application, so it should be in the main group
54   SetOutPath "$INSTDIR\bin"
55   CreateShortCut "$SMPROGRAMS\${SHORTCUT}
56     
57   # Uninstaller information
58   !define REG_UNINSTALL 'WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SETUP_UNINSTALLER_KEY}"'
59   
60   ${If} $MultiUser.InstallMode == "CurrentUser"
61     ${REG_UNINSTALL} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
62   ${Else}
63     ${REG_UNINSTALL} "DisplayName" "${APP_NAME} ${APP_VERSION}"
64   ${EndIf}
65   
66   ${REG_UNINSTALL} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
67   ${REG_UNINSTALL} "DisplayVersion" "${APP_VERSION}"
68   ${REG_UNINSTALL} "DisplayIcon" "$INSTDIR\bin\LyXLauncher,0"
69   ${REG_UNINSTALL} "URLUpdateInfo" "http://www.lyx.org/"
70   ${REG_UNINSTALL} "URLInfoAbout" "http://www.lyx.org/about/"
71   ${REG_UNINSTALL} "Publisher" "LyX Team"
72   ${REG_UNINSTALL} "HelpLink" "http://www.lyx.org/internet/mailing.php"  
73   
74 SectionEnd
75
76 #--------------------------------
77 # Write LyX configuration file
78
79 Section -Configure
80
81   # Windows specific configuration in lyxrc.dist
82
83   Delete "$INSTDIR\Resources\lyxrc.dist"
84   FileOpen $DistFile "$INSTDIR\Resources\lyxrc.dist" w
85
86   # Path prefix
87
88   StrCpy $PathPrefix "$INSTDIR\bin;$INSTDIR\python"
89   
90   !ifdef BUNDLE_IMAGEMAGICK
91     StrCpy $PathImageMagick "$INSTDIR\imagemagick"
92   !endif
93   !ifdef BUNDLE_GHOSTSCRIPT
94     StrCpy $PathGhostscript "$INSTDIR\ghostscript\bin"
95   !endif  
96   
97   ${If} $PathLaTeX != ""
98     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
99   ${EndIf}
100   ${If} $PathGhostscript != ""
101     StrCpy $PathPrefix "$PathPrefix;$PathGhostscript"
102   ${EndIf}
103   ${If} $PathImageMagick != ""
104     StrCpy $PathPrefix "$PathPrefix;$PathImageMagick"
105   ${EndIf}
106   ${If} $PathBibTeXEditor != ""
107     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
108   ${EndIf}  
109
110   FileWrite $DistFile '\path_prefix "$PathPrefix"$\r$\n'
111
112   # Default screen fonts
113   FileWrite $DistFile '\screen_font_roman "Times New Roman"$\r$\n'
114   FileWrite $DistFile '\screen_font_sans "Arial"$\r$\n'
115   FileWrite $DistFile '\screen_font_typewriter "Courier New"$\r$\n'
116   FileWrite $DistFile '\preview_scale_factor 1.0$\r$\n' # Fit instant preview font size to screen fonts
117   # PDF view helper
118   FileWrite $DistFile '\format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector"$\r$\n'  
119   FileWrite $DistFile '\format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector"$\r$\n'
120   FileWrite $DistFile '\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector"$\r$\n'
121
122   FileClose $DistFile
123
124   # Set language
125   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETTINGS} "Language" $LangISOCode
126
127 SectionEnd
128
129 #--------------------------------
130 # LaTeX files
131
132 Var UpdateFNDBReturn
133
134 Section -LaTeXFiles
135
136   # Install files in local root
137
138   ${If} $PathLaTeXLocal != ""
139     # dvipost
140     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
141     File "${FILES_DVIPOST_PKG}\dvipost.sty"
142     # LyX files in Resources\tex
143     SetOutPath "$PathLaTeXLocal\tex\latex\lyx"
144     CopyFiles /SILENT "$INSTDIR\Resources\tex\*.*" "$PathLaTeXLocal\tex\latex\lyx"
145   ${EndIf}
146
147   # Update file name database
148
149   ${If} $PathLaTeX != ""
150     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
151     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
152     Pop $UpdateFNDBReturn # Return value
153   ${EndIf}
154
155 SectionEnd
156
157 #--------------------------------
158 # Postscript printer for metafile to EPS converter
159
160 Section -PSPrinter
161
162   ${If} $MultiUser.Privileges == "Admin"
163     ${OrIf} $MultiUser.Privileges == "Power"
164
165     # Delete printer
166     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
167     # Install printer and driver
168     ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
169     # Restore DEVMODE with proper settings
170     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\bin\metafile2eps.dat" g'
171
172   ${EndIf}
173
174 SectionEnd
175
176 #--------------------------------
177 # Run the LyX configure.py script, so MiKTeX can download its packages
178
179 Var ConfigureReturn
180
181 Section -ConfigureScript
182
183   SetOutPath "$INSTDIR\Resources"
184   DetailPrint $(TEXT_CONFIGURE_LYX)
185   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
186   Pop $ConfigureReturn # Return value
187
188 SectionEnd
189
190 #--------------------------------
191 # Desktop shortcut
192
193 Function CheckDesktopShortcut
194
195   # Enable desktop icon creation when there is an icon already
196   # Old shortcuts need to be updated
197   
198   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
199     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
200   ${EndIf}
201
202 FunctionEnd
203
204 Function CreateDesktopShortcut
205
206   # Desktop icon creation is an option on the finish page
207   SetOutPath "$INSTDIR\bin"
208   CreateShortCut "$DESKTOP\${SHORTCUT}
209
210 FunctionEnd