]> git.lyx.org Git - features.git/blob - development/Win32/packaging/installer/setup/install.nsh
15bc2758548d39f755c98333c486415571d93174
[features.git] / development / Win32 / packaging / installer / setup / install.nsh
1 /*
2
3 install.nsh
4
5 Installation of program files, dictionaries and external components
6
7 */
8
9 #--------------------------------
10 # Program files
11
12 Var PythonCompileFile
13 Var PythonCompileReturn
14
15 Section -ProgramFiles SecProgramFiles
16
17   # if the $INSTDIR does not contain "LyX" we must add a subfolder to avoid that LyX will e.g.
18   # be installed directly to C:\programs - the uninstaller will then delete the whole
19   # C:\programs directory
20   StrCpy $String $INSTDIR
21   StrCpy $Search "LyX"
22   Call StrPoint # function from LyXUtils.nsh
23   ${if} $Pointer == "-1"
24    StrCpy $INSTDIR "$INSTDIR\${APP_DIR}"
25   ${endif}
26
27  !if ${SETUPTYPE} != BUNDLE
28   # abort the installation if no LaTeX was found but should be used
29   ${if} $PathLaTeX == ""
30   ${andif} $State == "0"
31    SetOutPath $TEMP # to be able to delete the $INSTDIR
32    RMDir /r $INSTDIR
33    Abort
34   ${endif}
35  !endif # end if != BUNDLE
36
37   # Install and register the core LyX files
38   
39   # The macros are defined in filelists.nsh
40   # the parameters are COMMAND DIRECTORY that form command '${COMMAND} "${DIRECTORY}files"  
41   
42   # Initializes the plug-ins dir ($PLUGINSDIR) if not already initialized.
43   # $PLUGINSDIR is automatically deleted when the installer exits.
44   InitPluginsDir
45   
46   # Binaries
47   SetOutPath "$INSTDIR\bin"
48   !insertmacro FileListLyXBin File "${FILES_LYX}\bin\"
49   !insertmacro FileListQtBin File "${FILES_QT}\bin\"
50   !insertmacro FileListMSVC File "${FILES_MSVC}\"
51   !insertmacro FileListNetpbmBin File "${FILES_NETPBM}\"
52   !insertmacro FileListDTLBin File "${FILES_DTL}\"
53   !insertmacro FileListRsvg File "${FILES_RSVG}\"
54   !insertmacro FileListDvipostBin File "${FILES_DVIPOST}\"
55   !insertmacro FileListPDFViewBin File "${FILES_PDFVIEW}\"
56   
57   # Qt plugin DLLs
58   SetOutPath "$INSTDIR\bin\imageformats"
59   !insertmacro FileListQtImageformats File "${FILES_QT}\plugins\imageformats\"
60   SetOutPath "$INSTDIR\bin\iconengines"
61   !insertmacro FileListQtIconengines File "${FILES_QT}\plugins\iconengines\"
62   SetOutPath "$INSTDIR\bin\platforms"
63   !insertmacro FileListQtPlatforms File "${FILES_QT}\plugins\platforms\"
64   
65   # Resources
66   SetOutPath "$INSTDIR"
67   # recursively copy all files under Resources
68   File /r "${FILES_LYX}\Resources"
69   
70   !if ${SETUPTYPE} == BUNDLE
71    
72    # extract the MiKTeX installer
73    File /r "${FILES_LYX}\external"
74
75    # install MiKTeX if not already installed
76    Call InstallMiKTeX # function from LaTeX.nsh
77    
78   !endif # end if BUNDLE
79   
80   # Python
81   SetOutPath "$INSTDIR"
82   # recursively copy all files under Python
83   File /r "${FILES_PYTHON}"
84   # register .py files if necessary
85   ReadRegStr $0 SHCTX "Software\Classes\Python.File\shell\open\command" ""
86   ${if} $0 == "" # if nothing was found
87    WriteRegStr SHCTX "Software\Classes\Python.File\shell\open\command" "" '"$INSTDIR\Python\python.exe" "%1" %*'
88    WriteRegStr SHCTX "Software\Classes\Python.File\DefaultIcon" "" "$INSTDIR\Python\DLLs\py.ico"
89    WriteRegStr SHCTX "Software\Classes\.py" "" "Python.File"
90    WriteRegStr SHCTX "Software\Classes\Python.File" "OnlyWithLyX" "Yes${APP_SERIES_KEY}" # special entry to test if they were registered by this LyX version
91   ${endif}
92   
93   # Compile all Pyton files to byte-code
94   # The user using the scripts may not have write access
95   FileOpen $PythonCompileFile "$INSTDIR\compilepy.py" w
96   FileWrite $PythonCompileFile "import compileall$\r$\n"
97   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\python\Lib')$\r$\n"
98   FileWrite $PythonCompileFile "compileall.compile_dir('$INSTDIR\Resources')$\r$\n"
99   FileClose $PythonCompileFile
100   DetailPrint $(TEXT_CONFIGURE_PYTHON)
101   nsExec::ExecToLog '"$INSTDIR\python\python.exe" "$INSTDIR\compilepy.py"'
102   Pop $PythonCompileReturn # Return value
103   Delete "$INSTDIR\compilepy.py"
104   
105   # Components of ImageMagick
106   SetOutPath "$INSTDIR\imagemagick"
107   File /r "${FILES_IMAGEMAGICK}\"
108   !insertmacro FileListMSVC File "${FILES_MSVC}\"
109   # register ImageMagick
110   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "BinPath" "$INSTDIR\imagemagick"
111   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
112   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "ConfigurePath" "$INSTDIR\imagemagick"
113   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
114   WriteRegStr SHCTX "SOFTWARE\ImageMagick\${ImageMagickVersion}\Q:16" "LibPath" "$INSTDIR\imagemagick"
115   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "BinPath" "$INSTDIR\imagemagick"
116   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "CoderModulesPath" "$INSTDIR\imagemagick\modules\coders"
117   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "ConfigurePath" "$INSTDIR\imagemagick"
118   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "FilterModulesPath" "$INSTDIR\imagemagick\modules\filters"
119   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "LibPath" "$INSTDIR\imagemagick"
120   WriteRegDWORD SHCTX "SOFTWARE\ImageMagick\Current" "QuantumDepth" 0x00000010
121   WriteRegStr SHCTX "SOFTWARE\ImageMagick\Current" "Version" "${ImageMagickVersion}"
122   WriteRegStr SHCTX "SOFTWARE\ImageMagick" "OnlyWithLyX" "Yes${APP_SERIES_KEY}"
123   
124   # Components of Ghostscript
125   ${if} $GhostscriptPath == ""
126    SetOutPath "$INSTDIR\ghostscript"
127    File /r "${FILES_GHOSTSCRIPT}\"
128    !insertmacro FileListMSVC File "${FILES_MSVC}\"
129    StrCpy $GhostscriptPath "$INSTDIR\ghostscript\bin"
130   ${endif}
131   
132   # install eLyXer
133   SetOutPath "$INSTDIR\Python\Lib"
134   !insertmacro FileListeLyXer File "${FILES_ELYXER}\"
135    
136   # install unoconv
137   SetOutPath "$INSTDIR\Python\Lib"
138   !insertmacro FileListUnoConv File "${FILES_UNOCONV}\"
139
140   # install the LaTeX class files that are delivered with LyX to MiKTeX
141   # and enable MiKTeX's automatic package installation
142   ${if} $LaTeXInstalled == "MiKTeX"
143    Call ConfigureMiKTeX # Function from LaTeX.nsh
144   ${endif}
145   # install the LaTeX class files that are delivered with LyX to TeXLive
146   ${if} $LaTeXInstalled == "TeXLive"
147    Call ConfigureTeXLive # Function from LaTeX.nsh
148   ${endif}
149   
150   # download dictionaries and thesaurus
151   ${if} $DictCodes != ""
152    Call InstallHunspellDictionaries # Function from dictionaries.nsh
153   ${endif}
154   ${if} $ThesCodes != ""
155    Call InstallThesaurusDictionaries # Function from dictionaries.nsh
156   ${endif}
157   # finally delete the list of mirrors
158   Delete "$INSTDIR\Resources\DictionaryMirrors.txt"
159   
160   # Create uninstaller
161   WriteUninstaller "$INSTDIR\${SETUP_UNINSTALLER}"
162
163 SectionEnd