summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/git.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/fetch2/git.py')
-rw-r--r--bitbake/lib/bb/fetch2/git.py66
1 files changed, 31 insertions, 35 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 07af02f061..c54d826a01 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -57,7 +57,13 @@ class Git(Fetch):
57 if 'nocheckout' in ud.parm: 57 if 'nocheckout' in ud.parm:
58 ud.nocheckout = True 58 ud.nocheckout = True
59 59
60 ud.branch = ud.parm.get("branch", "master") 60 branches = ud.parm.get("branch", "master").split(',')
61 if len(branches) != len(ud.names):
62 raise bb.fetch2.ParameterError("SRC_URI (%) name and branch number mismatch" % ud.url)
63 ud.branches = {}
64 for name in ud.names:
65 branch = branches[ud.names.index(name)]
66 ud.branches[name] = branch
61 67
62 gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.')) 68 gitsrcname = '%s%s' % (ud.host, ud.path.replace('/', '.'))
63 ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname) 69 ud.mirrortarball = 'git_%s.tar.gz' % (gitsrcname)
@@ -66,25 +72,18 @@ class Git(Fetch):
66 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git" 72 ud.basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
67 73
68 def localpath(self, url, ud, d): 74 def localpath(self, url, ud, d):
69 ud.tag = ud.revision 75 for name in ud.names:
70 if not ud.tag or ud.tag == "master": 76 if not ud.revisions[name] or ud.revisions[name] == "master":
71 ud.tag = self.latest_revision(url, ud, d) 77 ud.revisions[name] = self.latest_revision(url, ud, d, name)
72 78
73 ud.localfile = ud.mirrortarball 79 ud.localfile = ud.mirrortarball
74 80
75 if 'noclone' in ud.parm:
76 ud.localfile = None
77 return None
78
79 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) 81 return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile)
80 82
81 def forcefetch(self, url, ud, d): 83 def forcefetch(self, url, ud, d):
82 if 'fullclone' in ud.parm: 84 for name in ud.names:
83 return True 85 if not self._contains_ref(ud.revisions[name], d):
84 if 'noclone' in ud.parm: 86 return True
85 return False
86 if not self._contains_ref(ud.tag, d):
87 return True
88 return False 87 return False
89 88
90 def try_premirror(self, u, ud, d): 89 def try_premirror(self, u, ud, d):
@@ -122,18 +121,15 @@ class Git(Fetch):
122 121
123 os.chdir(ud.clonedir) 122 os.chdir(ud.clonedir)
124 # Update the checkout if needed 123 # Update the checkout if needed
125 if not self._contains_ref(ud.tag, d) or 'fullclone' in ud.parm: 124 for name in ud.names:
126 # Remove all but the .git directory 125 if not self._contains_ref(ud.revisions[name], d):
127 bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path)) 126 # Remove all but the .git directory
128 runfetchcmd("rm * -Rf", d) 127 bb.fetch2.check_network_access(d, "git fetch %s%s" %(ud.host, ud.path))
129 if 'fullclone' in ud.parm: 128 runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name]), d)
130 runfetchcmd("%s fetch --all" % (ud.basecmd), d) 129 runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d)
131 else: 130 runfetchcmd("%s prune-packed" % ud.basecmd, d)
132 runfetchcmd("%s fetch %s://%s%s%s %s" % (ud.basecmd, ud.proto, username, ud.host, ud.path, ud.branch), d) 131 runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
133 runfetchcmd("%s fetch --tags %s://%s%s%s" % (ud.basecmd, ud.proto, username, ud.host, ud.path), d) 132 ud.repochanged = True
134 runfetchcmd("%s prune-packed" % ud.basecmd, d)
135 runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d)
136 ud.repochanged = True
137 133
138 def build_mirror_data(self, url, ud, d): 134 def build_mirror_data(self, url, ud, d):
139 # Generate a mirror tarball if needed 135 # Generate a mirror tarball if needed
@@ -141,7 +137,7 @@ class Git(Fetch):
141 137
142 os.chdir(ud.clonedir) 138 os.chdir(ud.clonedir)
143 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True) 139 mirror_tarballs = data.getVar("BB_GENERATE_MIRROR_TARBALLS", d, True)
144 if (mirror_tarballs != "0" or 'fullclone' in ud.parm) and ud.repochanged: 140 if mirror_tarballs != "0" and ud.repochanged:
145 logger.info("Creating tarball of git repository") 141 logger.info("Creating tarball of git repository")
146 runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d) 142 runfetchcmd("tar -czf %s %s" % (repofile, os.path.join(".", ".git", "*") ), d)
147 143
@@ -165,7 +161,7 @@ class Git(Fetch):
165 runfetchcmd("cp -af %s/.git/packed-refs %s/.git/" %(ud.clonedir, destdir), d) 161 runfetchcmd("cp -af %s/.git/packed-refs %s/.git/" %(ud.clonedir, destdir), d)
166 if not ud.nocheckout: 162 if not ud.nocheckout:
167 os.chdir(destdir) 163 os.chdir(destdir)
168 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.tag, readpathspec), d) 164 runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d)
169 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d) 165 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
170 return True 166 return True
171 167
@@ -177,13 +173,13 @@ class Git(Fetch):
177 output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True) 173 output = runfetchcmd("%s log --pretty=oneline -n 1 %s -- 2> /dev/null | wc -l" % (basecmd, tag), d, quiet=True)
178 return output.split()[0] != "0" 174 return output.split()[0] != "0"
179 175
180 def _revision_key(self, url, ud, d): 176 def _revision_key(self, url, ud, d, name):
181 """ 177 """
182 Return a unique key for the url 178 Return a unique key for the url
183 """ 179 """
184 return "git:" + ud.host + ud.path.replace('/', '.') + ud.branch 180 return "git:" + ud.host + ud.path.replace('/', '.') + ud.branches[name]
185 181
186 def _latest_revision(self, url, ud, d): 182 def _latest_revision(self, url, ud, d, name):
187 """ 183 """
188 Compute the HEAD revision for the url 184 Compute the HEAD revision for the url
189 """ 185 """
@@ -192,16 +188,16 @@ class Git(Fetch):
192 else: 188 else:
193 username = "" 189 username = ""
194 190
195 bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branch)) 191 bb.fetch2.check_network_access(d, "git ls-remote %s%s %s" % (ud.host, ud.path, ud.branches[name]))
196 basecmd = data.getVar("FETCHCMD_git", d, True) or "git" 192 basecmd = data.getVar("FETCHCMD_git", d, True) or "git"
197 cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branch) 193 cmd = "%s ls-remote %s://%s%s%s %s" % (basecmd, ud.proto, username, ud.host, ud.path, ud.branches[name])
198 output = runfetchcmd(cmd, d, True) 194 output = runfetchcmd(cmd, d, True)
199 if not output: 195 if not output:
200 raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd)) 196 raise bb.fetch2.FetchError("Fetch command %s gave empty output\n" % (cmd))
201 return output.split()[0] 197 return output.split()[0]
202 198
203 def _build_revision(self, url, ud, d): 199 def _build_revision(self, url, ud, d, name):
204 return ud.tag 200 return ud.revisions[name]
205 201
206 def _sortable_buildindex_disabled(self, url, ud, d, rev): 202 def _sortable_buildindex_disabled(self, url, ud, d, rev):
207 """ 203 """