diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2010-01-20 18:46:02 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-01-20 18:46:02 +0000 |
commit | 22c29d8651668195f72e2f6a8e059d625eb511c3 (patch) | |
tree | dd1dd43f0ec47a9964c8a766eb8b3ad75cf51a64 /bitbake/lib/bb/fetch | |
parent | 1bfd6edef9db9c9175058ae801d1b601e4f15263 (diff) | |
download | openembedded-core-22c29d8651668195f72e2f6a8e059d625eb511c3.tar.gz openembedded-core-22c29d8651668195f72e2f6a8e059d625eb511c3.tar.bz2 openembedded-core-22c29d8651668195f72e2f6a8e059d625eb511c3.tar.xz openembedded-core-22c29d8651668195f72e2f6a8e059d625eb511c3.zip |
bitbake: Switch to bitbake-dev version (bitbake master upstream)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/fetch')
-rw-r--r-- | bitbake/lib/bb/fetch/__init__.py | 42 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/cvs.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/git.py | 73 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/local.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/svk.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch/wget.py | 2 |
6 files changed, 87 insertions, 38 deletions
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py index 7326ed0f4..ab4658bc3 100644 --- a/bitbake/lib/bb/fetch/__init__.py +++ b/bitbake/lib/bb/fetch/__init__.py @@ -99,6 +99,11 @@ def fetcher_init(d): pd.delDomain("BB_URI_HEADREVS") else: bb.msg.fatal(bb.msg.domain.Fetcher, "Invalid SRCREV cache policy of: %s" % srcrev_policy) + + for m in methods: + if hasattr(m, "init"): + m.init(d) + # Make sure our domains exist pd.addDomain("BB_URI_HEADREVS") pd.addDomain("BB_URI_LOCALCOUNT") @@ -467,6 +472,23 @@ class Fetch(object): srcrev_internal_helper = staticmethod(srcrev_internal_helper) + def localcount_internal_helper(ud, d): + """ + Return: + a) a locked localcount if specified + b) None otherwise + """ + + localcount= None + if 'name' in ud.parm: + pn = data.getVar("PN", d, 1) + localcount = data.getVar("LOCALCOUNT_" + ud.parm['name'], d, 1) + if not localcount: + localcount = data.getVar("LOCALCOUNT", d, 1) + return localcount + + localcount_internal_helper = staticmethod(localcount_internal_helper) + def try_mirror(d, tarfn): """ Try to use a mirrored version of the sources. We do this @@ -555,12 +577,7 @@ class Fetch(object): """ """ - has_sortable_valid = hasattr(self, "_sortable_revision_valid") - has_sortable = hasattr(self, "_sortable_revision") - - if has_sortable and not has_sortable_valid: - return self._sortable_revision(url, ud, d) - elif has_sortable and self._sortable_revision_valid(url, ud, d): + if hasattr(self, "_sortable_revision"): return self._sortable_revision(url, ud, d) pd = persist_data.PersistData(d) @@ -568,13 +585,24 @@ class Fetch(object): latest_rev = self._build_revision(url, ud, d) last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") - count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") + uselocalcount = bb.data.getVar("BB_LOCALCOUNT_OVERRIDE", d, True) or False + count = None + if uselocalcount: + count = Fetch.localcount_internal_helper(ud, d) + if count is None: + count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") if last_rev == latest_rev: return str(count + "+" + latest_rev) + buildindex_provided = hasattr(self, "_sortable_buildindex") + if buildindex_provided: + count = self._sortable_buildindex(url, ud, d, latest_rev) + if count is None: count = "0" + elif uselocalcount or buildindex_provided: + count = str(count) else: count = str(int(count) + 1) diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py index d8bd4eaf7..90a006500 100644 --- a/bitbake/lib/bb/fetch/cvs.py +++ b/bitbake/lib/bb/fetch/cvs.py @@ -41,7 +41,7 @@ class Cvs(Fetch): """ Check to see if a given url can be fetched with cvs. """ - return ud.type in ['cvs', 'pserver'] + return ud.type in ['cvs'] def localpath(self, url, ud, d): if not "module" in ud.parm: diff --git a/bitbake/lib/bb/fetch/git.py b/bitbake/lib/bb/fetch/git.py index 3016f0f00..0e68325db 100644 --- a/bitbake/lib/bb/fetch/git.py +++ b/bitbake/lib/bb/fetch/git.py @@ -28,6 +28,12 @@ from bb.fetch import runfetchcmd class Git(Fetch): """Class to fetch a module or modules from git repositories""" + def init(self, d): + # + # Only enable _sortable revision if the key is set + # + if bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True): + self._sortable_buildindex = self._sortable_buildindex_disabled def supports(self, url, ud, d): """ Check to see if a given url can be fetched with git. @@ -58,10 +64,18 @@ class Git(Fetch): if not ud.tag or ud.tag == "master": ud.tag = self.latest_revision(url, ud, d) + subdir = ud.parm.get("subpath", "") + if subdir != "": + if subdir.endswith("/"): + subdir = subdir[:-1] + subdirpath = os.path.join(ud.path, subdir); + else: + subdirpath = ud.path; + if 'fullclone' in ud.parm: ud.localfile = ud.mirrortarball else: - ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) + ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, subdirpath.replace('/', '.'), ud.tag), d) return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) @@ -111,10 +125,27 @@ class Git(Fetch): if os.path.exists(codir): bb.utils.prunedir(codir) + subdir = ud.parm.get("subpath", "") + if subdir != "": + if subdir.endswith("/"): + subdirbase = os.path.basename(subdir[:-1]) + else: + subdirbase = os.path.basename(subdir) + else: + subdirbase = "" + + if subdir != "": + readpathspec = ":%s" % (subdir) + codir = os.path.join(codir, "git") + coprefix = os.path.join(codir, subdirbase, "") + else: + readpathspec = "" + coprefix = os.path.join(codir, "git", "") + bb.mkdirhier(codir) os.chdir(ud.clonedir) - runfetchcmd("git read-tree %s" % (ud.tag), d) - runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (os.path.join(codir, "git", "")), d) + runfetchcmd("git read-tree %s%s" % (ud.tag, readpathspec), d) + runfetchcmd("git checkout-index -q -f --prefix=%s -a" % (coprefix), d) os.chdir(codir) bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") @@ -154,42 +185,32 @@ class Git(Fetch): def _build_revision(self, url, ud, d): return ud.tag - def _sortable_revision_valid(self, url, ud, d): - return bb.data.getVar("BB_GIT_CLONE_FOR_SRCREV", d, True) or False - - def _sortable_revision(self, url, ud, d): + def _sortable_buildindex_disabled(self, url, ud, d, rev): """ - This is only called when _sortable_revision_valid called true - - We will have to get the updated revision. + Return a suitable buildindex for the revision specified. This is done by counting revisions + using "git rev-list" which may or may not work in different circumstances. """ - key = "GIT_CACHED_REVISION-%s-%s" % (gitsrcname, ud.tag) - if bb.data.getVar(key, d): - return bb.data.getVar(key, d) - - - # Runtime warning on wrongly configured sources - if ud.tag == "1": - bb.msg.error(1, bb.msg.domain.Fetcher, "SRCREV is '1'. This indicates a configuration error of %s" % url) - return "0+1" - cwd = os.getcwd() # Check if we have the rev already + if not os.path.exists(ud.clonedir): print "no repo" self.go(None, ud, d) + if not os.path.exists(ud.clonedir): + bb.msg.error(bb.msg.domain.Fetcher, "GIT repository for %s doesn't exist in %s, cannot get sortable buildnumber, using old value" % (url, ud.clonedir)) + return None + os.chdir(ud.clonedir) - if not self._contains_ref(ud.tag, d): + if not self._contains_ref(rev, d): self.go(None, ud, d) - output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % ud.tag, d, quiet=True) + output = runfetchcmd("git rev-list %s -- 2> /dev/null | wc -l" % rev, d, quiet=True) os.chdir(cwd) - sortable_revision = "%s+%s" % (output.split()[0], ud.tag) - bb.data.setVar(key, sortable_revision, d) - return sortable_revision - + buildindex = "%s" % output.split()[0] + bb.msg.debug(1, bb.msg.domain.Fetcher, "GIT repository for %s in %s is returning %s revisions in rev-list before %s" % (url, repodir, buildindex, rev)) + return buildindex diff --git a/bitbake/lib/bb/fetch/local.py b/bitbake/lib/bb/fetch/local.py index 577774e59..f9bdf589c 100644 --- a/bitbake/lib/bb/fetch/local.py +++ b/bitbake/lib/bb/fetch/local.py @@ -33,9 +33,9 @@ from bb.fetch import Fetch class Local(Fetch): def supports(self, url, urldata, d): """ - Check to see if a given url can be fetched with cvs. + Check to see if a given url represents a local fetch. """ - return urldata.type in ['file','patch'] + return urldata.type in ['file'] def localpath(self, url, urldata, d): """ diff --git a/bitbake/lib/bb/fetch/svk.py b/bitbake/lib/bb/fetch/svk.py index 442f85804..120dad9d4 100644 --- a/bitbake/lib/bb/fetch/svk.py +++ b/bitbake/lib/bb/fetch/svk.py @@ -36,7 +36,7 @@ class Svk(Fetch): """Class to fetch a module or modules from svk repositories""" def supports(self, url, ud, d): """ - Check to see if a given url can be fetched with cvs. + Check to see if a given url can be fetched with svk. """ return ud.type in ['svk'] diff --git a/bitbake/lib/bb/fetch/wget.py b/bitbake/lib/bb/fetch/wget.py index a0dca9404..fd93c7ec4 100644 --- a/bitbake/lib/bb/fetch/wget.py +++ b/bitbake/lib/bb/fetch/wget.py @@ -36,7 +36,7 @@ class Wget(Fetch): """Class to fetch urls via 'wget'""" def supports(self, url, ud, d): """ - Check to see if a given url can be fetched with cvs. + Check to see if a given url can be fetched with wget. """ return ud.type in ['http','https','ftp'] |