]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
Consider inset strings in simple find/replaceAll (#12049)
[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   ReadRegStr $0 SHCTX ${APP_REGFOLDER} "latestVersion"
20   ${If} $0 < ${APP_SERIES_KEY}
21     WriteRegStr SHCTX ${APP_REGFOLDER} "latestVersion" ${APP_SERIES_KEY}
22   ${EndIf}
23   WriteRegStr SHCTX ${APP_REGKEY} "" $INSTDIR
24   WriteRegStr SHCTX ${APP_REGKEY} "Version" "${APP_VERSION_NUMBER}"
25   WriteRegStr SHCTX ${APP_REGKEY_SETUP} "LaTeX Path" $PathLaTeX
26   
27   # Start Menu shortcut
28   SetOutPath "$INSTDIR\bin" # this is the folder in which the shortcut is executed
29   # we must assure that the folder is not empty (happens on silent install and can accidentally happen)
30   ${if} $StartmenuFolder == ""
31    StrCpy $StartmenuFolder "${APP_DIR}"
32   ${endif}
33   CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
34   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${APP_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
35   # Link to www.lyx.org and to the Wiki
36   WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WEBPAGE_INFO}.url" "InternetShortcut" "URL" "${APP_WEBPAGE}"
37   WriteINIStr "$SMPROGRAMS\$StartmenuFolder\${APP_WIKI_INFO}.url" "InternetShortcut" "URL" "${APP_WIKI}"
38   # create desktop icon
39   ${if} $CreateDesktopIcon == "true"
40    SetOutPath "$INSTDIR\bin"
41    CreateShortCut "$DESKTOP\${APP_NAME} ${APP_SERIES_NAME}.lnk" "$INSTDIR\${APP_RUN}" "" "$INSTDIR\${APP_RUN}" "" "" "" "${APP_INFO}"
42   ${endif}
43   
44   # Uninstaller information
45   ${If} $MultiUser.InstallMode == "CurrentUser"
46     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION} $(TEXT_INSTALL_CURRENTUSER)"
47   ${Else}
48     WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayName" "${APP_NAME} ${APP_VERSION}"
49   ${EndIf}
50   
51   WriteRegStr SHCTX ${APP_UNINST_KEY} "UninstallString" '"$INSTDIR\${SETUP_UNINSTALLER}"'
52   WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayVersion" "${APP_VERSION}"
53   WriteRegStr SHCTX ${APP_UNINST_KEY} "DisplayIcon" "$INSTDIR\bin\${APP_NAME_SMALL}.exe"
54   WriteRegStr SHCTX ${APP_UNINST_KEY} "URLUpdateInfo" "${APP_WEBPAGE}"
55   WriteRegStr SHCTX ${APP_UNINST_KEY} "URLInfoAbout" "https://www.lyx.org/AboutLyX"
56   WriteRegStr SHCTX ${APP_UNINST_KEY} "Publisher" "${APP_NAME} Team"
57   WriteRegStr SHCTX ${APP_UNINST_KEY} "HelpLink" "https://www.lyx.org/MailingLists"
58   WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoModify" 0x00000001
59   WriteRegDWORD SHCTX ${APP_UNINST_KEY} "NoRepair" 0x00000001
60   WriteRegStr SHCTX ${APP_UNINST_KEY} "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
61   # if we install over an older existing version, remove the old uninstaller information
62   ${if} $OldVersionNumber != ""
63   ${AndIf} $OldVersionNumber < ${APP_SERIES_KEY}
64    DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber"
65    DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}\$OldVersionNumber"
66    # also delete in the case of an emergency release
67    ${For} $7 0 20
68     DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber$7"
69     DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}\$OldVersionNumber$7"
70    ${Next}
71   ${endif}
72 SectionEnd
73
74 #--------------------------------
75 # Write LyX configuration file
76
77 Section -Configure
78
79   # Associate .lyx files with LyX for current user or all users
80
81   ${if} $CreateFileAssociations == "true"
82    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
83   ${endif}
84
85   # Write information about file type
86   #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
87   
88   ${if} $CreateFileAssociations == "true"
89    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
90    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
91    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
92    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
93    # we need to update also the automatically created entry about the lyx.exe
94    # otherwise .lyx-files will could be opened with an older LyX version
95    ReadRegStr $0 SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" ""
96    ${if} $0 != "" # if something was found
97     WriteRegStr SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
98    ${endif}
99    # .lyx
100    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
101    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
102    # .lyx13
103    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
104    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
105    # .lyx14
106    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
107    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
108    # .lyx15
109    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
110    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
111    # .lyx16
112    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "" "${APP_REGNAME_DOC}"
113    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "Content Type" "${APP_MIME_TYPE}"
114    # .lyx20
115    WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "" "${APP_REGNAME_DOC}"
116    WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "Content Type" "${APP_MIME_TYPE}"
117    # .lyx21
118    WriteRegStr SHCTX "Software\Classes\${APP_EXT}21" "" "${APP_REGNAME_DOC}"
119    WriteRegStr SHCTX "Software\Classes\${APP_EXT}21" "Content Type" "${APP_MIME_TYPE}"
120    # .lyx22 don't set this, because this is designed to be opened with LyX 2.2.x
121   
122    # Refresh shell
123    ${RefreshShellIcons}
124   ${endif}
125   
126   # Install standard lyxrc.dist file
127   #SetOutPath "$INSTDIR\Resources"
128   #File "${FILES_DEPS}\Resources\lyxrc.dist"
129
130   # create the path prefix
131   # $$ represents a literal $ in an NSIS string
132   StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\Python;$$LyXDir\Python\Lib;$$LyXDir\Perl\bin;$$LyXDir\imagemagick"
133   
134   ${if} $PathLaTeX != ""
135     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
136   ${EndIf}
137   ${if} $PSVPath != ""
138     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
139   ${endif}
140   ${if} $EditorPath != ""
141     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
142   ${endif}
143   ${if} $ImageEditorPath != ""
144     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
145   ${endif}
146   ${if} $GhostscriptPath != ""
147    StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
148   ${endif}
149   ${if} $SVGPath != ""
150    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
151   ${endif}
152   ${if} $GnumericPath != ""
153    StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
154   ${endif}
155   ${if} $PathBibTeXEditor != ""
156     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
157   ${EndIf}
158   ${if} $PandocPath != ""
159    StrCpy $PathPrefix "$PathPrefix;$PandocPath"
160   ${endif}
161   ${if} $LilyPondPath != ""
162    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
163   ${endif}
164   
165   # Set the path prefix in lyxrc.dist
166   ClearErrors
167   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" a
168   FileSeek $R1 0 END
169   # set some general things
170   FileWrite $R1 '\screen_zoom 120$\r$\n'
171   ${if} "$PathPrefix" != ""
172    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
173   ${endif}
174   
175   # use pdfview for all types of PDF files
176   FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
177                  \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
178                  \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
179                  \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
180                  \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n'
181   
182   # use Inkscape to edit PDF and EPS images
183   ${if} $SVGPath != ""
184    FileWrite $R1 '\format "pdf6" "pdf" "PDF (graphics)" "" "auto" "inkscape" "vector" "application/pdf"$\r$\n\
185                                   \format "eps" "eps" "EPS" "" "auto" "inkscape" "vector" "image/x-eps"$\r$\n'
186   ${endif}
187   
188   # set image editors
189   ${if} $ImageEditor == "Gimp"
190    FileWrite $R1 '\format "gif" "gif" "GIF" "" "auto" "gimp-2.8" "" "image/gif"$\r$\n\
191                                   \format "jpg" "jpg, jpeg" "JPEG" "" "auto" "gimp-2.8" "" "image/jpeg"$\r$\n\
192                                   \format "png" "png" "PNG" "" "auto" "gimp-2.8" "" "image/x-png"'
193   ${endif}
194   ${if} $ImageEditor == "Krita"
195    FileWrite $R1 '\format "gif" "gif" "GIF" "" "auto" "krita" "" "image/gif"$\r$\n\
196                                   \format "jpg" "jpg, jpeg" "JPEG" "" "auto" "krita" "" "image/jpeg"$\r$\n\
197                                   \format "png" "png" "PNG" "" "auto" "krita" "" "image/x-png"'
198   ${endif}
199   
200   # if Inkscape is not available Imagemagick will be used to convert WMF/EMF files
201   # We need to specify a resolution for the converter otherwise 1024 dpi are used and
202   # eps2pdf takes ages. 300 dpi are a good compromise for speed and size.
203   ${if} $SVGPath == ""
204    FileWrite $R1 '\converter "wmf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n\
205          \converter "emf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n'
206   ${endif}
207   
208   # if LilyPondPath was found
209   # We need to add these entries because python scripts can only be executed
210   # if the full path is given.
211   ${if} $LilyPondPath != ""
212    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export" ""$\r$\n\
213                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
214                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
215                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
216                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
217   ${endif}
218   FileClose $R1
219   IfErrors 0 +2
220    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)" /SD IDOK
221   ClearErrors
222   
223   # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
224   ${if} $LaTeXInstalled != "TeXLive"
225     ${if} $MultiUser.Privileges != "Admin"
226     ${andif} $MultiUser.Privileges != "Power"
227     # call the non-admin version
228     ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\Perl\bin"
229     ${else}
230     ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\Perl\bin"
231     ${endif}
232   ${endif}
233
234 SectionEnd
235
236 #--------------------------------
237 # Run the LyX configure.py script, so MiKTeX can download its packages
238
239 Var ConfigureReturn
240
241 Section -ConfigureScript
242
243   DetailPrint $(TEXT_CONFIGURE_LYX)
244   SetShellVarContext current
245   SetOutPath "$APPDATA\${APP_DIR_USERDATA}"
246   nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
247   # $ConfigureReturn is "0" if successful, otherwise "1"
248   Pop $ConfigureReturn # Return value
249
250 SectionEnd
251
252 #--------------------------------
253 #
254
255 #Function StartLyX
256
257   # run LyX in a command line window to give the users feedback about
258   # the time consuming LaTeX package installation
259   
260 #  Exec "$INSTDIR\${APP_RUN}"
261
262 #FunctionEnd