]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
installer: further work on dictionary handling and bugfixes
[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 PathPrefix
10
11 #!define SHORTCUT '${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"'
12
13 #--------------------------------
14 # Registry information
15
16 Section -InstallData
17
18   # Registry information
19   WriteRegStr SHCTX ${APP_REGKEY} "" $INSTDIR
20   WriteRegStr SHCTX ${APP_REGKEY} "Version" "${APP_VERSION_NUMBER}"
21   WriteRegStr SHCTX ${APP_REGKEY_SETUP} "LaTeX Path" $PathLaTeX
22   
23   # Start Menu shortcut
24   SetOutPath "$INSTDIR\bin" # this is the folder in which the shortcut is executed
25   CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
26   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
27   # Link to www.lyx.org and to the Wiki
28   WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WEBPAGE_INFO}.url" "InternetShortcut" "URL" "${APP_WEBPAGE}"
29   WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WIKI_INFO}.url" "InternetShortcut" "URL" "${APP_WIKI}"
30   # create desktop icon
31   ${if} $CreateDesktopIcon == "true"
32    SetOutPath "$INSTDIR\bin"
33    CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
34   ${endif}
35   
36   # Uninstaller information
37   ${If} $MultiUser.InstallMode == "CurrentUser"
38     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
39   ${Else}
40     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION}"
41   ${EndIf}
42   
43   WriteRegStr SHCTX ${APP_UNINST_KEY} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
44   WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayVersion" "${APP_VERSION}"
45   WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayIcon" "$INSTDIR\bin\lyx,0"
46   WriteRegStr SHCTX ${APP_UNINST_KEY} "URLUpdateInfo" "http://www.lyx.org/"
47   WriteRegStr SHCTX ${APP_UNINST_KEY} "URLInfoAbout" "http://www.lyx.org/about/"
48   WriteRegStr SHCTX ${APP_UNINST_KEY} "Publisher" "LyX Team"
49   WriteRegStr SHCTX ${APP_UNINST_KEY} "HelpLink" "http://www.lyx.org/internet/mailing.php"
50   WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoModify" 0x00000001
51   WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoRepair" 0x00000001
52   WriteRegStr SHCTX ${APP_UNINST_KEY} "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
53   
54 SectionEnd
55
56 #--------------------------------
57 # Write LyX configuration file
58
59 Section -Configure
60
61   # Associate .lyx files with LyX for current user of all users
62
63   ${if} $CreateFileAssociations == "true"
64    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
65   ${endif}
66
67   # Write information about file type
68   #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
69   
70   ${if} $CreateFileAssociations == "true"
71    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
72    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
73    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
74    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
75    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
76    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
77    # .lyx13
78    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
79    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
80    # .lyx14
81    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
82    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
83    # .lyx15
84    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
85    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
86    # .lyx16 don't set this, because this is designed to be opened with LyX 1.6.x
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\Python\Lib;$$LyXDir\imagemagick"
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} $GhostscriptPath != ""
115    StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
116   ${endif}
117   ${if} $SVGPath != ""
118    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
119   ${endif}
120   ${if} $GnumericPath != ""
121    StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
122   ${endif}
123   ${if} $PathBibTeXEditor != ""
124     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
125   ${EndIf}
126   ${if} $LilyPondPath != ""
127    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
128   ${endif}
129   
130   # Set the path prefix in lyxrc.dist
131   ClearErrors
132   Delete "$INSTDIR\Resources\lyxrc.dist"
133   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
134   # set the format
135   FileWrite $R1 'Format 1$\r$\n'
136   # set some general things
137   FileWrite $R1 '\screen_zoom 120$\r$\n'
138   ${if} "$PathPrefix" != ""
139    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
140   ${endif}
141   ${if} $Acrobat == "Yes" # use pdfview for Acrobat / Adobe Reader
142    FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export"$\r$\n\
143                   \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export"$\r$\n\
144                   \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export"$\r$\n\
145                   \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export"$\r$\n\
146                   \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export"$\r$\n'
147   ${endif}
148   # if LilyPondPath was found
149   # we need to add these entris because python scripts can only be executed
150   # if the full path is given
151   ${if} $LilyPondPath != ""
152    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export"$\r$\n\
153                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
154                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
155                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
156                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
157   ${endif}
158   FileClose $R1
159   IfErrors 0 +2
160    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
161   ClearErrors
162
163 SectionEnd
164
165 #--------------------------------
166 # Postscript printer for metafile to EPS converter
167
168 Section -PSPrinter
169
170   ${if} $MultiUser.Privileges == "Admin"
171   ${orif} $MultiUser.Privileges == "Power"
172    # Delete printer
173    ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
174    # Install printer and driver
175    ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
176   ${else}
177    MessageBox MB_OK|MB_ICONINFORMATION "$(MetafileNotAvailable)"
178   ${endif}
179
180 SectionEnd
181
182 #--------------------------------
183 # Run the LyX configure.py script, so MiKTeX can download its packages
184
185 Var ConfigureReturn
186
187 Section -ConfigureScript
188
189   SetOutPath "$INSTDIR\Resources"
190   DetailPrint $(TEXT_CONFIGURE_LYX)
191   nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
192   Pop $ConfigureReturn # Return value
193
194   # ask to update MiKTeX
195   ${if} $LaTeXInstalled == "MiKTeX"
196    Call UpdateMiKTeX # function from latex.nsh
197    # for new installations a second run is necessary to give the users feedback about
198    # the ongoing installation of LaTeX packages
199    # a new installed MiKTeX needs some time until it is ready to install packages
200    !if ${SETUPTYPE} == BUNDLE
201     nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
202    !endif # end if == BUNDLE
203   ${endif}
204
205 SectionEnd
206
207 #--------------------------------
208 # Desktop shortcut
209
210 Function StartLyX
211
212   # run LyX in a command line window to give the users feedback about
213   # the time consuming LaTeX package installation
214   
215   #Exec 'cmd /K " "$INSTDIR\bin\lyx.exe""'
216   Exec "$INSTDIR\${APP_RUN}"
217
218 FunctionEnd
219
220 /*Function CheckDesktopShortcut
221
222   # Enable desktop icon creation when there is an icon already
223   # Old shortcuts need to be updated
224   
225   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
226     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
227   ${EndIf}
228
229 FunctionEnd
230
231 Function CreateDesktopShortcut
232
233   # Desktop icon creation is an option on the finish page
234   SetOutPath "$INSTDIR\bin"
235   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
236
237 FunctionEnd*/
238