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