Debian Codegraph @

cmake/tribits/devtools_install/install-git.py

raw
1 #!/usr/bin/env python3
2
3 # @HEADER
4 # *****************************************************************************
5 # TriBITS: Tribal Build, Integrate, and Test System
6 #
7 # Copyright 2013-2016 NTESS and the TriBITS contributors.
8 # SPDX-License-Identifier: BSD-3-Clause
9 # *****************************************************************************
10 # @HEADER
11
12
13 #
14 # Defaults
15 #
16
17 gitBaseName = "git"
18 gitDefaultVersion = "2.6.4"
19 gitSupportedVersions = ["2.6.4"]
20 gitTarballVersions = {
21 "2.6.4" : "2.6.4",
22 }
23
24
25 #
26 # Script code
27 #
28
29
30 from InstallProgramDriver import *
31 from GeneralScriptSupport import *
32
33
34 class GitInstall:
35
36 def __init__(self):
37 self.dummy = None
38
39 #
40 # Called before even knowing the product version
41 #
42
43 def getScriptName(self):
44 return "install-git.py"
45
46 def getProductBaseName(self):
47 return gitBaseName
48
49 def getProductDefaultVersion(self):
50 return gitDefaultVersion
51
52 def getProductSupportedVersions(self):
53 return gitSupportedVersions
54
55 #
56 # Called after knowing the product version but before parsing the
57 # command-line.
58 #
59
60 def getProductName(self, version):
61 return gitBaseName+"-"+version
62
63 def getBaseDirName(self, version):
64 return gitBaseName+"-"+version+"-base"
65
66 def getExtraHelpStr(self, version):
67 return """
68 This script builds """+self.getProductName(version)+""" from source compiled with the
69 configured C compiler in your path. This also installs the git-subtree provided in the
70 contributed folder on install.
71
72 To also build and install the documentation, additionally, pass in:
73
74 --with-doc --with-info
75
76 (but note the extra packages that must be installed on the system).
77
78 For more details on installing from source and required system dependencies
79 before attempting this build, see:
80
81 https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
82
83 In particular, to build everything you will need to install the documentation
84 (--with-doc and --with-info), you will need to install the packages
85 'asciidoc', 'xmlto', and 'docbook2X'. Again, see the above webpage for
86 details (it is not 100% pretty).
87
88 NOTE: The assumed directory structure of the download source provided by the
89 command --download-cmnd=<download-cmnd> is:
90
91 git-<version>-base/
92 git-<full-version>.tar.gz
93 """
94
95 def injectExtraCmndLineOptions(self, clp, version):
96 setStdDownloadCmndOption(self, clp, version)
97 clp.add_option(
98 "--extra-configure-options", dest="extraConfigureOptions", type="string", \
99 default="", \
100 help="Extra options to add to the 'configure' command for "+self.getProductName(version)+"." \
101 +" Note: This does not override the hard-coded configure options." )
102 clp.add_option(
103 "--with-doc", dest="withDoc", action="store_true", default=False,
104 help="Build and install manpage documentation (requires asciidoc and xmlto)." )
105 clp.add_option(
106 "--with-info", dest="withInfo", action="store_true", default=False,
107 help="Build and install info documentation (requires docbook2x)." )
108
109 def echoExtraCmndLineOptions(self, inOptions):
110 cmndLine = ""
111 cmndLine += " --download-cmnd='"+inOptions.downloadCmnd+"' \\\n"
112 cmndLine += " --extra-configure-options='"+inOptions.extraConfigureOptions+"' \\\n"
113 return cmndLine
114
115 #
116 # Called after parsing the command-line
117 #
118
119 def setup(self, inOptions):
120 self.inOptions = inOptions
121 self.baseDir = os.getcwd()
122 self.gitBaseDir = self.baseDir+"/"+self.getBaseDirName(self.inOptions.version)
123 gitVersionFull = gitTarballVersions[self.inOptions.version]
124 self.gitTarball = "git-"+gitVersionFull+".tar.gz"
125 self.gitSrcDir = "git-"+gitVersionFull
126 self.gitSrcBuildDir = self.gitBaseDir+"/"+self.gitSrcDir
127 self.gitSubtreeSrcBuildDir = self.gitSrcBuildDir+"/contrib/subtree"
128 self.scriptBaseDir = getScriptBaseDir()
129
130 #
131 # Called after setup()
132 #
133
134 def doDownload(self):
135 removeDirIfExists(self.gitBaseDir, True)
136 echoRunSysCmnd(self.inOptions.downloadCmnd)
137
138 def doUntar(self):
139 # Find the full name of the source tarball
140 echoChDir(self.gitBaseDir)
141 echoRunSysCmnd("tar -xzf "+self.gitTarball)
142
143 def doConfigure(self):
144 echoChDir(self.gitSrcBuildDir)
145 echoRunSysCmnd("make configure")
146 echoRunSysCmnd(
147 "./configure "+\
148 " "+self.inOptions.extraConfigureOptions+\
149 " --prefix="+self.inOptions.installDir
150 )
151 # NOTE: Git appears to only allow an in-source build :-(
152
153 def doBuild(self):
154 echoChDir(self.gitSrcBuildDir)
155 echoRunSysCmnd("make "+getParallelOpt(self.inOptions, "-j")+\
156 self.inOptions.makeOptions+" all")
157 if self.inOptions.withDoc:
158 echoRunSysCmnd("make "+getParallelOpt(self.inOptions, "-j")+\
159 self.inOptions.makeOptions+" doc")
160 if self.inOptions.withInfo:
161 echoRunSysCmnd("make "+getParallelOpt(self.inOptions, "-j")+\
162 self.inOptions.makeOptions+" info")
163 # Build git-subtree to get ready to install
164 echoChDir(self.gitSubtreeSrcBuildDir)
165
166
167 def doInstall(self):
168 echoChDir(self.gitSrcBuildDir)
169 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install")
170 if self.inOptions.withDoc:
171 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install-doc")
172 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install-html")
173 if self.inOptions.withInfo:
174 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install-info")
175 # Install git-subtree and documentation
176 echoChDir(self.gitSubtreeSrcBuildDir)
177 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install")
178 if self.inOptions.withDoc:
179 echoRunSysCmnd("make "+self.inOptions.makeOptions+" install-doc")
180
181 def getFinalInstructions(self):
182 return """
183 To use the installed version of git-"""+self.inOptions.version+""" add the path:
184
185 """+self.inOptions.installDir+"""/bin
186
187 to your path and that should be it!
188 """
189
190 #
191 # Executable statements
192 #
193
194 gitInstaller = InstallProgramDriver(GitInstall())
195 gitInstaller.runDriver()