diff options
author | Saul Wold <sgw@linux.intel.com> | 2011-02-09 14:30:29 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-10 23:49:25 +0000 |
commit | 14dea89521c0c648e8e543388096a6dcd6d4f2e0 (patch) | |
tree | ddb73f19d8eeaa659905968ee1de28b9750b5628 /bitbake/lib/bb/fetch2 | |
parent | f1bbea4ab0c41cf93cd1a2d0d4d05a4ad06a0728 (diff) | |
download | poky-14dea89521c0c648e8e543388096a6dcd6d4f2e0.tar.gz |
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/bb/fetch2')
-rw-r--r-- | bitbake/lib/bb/fetch2/__init__.py | 34 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/cvs.py | 12 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/local.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/fetch2/svn.py | 7 |
5 files changed, 63 insertions, 0 deletions
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): | |||
491 | """ | 491 | """ |
492 | def __init__(self, url, d): | 492 | def __init__(self, url, d): |
493 | # localpath is the location of a downloaded result. If not set, the file is local. | 493 | # localpath is the location of a downloaded result. If not set, the file is local. |
494 | self.donestamp = None | ||
494 | self.localfile = "" | 495 | self.localfile = "" |
495 | self.localpath = None | 496 | self.localpath = None |
496 | self.lockfile = None | 497 | self.lockfile = None |
@@ -717,6 +718,12 @@ class FetchMethod(object): | |||
717 | 718 | ||
718 | return | 719 | return |
719 | 720 | ||
721 | def clean(self, urldata, d): | ||
722 | """ | ||
723 | Clean any existing full or partial download | ||
724 | """ | ||
725 | bb.utils.remove(urldata.localpath) | ||
726 | |||
720 | def try_premirror(self, url, urldata, d): | 727 | def try_premirror(self, url, urldata, d): |
721 | """ | 728 | """ |
722 | Should premirrors be used? | 729 | Should premirrors be used? |
@@ -958,6 +965,33 @@ class Fetch(object): | |||
958 | if ud.lockfile: | 965 | if ud.lockfile: |
959 | bb.utils.unlockfile(lf) | 966 | bb.utils.unlockfile(lf) |
960 | 967 | ||
968 | def clean(self, urls = []): | ||
969 | """ | ||
970 | Clean files that the fetcher gets or places | ||
971 | """ | ||
972 | |||
973 | if len(urls) == 0: | ||
974 | urls = self.urls | ||
975 | |||
976 | for url in urls: | ||
977 | if url not in self.ud: | ||
978 | self.ud[url] = FetchData(url, d) | ||
979 | ud = self.ud[url] | ||
980 | ud.setup_localpath(self.d) | ||
981 | |||
982 | if not ud.localfile or self.localpath is None: | ||
983 | continue | ||
984 | |||
985 | if ud.lockfile: | ||
986 | lf = bb.utils.lockfile(ud.lockfile) | ||
987 | |||
988 | ud.method.clean(ud, self.d) | ||
989 | if ud.donestamp: | ||
990 | bb.utils.remove(ud.donestamp) | ||
991 | |||
992 | if ud.lockfile: | ||
993 | bb.utils.unlockfile(lf) | ||
994 | |||
961 | from . import cvs | 995 | from . import cvs |
962 | from . import git | 996 | from . import git |
963 | from . import local | 997 | 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): | |||
167 | 167 | ||
168 | runfetchcmd(cmd, d, cleanup = [ud.localpath]) | 168 | runfetchcmd(cmd, d, cleanup = [ud.localpath]) |
169 | 169 | ||
170 | def clean(self, ud, d): | ||
171 | """ Clean CVS Files and tarballs """ | ||
172 | |||
173 | pkg = data.expand('${PN}', d) | ||
174 | localdata = data.createCopy(d) | ||
175 | data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata) | ||
176 | data.update_data(localdata) | ||
177 | pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg) | ||
178 | |||
179 | bb.utils.remove(pkgdir, True) | ||
180 | bb.utils.remove(ud.localpath) | ||
181 | |||
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): | |||
172 | runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d) | 172 | runfetchcmd("%s checkout-index -q -f -a" % ud.basecmd, d) |
173 | return True | 173 | return True |
174 | 174 | ||
175 | def clean(self, ud, d): | ||
176 | """ clean the git directory """ | ||
177 | |||
178 | bb.utils.remove(ud.localpath, True) | ||
179 | bb.utils.remove(ud.fullmirror) | ||
180 | |||
175 | def supports_srcrev(self): | 181 | def supports_srcrev(self): |
176 | return True | 182 | return True |
177 | 183 | ||
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): | |||
74 | if os.path.exists(urldata.localpath): | 74 | if os.path.exists(urldata.localpath): |
75 | return True | 75 | return True |
76 | return False | 76 | return False |
77 | |||
78 | def clean(self, urldata, d): | ||
79 | return | ||
80 | |||
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): | |||
138 | # tar them up to a defined filename | 138 | # tar them up to a defined filename |
139 | runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.module), d, cleanup = [ud.localpath]) | 139 | runfetchcmd("tar %s -czf %s %s" % (tar_flags, ud.localpath, ud.module), d, cleanup = [ud.localpath]) |
140 | 140 | ||
141 | def clean(self, ud, d): | ||
142 | """ Clean SVN specific files and dirs """ | ||
143 | |||
144 | bb.utils.remove(ud.localpath) | ||
145 | bb.utils.remove(ud.moddir, True) | ||
146 | |||
147 | |||
141 | def supports_srcrev(self): | 148 | def supports_srcrev(self): |
142 | return True | 149 | return True |
143 | 150 | ||