]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/configure.nsh
Win installer: fix registry issue
[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   # 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\${APP_NAME_SMALL}.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    DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}$OldVersionNumber"
62    # also delete in the case of an emergency release
63    DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}$OldVersionNumber1"
64    DeleteRegKey SHCTX "SOFTWARE\${APP_NAME}$OldVersionNumber1"
65   ${endif}
66   
67 SectionEnd
68
69 #--------------------------------
70 # Write LyX configuration file
71
72 Section -Configure
73
74   # Associate .lyx files with LyX for current user or all users
75
76   ${if} $CreateFileAssociations == "true"
77    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "" "$INSTDIR\${APP_RUN}"
78   ${endif}
79
80   # Write information about file type
81   #!define REG_FILETYPE 'WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}"'
82   
83   ${if} $CreateFileAssociations == "true"
84    WriteRegStr SHCTX "${APP_DIR_REGKEY}" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
85    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}" "" "${APP_NAME} Document"
86    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\DefaultIcon" "" "$INSTDIR\${APP_RUN},0"
87    WriteRegStr SHCTX "Software\Classes\${APP_REGNAME_DOC}\Shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
88    # we need to update also the automatically created entry about the lyx.exe
89    # otherwise .lyx-files will could be opened with an older LyX version
90    ReadRegStr $0 SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" ""
91    ${if} $0 != "" # if something was found
92     WriteRegStr SHCTX "Software\Classes\Applications\${BIN_LYX}\shell\open\command" "" '"$INSTDIR\${APP_RUN}" "%1"'
93    ${endif}
94    # .lyx
95    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "" "${APP_REGNAME_DOC}"
96    WriteRegStr SHCTX "Software\Classes\${APP_EXT}" "Content Type" "${APP_MIME_TYPE}"
97    # .lyx13
98    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "" "${APP_REGNAME_DOC}"
99    WriteRegStr SHCTX "Software\Classes\${APP_EXT}13" "Content Type" "${APP_MIME_TYPE}"
100    # .lyx14
101    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "" "${APP_REGNAME_DOC}"
102    WriteRegStr SHCTX "Software\Classes\${APP_EXT}14" "Content Type" "${APP_MIME_TYPE}"
103    # .lyx15
104    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "" "${APP_REGNAME_DOC}"
105    WriteRegStr SHCTX "Software\Classes\${APP_EXT}15" "Content Type" "${APP_MIME_TYPE}"
106    # .lyx16
107    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "" "${APP_REGNAME_DOC}"
108    WriteRegStr SHCTX "Software\Classes\${APP_EXT}16" "Content Type" "${APP_MIME_TYPE}"
109    # .lyx20
110    WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "" "${APP_REGNAME_DOC}"
111    WriteRegStr SHCTX "Software\Classes\${APP_EXT}20" "Content Type" "${APP_MIME_TYPE}"
112    # .lyx21
113    WriteRegStr SHCTX "Software\Classes\${APP_EXT}21" "" "${APP_REGNAME_DOC}"
114    WriteRegStr SHCTX "Software\Classes\${APP_EXT}21" "Content Type" "${APP_MIME_TYPE}"
115    # .lyx22 don't set this, because this is designed to be opened with LyX 2.2.x
116   
117    # Refresh shell
118    ${RefreshShellIcons}
119   ${endif}
120   
121   # Install standard lyxrc.dist file
122   #SetOutPath "$INSTDIR\Resources"
123   #File "${FILES_DEPS}\Resources\lyxrc.dist"
124
125   # create the path prefix
126   # $$ represents a literal $ in an NSIS string
127   StrCpy $PathPrefix "$$LyXDir\bin;$$LyXDir\Python;$$LyXDir\Python\Lib;$$LyXDir\Perl\bin;$$LyXDir\imagemagick"
128   
129   ${if} $PathLaTeX != ""
130     StrCpy $PathPrefix "$PathPrefix;$PathLaTeX"
131   ${EndIf}
132   ${if} $PSVPath != ""
133     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
134   ${endif}
135   ${if} $EditorPath != ""
136     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
137   ${endif}
138   ${if} $ImageEditorPath != ""
139     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
140   ${endif}
141   ${if} $GhostscriptPath != ""
142    StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
143   ${endif}
144   ${if} $SVGPath != ""
145    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
146   ${endif}
147   ${if} $GnumericPath != ""
148    StrCpy $PathPrefix "$PathPrefix;$GnumericPath"
149   ${endif}
150   ${if} $PathBibTeXEditor != ""
151     StrCpy $PathPrefix "$PathPrefix;$PathBibTeXEditor"
152   ${EndIf}
153   ${if} $PandocPath != ""
154    StrCpy $PathPrefix "$PathPrefix;$PandocPath"
155   ${endif}
156   ${if} $LilyPondPath != ""
157    StrCpy $PathPrefix "$PathPrefix;$LilyPondPath"
158   ${endif}
159   
160   # Set the path prefix in lyxrc.dist
161   ClearErrors
162   Delete "$INSTDIR\Resources\lyxrc.dist"
163   FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
164   # set the format to the latest LyXRC format
165   FileWrite $R1 'Format 24$\r$\n'
166   # set some general things
167   FileWrite $R1 '\screen_zoom 120$\r$\n'
168   ${if} "$PathPrefix" != ""
169    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
170   ${endif}
171   
172   # use pdfview for all types of PDF files
173   FileWrite $R1 '\format "pdf5" "pdf" "PDF (LuaTeX)" "u" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
174                  \format "pdf4" "pdf" "PDF (XeTeX)" "X" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
175                  \format "pdf3" "pdf" "PDF (dvipdfm)" "m" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
176                  \format "pdf2" "pdf" "PDF (pdflatex)" "F" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n\
177                  \format "pdf" "pdf" "PDF (ps2pdf)" "P" "pdfview" "" "document,vector,menu=export" "application/pdf"$\r$\n'
178   
179   # use Inkscape to edit PDF and EPS images
180   ${if} $SVGPath != ""
181    FileWrite $R1 '\format "pdf6" "pdf" "PDF (graphics)" "" "auto" "inkscape" "vector" "application/pdf"$\r$\n\
182                                   \format "eps" "eps" "EPS" "" "auto" "inkscape" "vector" "image/x-eps"$\r$\n'
183   ${endif}
184   
185   # set image editors
186   ${if} $ImageEditor == "Gimp"
187    FileWrite $R1 '\format "gif" "gif" "GIF" "" "auto" "gimp-2.8" "" "image/gif"$\r$\n\
188                                   \format "jpg" "jpg, jpeg" "JPEG" "" "auto" "gimp-2.8" "" "image/jpeg"$\r$\n\
189                                   \format "png" "png" "PNG" "" "auto" "gimp-2.8" "" "image/x-png"'
190   ${endif}
191   ${if} $ImageEditor == "Krita"
192    FileWrite $R1 '\format "gif" "gif" "GIF" "" "auto" "krita" "" "image/gif"$\r$\n\
193                                   \format "jpg" "jpg, jpeg" "JPEG" "" "auto" "krita" "" "image/jpeg"$\r$\n\
194                                   \format "png" "png" "PNG" "" "auto" "krita" "" "image/x-png"'
195   ${endif}
196   
197   # if Inkscape is not available Imagemagick will be used to convert WMF/EMF files
198   # We need to specify a resolution for the converter otherwise 1024 dpi are used and
199   # eps2pdf takes ages. 300 dpi are a good compromise for speed and size.
200   ${if} $SVGPath == ""
201    FileWrite $R1 '\converter "wmf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n\
202          \converter "emf" "eps" "convert -density 300 $$$$i $$$$o" ""$\r$\n'
203   ${endif}
204   
205   # if LilyPondPath was found
206   # We need to add these entries because python scripts can only be executed
207   # if the full path is given.
208   ${if} $LilyPondPath != ""
209    FileWrite $R1 '\format "lilypond-book" "lytex" "LilyPond book (LaTeX)" "" "" "auto" "document,menu=export" ""$\r$\n\
210                   \converter "lilypond-book" "pdflatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=pdflatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
211                   \converter "lilypond-book" "xetex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=xelatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
212                   \converter "lilypond-book" "luatex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --pdf --latex-program=lualatex --lily-output-dir=ly-pdf $$$$i" ""$\r$\n\
213                   \converter "lilypond-book" "latex" "python \"$LilyPondPath\\lilypond-book.py\" --safe --lily-output-dir=ly-eps $$$$i" ""$\r$\n'
214   ${endif}
215   FileClose $R1
216   IfErrors 0 +2
217    MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)" /SD IDOK
218   ClearErrors
219   
220   # for texindy the path to the perl.exe must unfortunately be in Windows' PATH variable
221   ${if} $MultiUser.Privileges != "Admin"
222   ${andif} $MultiUser.Privileges != "Power"
223    # call the non-admin version
224    ${EnvVarUpdate} $0 "PATH" "A" "HKCU" "$INSTDIR\Perl\bin"
225   ${else}
226    ${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\Perl\bin"
227   ${endif}
228
229 SectionEnd
230
231 #--------------------------------
232 # Run the LyX configure.py script, so MiKTeX can download its packages
233
234 Var ConfigureReturn
235
236 Section -ConfigureScript
237
238   DetailPrint $(TEXT_CONFIGURE_LYX)
239   nsExec::ExecToLog '"$INSTDIR\Python\python.exe" "$INSTDIR\Resources\configure.py"'
240   # $ConfigureReturn is "0" if successful, otherwise "1"
241   Pop $ConfigureReturn # Return value
242
243 SectionEnd
244
245 #--------------------------------
246 #
247
248 Function StartLyX
249
250   # run LyX in a command line window to give the users feedback about
251   # the time consuming LaTeX package installation
252   
253   Exec "$INSTDIR\${APP_RUN}"
254
255 FunctionEnd