diff options
-rw-r--r-- | bitbake/lib/bb/fetch/cvs.py | 11 | ||||
-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 | ||||
-rw-r--r-- | meta/classes/base.bbclass | 24 |
7 files changed, 83 insertions, 15 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): | |||
170 | except OSError: | 170 | except OSError: |
171 | pass | 171 | pass |
172 | raise FetchError(ud.module) | 172 | raise FetchError(ud.module) |
173 | |||
174 | def clean(self, ud, d): | ||
175 | """ clean the git directory """ | ||
176 | |||
177 | pkg = data.expand('${PN}', d) | ||
178 | localdata = data.createCopy(d) | ||
179 | data.setVar('OVERRIDES', "cvs:%s" % data.getVar('OVERRIDES', localdata), localdata) | ||
180 | data.update_data(localdata) | ||
181 | pkgdir = os.path.join(data.expand('${CVSDIR}', localdata), pkg) | ||
182 | bb.utils.remove(pkgdir, True) | ||
183 | 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): | |||
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 | ||
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass index edb65eb96b..e4ea69d481 100644 --- a/meta/classes/base.bbclass +++ b/meta/classes/base.bbclass | |||
@@ -464,24 +464,18 @@ addtask cleanall after do_clean | |||
464 | python do_cleanall() { | 464 | python do_cleanall() { |
465 | sstate_clean_cachefiles(d) | 465 | sstate_clean_cachefiles(d) |
466 | 466 | ||
467 | src_uri = (bb.data.getVar('SRC_URI', d, True) or "").split() | ||
468 | if len(src_uri) == 0: | ||
469 | return | ||
470 | |||
467 | localdata = bb.data.createCopy(d) | 471 | localdata = bb.data.createCopy(d) |
468 | bb.data.update_data(localdata) | 472 | bb.data.update_data(localdata) |
469 | 473 | ||
470 | dl_dir = bb.data.getVar('DL_DIR', localdata, True) | 474 | try: |
471 | dl_dir = os.path.realpath(dl_dir) | 475 | fetcher = bb.fetch2.Fetch(src_uri, localdata) |
472 | 476 | fetcher.clean() | |
473 | src_uri = (bb.data.getVar('SRC_URI', localdata, True) or "").split() | 477 | except bb.fetch2.BBFetchException, e: |
474 | if len(src_uri) == 0: | 478 | raise bb.build.FuncFailed(e) |
475 | return | ||
476 | fetcher = bb.fetch2.Fetch(src_uri, localdata) | ||
477 | for url in src_uri: | ||
478 | local = fetcher.localpath(url) | ||
479 | if local is None: | ||
480 | continue | ||
481 | local = os.path.realpath(local) | ||
482 | if local.startswith(dl_dir): | ||
483 | bb.note("Removing %s*" % local) | ||
484 | oe.path.remove(local + "*") | ||
485 | } | 479 | } |
486 | do_cleanall[nostamp] = "1" | 480 | do_cleanall[nostamp] = "1" |
487 | 481 | ||