Lines Matching full:ud
126 def supports(self, ud, d): argument
130 return ud.type in ['git']
135 def urldata_init(self, ud, d): argument
140 if 'protocol' in ud.parm:
141 ud.proto = ud.parm['protocol']
142 elif not ud.host:
143 ud.proto = 'file'
145 ud.proto = "git"
146 if ud.host == "github.com" and ud.proto == "git":
149 ud.proto = "https"
150 …col which is no longer supported by github. Please change to ;protocol=https in the url." % ud.url)
152 if not ud.proto in ('git', 'file', 'ssh', 'http', 'https', 'rsync'):
153 raise bb.fetch2.ParameterError("Invalid protocol type", ud.url)
155 ud.nocheckout = ud.parm.get("nocheckout","0") == "1"
157 ud.rebaseable = ud.parm.get("rebaseable","0") == "1"
159 ud.nobranch = ud.parm.get("nobranch","0") == "1"
162 ud.usehead = ud.parm.get("usehead","0") == "1"
163 if ud.usehead:
164 if ud.proto != "file":
165 …erError("The usehead option is only for use with local ('protocol=file') git repositories", ud.url)
166 ud.nobranch = 1
169 ud.bareclone = ud.parm.get("bareclone","0") == "1"
170 if ud.bareclone:
171 ud.nocheckout = 1
173 ud.unresolvedrev = {}
174 branches = ud.parm.get("branch", "").split(',')
175 if branches == [""] and not ud.nobranch:
176 …epositories is uncertain and we will therefore soon require this is set in all git urls." % ud.url)
178 if len(branches) != len(ud.names):
179 … raise bb.fetch2.ParameterError("The number of name and branch parameters is not balanced", ud.url)
181 ud.noshared = d.getVar("BB_GIT_NOSHARED") == "1"
183 ud.cloneflags = "-n"
184 if not ud.noshared:
185 ud.cloneflags += " -s"
186 if ud.bareclone:
187 ud.cloneflags += " --mirror"
189 ud.shallow = d.getVar("BB_GIT_SHALLOW") == "1"
190 ud.shallow_extra_refs = (d.getVar("BB_GIT_SHALLOW_EXTRA_REFS") or "").split()
203 ud.shallow_depths = collections.defaultdict(lambda: depth_default)
206 ud.shallow_revs = []
207 ud.branches = {}
208 for pos, name in enumerate(ud.names):
210 ud.branches[name] = branch
211 ud.unresolvedrev[name] = branch
222 ud.shallow_depths[name] = shallow_depth
226 ud.shallow_revs.extend(revs.split())
228 ud.shallow_revs.extend(revs_default.split())
230 if (ud.shallow and
231 not ud.shallow_revs and
232 all(ud.shallow_depths[n] == 0 for n in ud.names)):
234 ud.shallow = False
236 if ud.usehead:
241 for name in ud.names:
242 ud.unresolvedrev[name] = 'HEAD'
244 …ud.basecmd = d.getVar("FETCHCMD_git") or "git -c core.fsyncobjectfiles=0 -c gc.autoDetach=false -c…
247 ud.write_tarballs = write_tarballs != "0" or ud.rebaseable
248 … ud.write_shallow_tarballs = (d.getVar("BB_GENERATE_SHALLOW_TARBALLS") or write_tarballs) != "0"
250 ud.setup_revisions(d)
252 for name in ud.names:
254 …if not ud.revisions[name] or len(ud.revisions[name]) != 40 or (False in [c in "abcdef0123456789" …
255 if ud.revisions[name]:
256 ud.unresolvedrev[name] = ud.revisions[name]
257 ud.revisions[name] = self.latest_revision(ud, d, name)
259 …gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').repl…
267 if ud.rebaseable:
268 for name in ud.names:
269 gitsrcname = gitsrcname + '_' + ud.revisions[name]
273 ud.clonedir = os.path.join(gitdir, gitsrcname)
274 ud.localfile = ud.clonedir
277 ud.fullmirror = os.path.join(dl_dir, mirrortarball)
278 ud.mirrortarballs = [mirrortarball]
279 if ud.shallow:
281 if ud.bareclone:
284 if ud.shallow_revs:
285 tarballname = "%s_%s" % (tarballname, "_".join(sorted(ud.shallow_revs)))
287 for name, revision in sorted(ud.revisions.items()):
288 tarballname = "%s_%s" % (tarballname, ud.revisions[name][:7])
289 depth = ud.shallow_depths[name]
294 if not ud.nobranch:
295 shallow_refs.extend(ud.branches.values())
296 if ud.shallow_extra_refs:
297 …shallow_refs.extend(r.replace('refs/heads/', '').replace('*', 'ALL') for r in ud.shallow_extra_ref…
302 ud.shallowtarball = '%sshallow_%s.tar.gz' % (fetcher, tarballname)
303 ud.fullshallow = os.path.join(dl_dir, ud.shallowtarball)
304 ud.mirrortarballs.insert(0, ud.shallowtarball)
306 def localpath(self, ud, d): argument
307 return ud.clonedir
309 def need_update(self, ud, d): argument
310 …return self.clonedir_need_update(ud, d) or self.shallow_tarball_need_update(ud) or self.tarball_ne…
312 def clonedir_need_update(self, ud, d): argument
313 if not os.path.exists(ud.clonedir):
315 if ud.shallow and ud.write_shallow_tarballs and self.clonedir_need_shallow_revs(ud, d):
317 for name in ud.names:
318 if not self._contains_ref(ud, d, name, ud.clonedir):
322 def clonedir_need_shallow_revs(self, ud, d): argument
323 for rev in ud.shallow_revs:
325 … runfetchcmd('%s rev-parse -q --verify %s' % (ud.basecmd, rev), d, quiet=True, workdir=ud.clonedir)
330 def shallow_tarball_need_update(self, ud): argument
331 return ud.shallow and ud.write_shallow_tarballs and not os.path.exists(ud.fullshallow)
333 def tarball_need_update(self, ud): argument
334 return ud.write_tarballs and not os.path.exists(ud.fullmirror)
336 def try_premirror(self, ud, d): argument
341 if os.path.exists(ud.clonedir):
345 def download(self, ud, d): argument
351 if ud.shallow and os.path.exists(ud.fullshallow) and self.need_update(ud, d):
352 ud.localpath = ud.fullshallow
354 elif os.path.exists(ud.fullmirror) and not os.path.exists(ud.clonedir):
355 bb.utils.mkdirhier(ud.clonedir)
356 runfetchcmd("tar -xzf %s" % ud.fullmirror, d, workdir=ud.clonedir)
358 repourl = self._get_repo_url(ud)
361 if not os.path.exists(ud.clonedir):
369 …d = "LANG=C %s clone --bare --mirror %s %s --progress" % (ud.basecmd, shlex.quote(repourl), ud.clo…
370 if ud.proto.lower() != 'file':
371 bb.fetch2.check_network_access(d, clone_cmd, ud.url)
376 if self.clonedir_need_update(ud, d):
377 output = runfetchcmd("%s remote" % ud.basecmd, d, quiet=True, workdir=ud.clonedir)
379 runfetchcmd("%s remote rm origin" % ud.basecmd, d, workdir=ud.clonedir)
381 …etchcmd("%s remote add --mirror=fetch origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=…
383 if ud.nobranch:
384 … fetch_cmd = "LANG=C %s fetch -f --progress %s refs/*:refs/*" % (ud.basecmd, shlex.quote(repourl))
386 …tch -f --progress %s refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*" % (ud.basecmd, shlex.quote…
387 if ud.proto.lower() != 'file':
388 bb.fetch2.check_network_access(d, fetch_cmd, ud.url)
390 runfetchcmd(fetch_cmd, d, log=progresshandler, workdir=ud.clonedir)
391 runfetchcmd("%s prune-packed" % ud.basecmd, d, workdir=ud.clonedir)
392 runfetchcmd("%s pack-refs --all" % ud.basecmd, d, workdir=ud.clonedir)
393 … runfetchcmd("%s pack-redundant --all | xargs -r rm" % ud.basecmd, d, workdir=ud.clonedir)
395 os.unlink(ud.fullmirror)
400 for name in ud.names:
401 if not self._contains_ref(ud, d, name, ud.clonedir):
402 …("Unable to find revision %s in branch %s even from upstream" % (ud.revisions[name], ud.branches[n…
404 if ud.shallow and ud.write_shallow_tarballs:
405 missing_rev = self.clonedir_need_shallow_revs(ud, d)
409 if self._contains_lfs(ud, d, ud.clonedir) and self._need_lfs(ud):
419 Git.unpack(self, ud, tmpdir, d)
426 # result in a gradual accumulation of LFS blobs in <ud.clonedir>/lfs
434 … runfetchcmd("tar -cf - lfs | tar -xf - -C %s" % ud.clonedir, d, workdir="%s/git/.git" % tmpdir)
438 def build_mirror_data(self, ud, d): argument
453 if ud.shallow and ud.write_shallow_tarballs:
454 if not os.path.exists(ud.fullshallow):
455 if os.path.islink(ud.fullshallow):
456 os.unlink(ud.fullshallow)
460 self.clone_shallow_local(ud, shallowclone, d)
463 with create_atomic(ud.fullshallow) as tfile:
465 runfetchcmd("touch %s.done" % ud.fullshallow, d)
468 elif ud.write_tarballs and not os.path.exists(ud.fullmirror):
469 if os.path.islink(ud.fullmirror):
470 os.unlink(ud.fullmirror)
473 with create_atomic(ud.fullmirror) as tfile:
475 quiet=True, workdir=ud.clonedir)
477 % (tfile, mtime), d, workdir=ud.clonedir)
478 runfetchcmd("touch %s.done" % ud.fullmirror, d)
480 def clone_shallow_local(self, ud, dest, d): argument
485 runfetchcmd("%s clone %s %s %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, dest), d)
488 for name in ud.names:
489 revision = ud.revisions[name]
490 depth = ud.shallow_depths[name]
497 branch = ud.branches[name]
498 if ud.nobranch:
500 elif ud.bareclone:
506 runfetchcmd("%s update-ref %s %s" % (ud.basecmd, ref, revision), d, workdir=dest)
509 … parsed_depths = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join(to_parse)), d, workdir=dest)
512 …parsed_revs = runfetchcmd("%s rev-parse %s" % (ud.basecmd, " ".join('"%s^{}"' % r for r in ud.shal…
516 all_refs = runfetchcmd('%s for-each-ref "--format=%%(refname)"' % ud.basecmd,
518 for r in ud.shallow_extra_refs:
519 if not ud.bareclone:
536 def unpack(self, ud, destdir, d): argument
539 subdir = ud.parm.get("subdir")
540 subpath = ud.parm.get("subpath")
552 …e bb.fetch2.UnpackError("subdir argument isn't a subdirectory of unpack root %s" % destdir, ud.url)
558 destsuffix = ud.parm.get("destsuffix", def_destsuffix)
559 destdir = ud.destdir = os.path.join(destdir, destsuffix)
563 need_lfs = self._need_lfs(ud)
566 ud.basecmd = "GIT_LFS_SKIP_SMUDGE=1 " + ud.basecmd
572 clonedir_is_up_to_date = not self.clonedir_need_update(ud, d)
574 … runfetchcmd("%s clone %s %s/ %s" % (ud.basecmd, ud.cloneflags, ud.clonedir, destdir), d)
577 … source_error.append("clone directory not available or not up to date: " + ud.clonedir)
580 if ud.shallow:
581 if os.path.exists(ud.fullshallow):
583 runfetchcmd("tar -xzf %s" % ud.fullshallow, d, workdir=destdir)
586 source_error.append("shallow clone not available: " + ud.fullshallow)
591 … raise bb.fetch2.UnpackError("No up to date source found: " + "; ".join(source_error), ud.url)
593 repourl = self._get_repo_url(ud)
594 …runfetchcmd("%s remote set-url origin %s" % (ud.basecmd, shlex.quote(repourl)), d, workdir=destdir)
596 if self._contains_lfs(ud, d, destdir):
602 if not ud.nocheckout:
604 … runfetchcmd("%s read-tree %s%s" % (ud.basecmd, ud.revisions[ud.names[0]], readpathspec), d,
606 runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d, workdir=destdir)
607 elif not ud.nobranch:
608 branchname = ud.branches[ud.names[0]]
609 runfetchcmd("%s checkout -B %s %s" % (ud.basecmd, branchname, \
610 ud.revisions[ud.names[0]]), d, workdir=destdir)
611 runfetchcmd("%s branch %s --set-upstream-to origin/%s" % (ud.basecmd, branchname, \
614 … runfetchcmd("%s checkout %s" % (ud.basecmd, ud.revisions[ud.names[0]]), d, workdir=destdir)
618 def clean(self, ud, d): argument
621 to_remove = [ud.localpath, ud.fullmirror, ud.fullmirror + ".done"]
624 if os.path.islink(ud.localpath):
625 clonedir = os.path.realpath(ud.localpath)
636 def _contains_ref(self, ud, d, name, wd): argument
638 if ud.nobranch:
640 ud.basecmd, ud.revisions[name])
643 ud.basecmd, ud.revisions[name], ud.branches[name])
652 def _need_lfs(self, ud): argument
653 return ud.parm.get("lfs", "1") == "1"
655 def _contains_lfs(self, ud, d, wd): argument
660 if not ud.nobranch:
661 branchname = ud.branches[ud.names[0]]
666 if wd == ud.clonedir:
667 refname = ud.branches[ud.names[0]]
669 refname = "origin/%s" % ud.branches[ud.names[0]]
672 ud.basecmd, refname)
689 def _get_repo_url(self, ud): argument
698 if ud.user:
699 username = ud.user + '@'
702 return "%s://%s%s%s" % (ud.proto, username, ud.host, ud.path)
704 def _revision_key(self, ud, d, name): argument
710 return "git:" + ud.host + slash_re.sub(".", ud.path) + ud.unresolvedrev[name]
712 def _lsremote(self, ud, d, search): argument
726 repourl = self._get_repo_url(ud)
728 (ud.basecmd, shlex.quote(repourl), search)
729 if ud.proto.lower() != 'file':
733 … raise bb.fetch2.FetchError("The command %s gave empty output unexpectedly" % cmd, ud.url)
738 def _latest_revision(self, ud, d, name): argument
743 … call bb.fetch2.get_srcrev() (use SRCPV in PV for OE)." % (ud.unresolvedrev[name], ud.host+ud.path…
748 output = self._lsremote(ud, d, "")
750 if ud.unresolvedrev[name][:5] == "refs/" or ud.usehead:
751 head = ud.unresolvedrev[name]
752 tag = ud.unresolvedrev[name]
754 head = "refs/heads/%s" % ud.unresolvedrev[name]
755 tag = "refs/tags/%s" % ud.unresolvedrev[name]
762 (ud.unresolvedrev[name], ud.host+ud.path))
764 def latest_versionstring(self, ud, d): argument
774 output = self._lsremote(ud, d, "refs/tags/*")
808 def _build_revision(self, ud, d, name): argument
809 return ud.revisions[name]
811 def gitpkgv_revision(self, ud, d, name): argument
816 rev = self._build_revision(ud, d, name)
817 localpath = ud.localpath
836 def checkstatus(self, fetch, ud, d): argument
838 self._lsremote(ud, d, "")