summaryrefslogtreecommitdiff
path: root/bitbake/lib
diff options
context:
space:
mode:
authorSaul Wold <sgw@linux.intel.com>2011-02-09 14:30:29 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 23:49:25 +0000
commit14dea89521c0c648e8e543388096a6dcd6d4f2e0 (patch)
treeddb73f19d8eeaa659905968ee1de28b9750b5628 /bitbake/lib
parentf1bbea4ab0c41cf93cd1a2d0d4d05a4ad06a0728 (diff)
downloadopenembedded-core-14dea89521c0c648e8e543388096a6dcd6d4f2e0.tar.gz
openembedded-core-14dea89521c0c648e8e543388096a6dcd6d4f2e0.tar.bz2
openembedded-core-14dea89521c0c648e8e543388096a6dcd6d4f2e0.zip
fetch2: Correct the clean() mechanism for the fetcher2 code
This create a clean() method in each of the fetcher modules and correctly cleans the .done stamp file and lock files Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch/cvs.py11
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py34
-rw-r--r--bitbake/lib/bb/fetch2/cvs.py12
-rw-r--r--bitbake/lib/bb/fetch2/git.py6
-rw-r--r--bitbake/lib/bb/fetch2/local.py4
-rw-r--r--bitbake/lib/bb/fetch2/svn.py7
6 files changed, 74 insertions, 0 deletions
diff --git a/bitbake/lib/bb/fetch/cvs.py b/bitbake/lib/bb/fetch/cvs.py
index 0edb794b04..7d0ccf2134 100644
--- a/bitbake/lib/bb/fetch/cvs.py
+++ b/bitbake/lib/bb/fetch/cvs.py
@@ -170,3 +170,14 @@ class Cvs(Fetch):
except OSError:
pass
raise FetchError(ud.module)
+
+ def clean(self, ud, d):
+ """ clean the git directory """
+
+ pkg = data.expand('${PN}', d)
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+ pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg)
+ bb.utils.remove(pkgdir, True)
+ bb.utils.remove(ud.localpath)
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index ef9d75f3fe..1ec42717ff 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -491,6 +491,7 @@ class FetchData(object):
"""
def __init__(self, url, d):
# localpath is the location of a downloaded result. If not set, the file is local.
+ self.donestamp = None
self.localfile = ""
self.localpath = None
self.lockfile = None
@@ -717,6 +718,12 @@ class FetchMethod(object):
return
+ def clean(self, urldata, d):
+ """
+ Clean any existing full or partial download
+ """
+ bb.utils.remove(urldata.localpath)
+
def try_premirror(self, url, urldata, d):
"""
Should premirrors be used?
@@ -958,6 +965,33 @@ class Fetch(object):
if ud.lockfile:
bb.utils.unlockfile(lf)
+ def clean(self, urls = []):
+ """
+ Clean files that the fetcher gets or places
+ """
+
+ if len(urls) == 0:
+ urls = self.urls
+
+ for url in urls:
+ if url not in self.ud:
+ self.ud[url] = FetchData(url, d)
+ ud = self.ud[url]
+ ud.setup_localpath(self.d)
+
+ if not ud.localfile or self.localpath is None:
+ continue
+
+ if ud.lockfile:
+ lf = bb.utils.lockfile(ud.lockfile)
+
+ ud.method.clean(ud, self.d)
+ if ud.donestamp:
+ bb.utils.remove(ud.donestamp)
+
+ if ud.lockfile:
+ bb.utils.unlockfile(lf)
+
from . import cvs
from . import git
from . import local
diff --git a/bitbake/lib/bb/fetch2/cvs.py b/bitbake/lib/bb/fetch2/cvs.py
index 3cd28b1fd5..ae03daf236 100644
--- a/bitbake/lib/bb/fetch2/cvs.py
+++ b/bitbake/lib/bb/fetch2/cvs.py
@@ -167,3 +167,15 @@ class Cvs(FetchMethod):
runfetchcmd(cmd, d, cleanup = [ud.localpath])
+ def clean(self, ud, d):
+ """ Clean CVS Files and tarballs """
+
+ pkg = data.expand('${PN}', d)
+ localdata = data.createCopy(d)
+ data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata)
+ data.update_data(localdata)
+ pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg)
+
+ bb.utils.remove(pkgdir, True)
+ bb.utils.remove(ud.localpath)
+
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 6d99406777..6d82bdc88b 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -172,6 +172,12 @@ class Git(FetchMethod):
runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d)
return True
+ def clean(self, ud, d):
+ """ clean the git directory """
+
+ bb.utils.remove(ud.localpath, True)
+ bb.utils.remove(ud.fullmirror)
+
def supports_srcrev(self):
return True
diff --git a/bitbake/lib/bb/fetch2/local.py b/bitbake/lib/bb/fetch2/local.py
index d77d39375e..77a296ec67 100644
--- a/bitbake/lib/bb/fetch2/local.py
+++ b/bitbake/lib/bb/fetch2/local.py
@@ -74,3 +74,7 @@ class Local(FetchMethod):
if os.path.exists(urldata.localpath):
return True
return False
+
+ def clean(self, urldata, d):
+ return
+
diff --git a/bitbake/lib/bb/fetch2/svn.py b/bitbake/lib/bb/fetch2/svn.py
index 4ab643bcf7..d05dc02765 100644
--- a/bitbake/lib/bb/fetch2/svn.py
+++ b/bitbake/lib/bb/fetch2/svn.py
@@ -138,6 +138,13 @@ class Svn(FetchMethod):
# tar them up to a defined filename
runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.module), d, cleanup = [ud.localpath])
+ def clean(self, ud, d):
+ """ Clean SVN specific files and dirs """
+
+ bb.utils.remove(ud.localpath)
+ bb.utils.remove(ud.moddir, True)
+
+
def supports_srcrev(self):
return True