]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
lots of installer improvements:
[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   System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
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}"
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   CreateShortCut "$SMPROGRAMS\${SHORTCUT}
55     
56   # Uninstaller information
57   !define REG_UNINSTALL 'WriteRegStr SHELL_CONTEXT "Software\Microsoft\Windows\CurrentVersion\Uninstall\${SETUP_UNINSTALLER_KEY}"'
58   
59   ${If} $MultiUser.InstallMode == "CurrentUser"
60     ${REG_UNINSTALL} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
61   ${Else}
62     ${REG_UNINSTALL} "DisplayName" "${APP_NAME} ${APP_VERSION}"
63   ${EndIf}
64   
65   ${REG_UNINSTALL} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
66   ${REG_UNINSTALL} "DisplayVersion" "${APP_VERSION}"
67   ${REG_UNINSTALL} "DisplayIcon" "$INSTDIR\bin\LyXLauncher,0"
68   ${REG_UNINSTALL} "URLUpdateInfo" "http://www.lyx.org/"
69   ${REG_UNINSTALL} "URLInfoAbout" "http://www.lyx.org/about/"
70   ${REG_UNINSTALL} "Publisher" "LyX Team"
71   ${REG_UNINSTALL} "HelpLink" "http://www.lyx.org/internet/mailing.php"  
72   
73 SectionEnd
74
75 #--------------------------------
76 # Write LyX configuration file
77
78 Section -Configure
79
80   # Windows specific configuration in lyxrc.dist
81
82   Delete "$INSTDIR\Resources\lyxrc.dist"
83   FileOpen $DistFile "$INSTDIR\Resources\lyxrc.dist" w
84
85   # Path prefix
86
87   StrCpy $PathPrefix "$INSTDIR\bin;$INSTDIR\python"
88   
89   !ifdef BUNDLE_IMAGEMAGICK
90     StrCpy $PathImageMagick "$INSTDIR\imagemagick"
91   !endif
92   !ifdef BUNDLE_GHOSTSCRIPT
93     StrCpy $PathGhostscript "$INSTDIR\ghostscript\bin"
94   !endif  
95   
96   ${If} $PathLaTeX != ""
97     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
98   ${EndIf}
99   ${If} $PathGhostscript != ""
100     StrCpy $PathPrefix "$PathPrefix;$PathGhostscript"
101   ${EndIf}
102   ${If} $PathImageMagick != ""
103     StrCpy $PathPrefix "$PathPrefix;$PathImageMagick"
104   ${EndIf}
105
106   FileWrite $DistFile '\path_prefix "$PathPrefix"$\r$\n'
107
108   # Default screen fonts
109   FileWrite $DistFile '\screen_font_roman "Times New Roman"$\r$\n'
110   FileWrite $DistFile '\screen_font_sans "Arial"$\r$\n'
111   FileWrite $DistFile '\screen_font_typewriter "Courier New"$\r$\n'
112   FileWrite $DistFile '\preview_scale_factor 1.0$\r$\n' # Fit instant preview font size to screen fonts
113   # PDF view helper
114   FileWrite $DistFile '\format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector"$\r$\n'  
115   FileWrite $DistFile '\format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector"$\r$\n'
116   FileWrite $DistFile '\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector"$\r$\n'
117
118   FileClose $DistFile
119
120   # Set language
121   WriteRegStr SHELL_CONTEXT ${APP_REGKEY_SETTINGS} "Language" $LangISOCode
122
123 SectionEnd
124
125 #--------------------------------
126 # dvipost package
127
128 Var UpdateFNDBReturn
129
130 Section -dvipost
131
132   # Install package in local root
133
134   ${if} $PathLaTeXLocal != ""
135     SetOutPath "$PathLaTeXLocal\tex\latex\dvipost"
136     File "${FILES_DVIPOST_PKG}\dvipost.sty"
137   ${endif}
138
139   # Update file name database
140
141   ${if} $PathLaTeX != ""
142     DetailPrint $(TEXT_CONFIGURE_MIKTEXFNDB)
143     nsExec::ExecToLog '"$PathLaTeX\initexmf.exe" --update-fndb'
144     Pop $UpdateFNDBReturn # Return value
145   ${endif}
146
147 SectionEnd
148
149 #--------------------------------
150 # Postscript printer for metafile to EPS converter
151
152 Section -PSPrinter
153
154   ${If} $MultiUser.Privileges == "Admin"
155     ${OrIf} $MultiUser.Privileges == "Power"
156
157     # Delete printer
158     ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
159
160     # Delete printer driver
161     ExecWait '$PrinterConf /q /dd /m "Metafile to EPS Converter"'
162
163     # Install printer and driver
164     ExecWait '$PrinterConf /q /if /f "$INSTDIR\PSPrinter\metafile2eps.inf" /r "FILE:" /m "Metafile to EPS Converter"'
165
166     # Restore DEVMODE with proper settings
167     ExecWait '$PrinterConf /q /Sr /n "Metafile to EPS Converter" /a "$INSTDIR\PSPrinter\metafile2eps.dat" g'
168
169   ${EndIf}
170
171 SectionEnd
172
173 #--------------------------------
174 # Run the LyX configure.py script, so MiKTeX can download its packages
175
176 Var ConfigureReturn
177
178 Section -ConfigureScript
179
180   DetailPrint $(TEXT_CONFIGURE_LYX)
181   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\Resources\configure.py"'
182   Pop $ConfigureReturn # Return value
183
184 SectionEnd
185
186 #--------------------------------
187 # Desktop shortcut
188
189 Function CheckDesktopShortcut
190
191   # Enable desktop icon creation when there is an icon already
192   # Old shortcuts need to be updated
193   
194   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
195     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
196   ${EndIf}
197
198 FunctionEnd
199
200 Function CreateDesktopShortcut
201
202   # Desktop icon creation is an option on the finish page
203
204   CreateShortCut "$DESKTOP\${SHORTCUT}
205
206 FunctionEnd