diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2007-08-02 23:52:40 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2007-08-02 23:52:40 +0000 |
commit | befeeef96230980a170a0de329fe9ea4af2d3ce5 (patch) | |
tree | ba93dbc120e8dc895ca05c041c33c73e5b6987d8 /lib/bb/fetch | |
parent | 9aa602e50df18b4b91631f4357a54dcde3a487d9 (diff) | |
download | bitbake-befeeef96230980a170a0de329fe9ea4af2d3ce5.tar.gz |
fetcher updates: Add SRCREV support to git, fix svn SRCREV lockdown support, clean up fetcher force options, finish sortable_revision implementation
Diffstat (limited to 'lib/bb/fetch')
-rw-r--r-- | lib/bb/fetch/__init__.py | 27 | ||||
-rw-r--r-- | lib/bb/fetch/git.py | 35 | ||||
-rw-r--r-- | lib/bb/fetch/perforce.py | 2 | ||||
-rw-r--r-- | lib/bb/fetch/svn.py | 13 |
4 files changed, 55 insertions, 22 deletions
diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py index 8d4c7e59b..6ebf5a34a 100644 --- a/lib/bb/fetch/__init__.py +++ b/lib/bb/fetch/__init__.py @@ -256,7 +256,6 @@ class FetchData(object): (self.type, self.host, self.path, self.user, self.pswd, self.parm) = bb.decodeurl(data.expand(url, d)) self.date = Fetch.getSRCDate(self, d) self.url = url - self.force = False def init(self, method, d): self.method = method @@ -401,7 +400,7 @@ class Fetch(object): """ Look in the cache for the latest revision, if not present ask the SCM. """ - if not self._latest_revision: + if not hasattr(self, "_latest_revision"): raise ParameterError pd = persist_data.PersistData(d) @@ -418,10 +417,28 @@ class Fetch(object): """ """ - if not self._sortable_revision: - raise ParameterError + if hasattr(self, "_sortable_revision"): + return self._sortable_revision(url, ud, d) + + pd = persist_data.PersistData(d) + key = self._revision_key(url, ud, d) + latest_rev = self.latest_revision(url, ud, d) + last_rev = pd.getValue("BB_URI_LOCALCOUNT", key + "_rev") + count = pd.getValue("BB_URI_LOCALCOUNT", key + "_count") + + if last_rev == latest_rev: + return str(count + "+" + latest_rev) + + if count is None: + count = "0" + else: + count = str(int(count) + 1) + + pd.setValue("BB_URI_LOCALCOUNT", key + "_rev", latest_rev) + pd.setValue("BB_URI_LOCALCOUNT", key + "_count", count) + + return str(count + "+" + latest_rev) - return self._sortable_revision(url, ud, d) import cvs import git diff --git a/lib/bb/fetch/git.py b/lib/bb/fetch/git.py index 891fe1474..138c0a158 100644 --- a/lib/bb/fetch/git.py +++ b/lib/bb/fetch/git.py @@ -50,25 +50,22 @@ class Git(Fetch): if 'protocol' in ud.parm: ud.proto = ud.parm['protocol'] - ud.tag = "master" + tag = data.getVar("SRCREV", d, 0) if 'tag' in ud.parm: ud.tag = ud.parm['tag'] - # FIXME, set tag to latest revision so local filestash works + elif tag and "get_srcrev" not in tag and len(tag) == 40: + ud.tag = tag + else: + ud.tag = self.latest_revision(url, ud, d) ud.localfile = data.expand('git_%s%s_%s.tar.gz' % (ud.host, ud.path.replace('/', '.'), ud.tag), d) return os.path.join(data.getVar("DL_DIR", d, True), ud.localfile) - def forcefetch(self, url, ud, d): - # tag=="master" must always update - if (ud.tag == "master"): - return True - return False - def go(self, loc, ud, d): """Fetch url""" - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): + if Fetch.try_mirror(d, ud.localfile): bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists (or was stashed). Skipping git checkout." % ud.localpath) return @@ -90,12 +87,12 @@ class Git(Fetch): runfetchcmd("git clone -n %s://%s%s %s" % (ud.proto, ud.host, ud.path, repodir), d) os.chdir(repodir) + # Remove all but the .git directory + runfetchcmd("rm * -Rf", d) runfetchcmd("git pull %s://%s%s" % (ud.proto, ud.host, ud.path), d) runfetchcmd("git pull --tags %s://%s%s" % (ud.proto, ud.host, ud.path), d) runfetchcmd("git prune-packed", d) runfetchcmd("git pack-redundant --all | xargs -r rm", d) - # Remove all but the .git directory - runfetchcmd("rm * -Rf", d) # old method of downloading tags #runfetchcmd("rsync -a --verbose --stats --progress rsync://%s%s/ %s" % (ud.host, ud.path, os.path.join(repodir, ".git", "")), d) @@ -115,8 +112,20 @@ class Git(Fetch): bb.msg.note(1, bb.msg.domain.Fetcher, "Creating tarball of git checkout") runfetchcmd("tar -czf %s %s" % (ud.localpath, os.path.join(".", "*") ), d) - def latest_revision(self, url, ud, d): + os.chdir(repodir) + prunedir(codir) + + def suppports_srcrev(self): + return True + + def _revision_key(self, url, ud, d): + """ + Return a unique key for the url + """ + return "git:" + ud.host + ud.path.replace('/', '.') + + def _latest_revision(self, url, ud, d): - output = rungitcmd("git ls-remote %s://%s%s %s" % (ud.proto, ud.host, ud.path, ud.tag), d, True) + output = runfetchcmd("git ls-remote %s://%s%s %s" % (ud.proto, ud.host, ud.path, ud.tag), d, True) return output.split()[0] diff --git a/lib/bb/fetch/perforce.py b/lib/bb/fetch/perforce.py index 125eb99aa..97b618228 100644 --- a/lib/bb/fetch/perforce.py +++ b/lib/bb/fetch/perforce.py @@ -125,7 +125,7 @@ class Perforce(Fetch): """ # try to use the tarball stash - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): + if Fetch.try_mirror(d, ud.localfile): bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping perforce checkout." % ud.localpath) return diff --git a/lib/bb/fetch/svn.py b/lib/bb/fetch/svn.py index e16ec4ba7..ca12efe15 100644 --- a/lib/bb/fetch/svn.py +++ b/lib/bb/fetch/svn.py @@ -62,15 +62,22 @@ class Svn(Fetch): ud.revision = "" else: # - # ***Nasty hack*** + # ***Nasty hacks*** # If DATE in unexpanded PV, use ud.date (which is set from SRCDATE) # Will warn people to switch to SRCREV here # + # How can we tell when a user has overriden SRCDATE? + # check for "get_srcdate" in unexpanded SRCREV - ugly + # pv = data.getVar("PV", d, 0) if "DATE" in pv: ud.revision = "" else: - ud.revision = self.latest_revision(url, ud, d) + rev = data.getVar("SRCREV", d, 0) + if "get_srcrev" in rev: + ud.revision = self.latest_revision(url, ud, d) + else: + ud.revision = rev ud.date = "" ud.localfile = data.expand('%s_%s_%s_%s_%s.tar.gz' % (ud.module.replace('/', '.'), ud.host, ud.path.replace('/', '.'), ud.revision, ud.date), d) @@ -128,7 +135,7 @@ class Svn(Fetch): """Fetch url""" # try to use the tarball stash - if not self.forcefetch(loc, ud, d) and Fetch.try_mirror(d, ud.localfile): + if Fetch.try_mirror(d, ud.localfile): bb.msg.debug(1, bb.msg.domain.Fetcher, "%s already exists or was mirrored, skipping svn checkout." % ud.localpath) return |