]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
installer: 2 fixes
[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   # if we install over an existing version, remove the old uninstaller information
55   ${if} $OldVersionNumber != ""
56    DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber"
57   ${endif}
58   
59 SectionEnd
60
61 #--------------------------------
62 # Write LyX configuration file
63
64 Section -Configure
65
66   # Associate .lyx files with LyX for current user of all users
67
68   ${if} $CreateFileAssociations == "true"
69    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
70   ${endif}
71
72   # Write information about file type
73   #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
74   
75   ${if} $CreateFileAssociations == "true"
76    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
77    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
78    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
79    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
80    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
81    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
82    # .lyx13
83    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
84    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
85    # .lyx14
86    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
87    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
88    # .lyx15
89    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
90    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
91    # .lyx16 don't set this, because this is designed to be opened with LyX 1.6.x
92   
93    # Refresh shell
94    ${RefreshShellIcons}
95   ${endif}
96   
97   # Set path prefix in lyxrc.dist
98
99   # Install standard lyxrc.dist file
100   #SetOutPath "$INSTDIR\Resources"
101   #File "${FILES_DEPS}\Resources\lyxrc.dist"
102
103   # create the path prefix
104   # $$ represents a literal $ in an NSIS string
105   StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\Python;$$LyXDir\Python\Lib;$$LyXDir\imagemagick"
106   
107   ${if} $PathLaTeX != ""
108     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
109   ${EndIf}
110   ${if} $PSVPath != ""
111     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
112   ${endif}
113   ${if} $EditorPath != ""
114     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
115   ${endif}
116   ${if} $ImageEditorPath != ""
117     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
118   ${endif}
119   ${if} $GhostscriptPath != ""
120    StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
121   ${endif}
122   ${if} $SVGPath != ""
123    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
124   ${endif}
125   ${if} $GnumericPath != ""
126    StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
127   ${endif}
128   ${if} $PathBibTeXEditor != ""
129     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
130   ${EndIf}
131   ${if} $LilyPondPath != ""
132    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
133   ${endif}
134   
135   # Set the path prefix in lyxrc.dist
136   ClearErrors
137   Delete "$INSTDIR\Resources\lyxrc.dist"
138   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
139   # set the format
140   FileWrite $R1 'Format 1$\r$\n'
141   # set some general things
142   FileWrite $R1 '\screen_zoom 120$\r$\n'
143   ${if} "$PathPrefix" != ""
144    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
145   ${endif}
146   
147   # use pdfview for all types of PDF files
148   FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export"$\r$\n\
149                  \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export"$\r$\n\
150                  \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export"$\r$\n\
151                  \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export"$\r$\n\
152                  \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export"$\r$\n'
153
154   # if LilyPondPath was found
155   # we need to add these entris because python scripts can only be executed
156   # if the full path is given
157   ${if} $LilyPondPath != ""
158    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export"$\r$\n\
159                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
160                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
161                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
162                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
163   ${endif}
164   FileClose $R1
165   IfErrors 0 +2
166    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
167   ClearErrors
168
169 SectionEnd
170
171 #--------------------------------
172 # Postscript printer for metafile to EPS converter
173
174 Section -PSPrinter
175
176   ${if} $MultiUser.Privileges == "Admin"
177   ${orif} $MultiUser.Privileges == "Power"
178    # Delete printer
179    ExecWait '$PrinterConf /q /dl /n "Metafile to EPS Converter"'
180    # Install printer and driver
181    ExecWait '$PrinterConf /if /f "$WINDIR\inf\ntprint.inf" /b "Metafile to EPS Converter" /r "FILE:" /m "MS Publisher Imagesetter"'
182   ${else}
183    MessageBox MB_OK|MB_ICONINFORMATION "$(MetafileNotAvailable)"
184   ${endif}
185
186 SectionEnd
187
188 #--------------------------------
189 # Run the LyX configure.py script, so MiKTeX can download its packages
190
191 Var ConfigureReturn
192
193 Section -ConfigureScript
194
195   SetOutPath "$INSTDIR\Resources"
196   DetailPrint $(TEXT_CONFIGURE_LYX)
197   nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
198   # $ConfigureReturn is "0" if successful, otherwise "1"
199   Pop $ConfigureReturn # Return value
200
201   # ask to update MiKTeX
202   ${if} $LaTeXInstalled == "MiKTeX"
203    Call UpdateMiKTeX # function from latex.nsh
204    # especially for new installations a second run is necessary to install all missing package
205    # the reason for this is unknown, most probably it is a timeout problem, because with a fast
206    # Internet connection one run is sometimes sufficient
207    # a new installed MiKTeX needs some time until it is ready to install packages
208    nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
209   ${endif}
210
211 SectionEnd
212
213 #--------------------------------
214 # Desktop shortcut
215
216 Function StartLyX
217
218   # run LyX in a command line window to give the users feedback about
219   # the time consuming LaTeX package installation
220   
221   #Exec 'cmd /K " "$INSTDIR\bin\lyx.exe""'
222   Exec "$INSTDIR\${APP_RUN}"
223
224 FunctionEnd
225
226 /*Function CheckDesktopShortcut
227
228   # Enable desktop icon creation when there is an icon already
229   # Old shortcuts need to be updated
230   
231   ${If} ${FileExists} "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk"
232     ${NSD_SetState} $mui.FinishPage.ShowReadme ${BST_CHECKED}
233   ${EndIf}
234
235 FunctionEnd
236
237 Function CreateDesktopShortcut
238
239   # Desktop icon creation is an option on the finish page
240   SetOutPath "$INSTDIR\bin"
241   CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
242
243 FunctionEnd*/
244