]> git.lyx.org Git - lyx.git/blob - development/Win32/packaging/AltInstaller/ConfigLyX.nsh
installer updates
[lyx.git] / development / Win32 / packaging / AltInstaller / ConfigLyX.nsh
1 Function ConfigureLyX
2  # configures LyX
3
4   # create the PathPrefix
5   StrCpy $PathPrefix "$INSTDIR\bin"
6   ${if} $PythonPath != ""
7     StrCpy $PathPrefix "$PathPrefix;$PythonPath"
8   ${endif}
9   ${if} $LatexPath != ""
10     StrCpy $PathPrefix "$PathPrefix;$LatexPath"
11   ${endif}
12   ${if} $GhostscriptPath != ""
13     StrCpy $PathPrefix "$PathPrefix;$GhostscriptPath"
14   ${endif}
15   ${if} $ImageMagickPath != ""
16     StrCpy $PathPrefix "$PathPrefix;$ImageMagickPath"
17   ${endif}
18   ${if} $PSVPath != ""
19     StrCpy $PathPrefix "$PathPrefix;$PSVPath"
20   ${endif}
21   ${if} $EditorPath != ""
22     StrCpy $PathPrefix "$PathPrefix;$EditorPath"
23   ${endif}
24   ${if} $ImageEditorPath != ""
25     StrCpy $PathPrefix "$PathPrefix;$ImageEditorPath"
26   ${endif}
27   ${if} $SVGPath != ""
28    StrCpy $PathPrefix "$PathPrefix;$SVGPath"
29   ${endif}
30   
31   # Set a path prefix in lyxrc.dist
32   ClearErrors
33   ${if} "$PathPrefix" != ""
34    Delete "$INSTDIR\Resources\lyxrc.dist"
35    FileOpen $R1 "$INSTDIR\Resources\lyxrc.dist" w
36    FileWrite $R1 '\path_prefix "$PathPrefix"$\r$\n'
37    FileClose $R1
38    IfErrors 0 +2
39     MessageBox MB_OK|MB_ICONEXCLAMATION "$(ModifyingConfigureFailed)"
40   ${endif}
41
42   # Create a batch file to start LyX with the environment variables set
43   ClearErrors
44   Delete "${PRODUCT_BAT}"
45   FileOpen $R1 "${PRODUCT_BAT}" w
46   FileWrite $R1 '@echo off$\r$\n\
47                  SET LANG=$LangCode$\r$\n\
48                  SET AIK_DATA_DIR=${AiksaurusDir}$\r$\n\
49                  start "${PRODUCT_NAME}" "${LAUNCHER_EXE}" %*$\r$\n'
50   FileClose $R1
51   IfErrors 0 +2
52    MessageBox MB_OK|MB_ICONEXCLAMATION "$(CreateCmdFilesFailed)"
53
54   # set up the preferences file
55   # if Acrobat or Adobe Reader is used
56   ${if} $Acrobat == "Yes" # used for Acrobat / Adobe Reader
57     # writes settings to the preferences file
58     ${LineFind} "$INSTDIR\Resources\preferences" "$INSTDIR\Resources\preferences" "75" "AcroPref"
59     # ${LineFind} macro from TextFunc.nsh # calls Function AcroPref
60   ${endif}
61   
62   # if a SVG to PDF converter ws found (e.g. Inkscape) define it in the preferences
63   ${if} $SVGPath != ""
64    ${if} $Acrobat == "Yes"
65     # writes settings to the preferences file
66     ${LineFind} "$INSTDIR\Resources\preferences" "$INSTDIR\Resources\preferences" "78" "SVGPref1"
67     # deletes lines from the preferences file
68     ${LineFind} "$INSTDIR\Resources\preferences" "$INSTDIR\Resources\preferences" "87:90" "SVGPref2"
69    ${else}
70     # writes settings to the preferences file but 3 lines earlier because the
71     #3 PDF lines are in this case not here
72     ${LineFind} "$INSTDIR\Resources\preferences" "$INSTDIR\Resources\preferences" "75" "SVGPref1"
73     ${LineFind} "$INSTDIR\Resources\preferences" "$INSTDIR\Resources\preferences" "84:87" "SVGPref2"
74    ${endif}
75   ${endif} 
76   
77   # register LyX
78   ${if} $CreateFileAssociations == "true"
79    WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "${PRODUCT_EXE}"
80   ${endif}
81   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "RootKey" "$ProductRootKey"
82   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayName" "${PRODUCT_NAME} ${PRODUCT_VERSION}"
83   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "UninstallString" "${PRODUCT_UNINSTALL_EXE}"
84   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayIcon" "${PRODUCT_EXE}"
85   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
86   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "StartMenu" "$SMPROGRAMS\$StartmenuFolder"
87   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLUpdateInfo" "${PRODUCT_INFO_URL}"
88   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_ABOUT_URL}"
89   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "Publisher" "LyX Team"
90   WriteRegStr SHCTX "${PRODUCT_UNINST_KEY}" "HelpLink" "${PRODUCT_HELP_LINK}"
91   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoModify" 0x00000001
92   WriteRegDWORD SHCTX "${PRODUCT_UNINST_KEY}" "NoRepair" 0x00000001
93
94   # create start menu entry
95   SetOutPath "$INSTDIR\bin"
96   CreateDirectory "$SMPROGRAMS\$StartmenuFolder"
97   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\${PRODUCT_NAME}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
98   SetOutPath "$INSTDIR"
99   CreateShortCut "$SMPROGRAMS\$StartmenuFolder\Uninstall.lnk" "${PRODUCT_UNINSTALL_EXE}"
100
101   # create desktop icon
102   ${if} $CreateDesktopIcon == "true"
103    SetOutPath "$INSTDIR\bin"
104    CreateShortCut "$DESKTOP\LyX ${PRODUCT_VERSION}.lnk" "${PRODUCT_BAT}" "" "${PRODUCT_EXE}"
105   ${endif}
106
107   # register the extension .lyx
108   ${if} $CreateFileAssociations == "true"
109    # write informations about file type
110    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}" "" "${PRODUCT_NAME} Document"
111    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\DefaultIcon" "" "${PRODUCT_EXE}"
112    WriteRegStr SHCTX "Software\Classes\${PRODUCT_REGNAME}\Shell\open\command" "" '"${PRODUCT_BAT}" "%1"'
113    # write informations about file extensions
114    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "" "${PRODUCT_REGNAME}"
115    WriteRegStr SHCTX "Software\Classes\${PRODUCT_EXT}" "Content Type" "${PRODUCT_MIME_TYPE}"  
116    # refresh shell
117    System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) (${SHCNE_ASSOCCHANGED}, ${SHCNF_IDLIST}, 0, 0)'
118   ${endif}
119
120   # create the LyX Application Data folder for all users
121   # this folder is automatically created by LyX when it is first started but we want to start LyX with a specific session file,
122   # so we create this folder before LyX starts and copy there the session file
123   Call CreateAppPathSub # function from LyXUtils.nsh
124   
125   # delete unnecessary files
126   ${if} $DelPythonFiles == "True"
127    Delete $INSTDIR\bin\python.exe
128    Delete $INSTDIR\bin\python25.dll
129    Delete $INSTDIR\bin\Python-License.txt
130    RMDir /r $INSTDIR\bin\Lib
131    RMDir /r $INSTDIR\bin\DLLs
132   ${endif}
133   RMDir /r $INSTDIR\external
134
135   # create a bat-file to start configure in a console window so that the user see the progress
136   # of the configuration and to have a signal when the configuration is ready to start LyX
137   # this is important when LyX is installed together with MiKTeX or when LyX is installed for the first
138   # time on a computer, because the installation of missing LaTeX-files required by LyX could last minutes
139   # a batch file is needed because simply calling
140   # ExecWait '"$PythonPath\python.exe" "$INSTDIR\Resources\configure.py"'
141   # creates the config files in $PythonPath
142   ${if} $PythonPath == ""
143    StrCpy $PythonPath "$INSTDIR\bin"
144   ${endif}
145   StrCpy $1 $INSTDIR 2 # get drive letter
146   FileOpen $R1 "$INSTDIR\Resources\configLyX.bat" w
147   FileWrite $R1 '$1$\r$\n\
148                  cd $INSTDIR\Resources\$\r$\n\
149                  "$PythonPath\python.exe" configure.py'
150   FileClose $R1
151
152 FunctionEnd
153
154 # --------------------------------
155
156 Function AcroPref
157  # writes PDF settings  to the preferences file
158
159   FileWrite $R4 '\format "pdf3" "pdf" "PDF (dvipdfm)" "m" "PDFViewWin" "" "document,vector"$\r$\n\
160                  \format "pdf2" "pdf" "PDF (pdflatex)" "F" "PDFViewWin" "" "document,vector"$\r$\n\
161                  \format "pdf" "pdf" "PDF (ps2pdf)" "P" "PDFViewWin" "" "document,vector"$\r$\n'
162   Push $0
163   
164 FunctionEnd
165
166 # --------------------------------
167
168 Function SVGPref1
169  # writes SVG settings to the preferences file
170   
171   FileWrite $R4 '\format "svg" "svg" "SVG" "" "inkscape --file=$$$$i" "inkscape --file=$$$$i" "vector"$\r$\n\
172                  $\r$\n\
173                  #$\r$\n\
174                  # CONVERTERS SECTION ##########################$\r$\n\
175                  #$\r$\n\
176                  $\r$\n\
177                  \converter "svg" "png" "inkscape --without-gui --file=$$$$i --export-png=$$$$o" ""$\r$\n\
178                  \converter "svg" "pdf" "inkscape --file=$$$$i --export-area-drawing --without-gui --export-pdf=$$$$o" ""$\r$\n\
179                  \converter "svg" "pdf2" "inkscape --file=$$$$i --export-area-drawing --without-gui --export-pdf=$$$$o" ""'
180   Push $0
181   
182 FunctionEnd
183
184 Function SVGPref2
185  # deletes lines from the preferences file
186   
187   StrCpy $0 SkipWrite
188   Push $0
189   
190 FunctionEnd
191