On Fri, 2012-10-05 at 15:50 +0200, Zdeněk Pavlas wrote:
> ---
> cli.py | 28 +++++++++++++++++++++++++++-
> yum/misc.py | 10 ++++++++++
> 2 files changed, 37 insertions(+), 1 deletions(-)
>
> diff --git a/cli.py b/cli.py
> index 3499273..28d520f 100755
> --- a/cli.py
> +++ b/cli.py
> @@ -42,7 +42,7 @@ from yum import _, P_
> from yum.rpmtrans import RPMTransaction
> import signal
> import yumcommands
> -import tempfile
> +import tempfile, shutil
>
> from yum.i18n import to_unicode, to_utf8, exception2msg
>
> @@ -568,6 +568,29 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
> po.basepath
> po.returnChecksums()
>
> + # downloadPkgs() will run predownload hooks without yum lock, so
> plugins may break.
> + # This is a presto-specific hack. We'll probably have to merge
> it to core anyway.
> + moved = []
> + presto, conf = self.plugins._plugins.get('presto') or (None,
> None)
> + if conf and conf.getboolean('main', 'enabled'):
> + repos = {}
> + for po in downloadpkgs:
> + if po.state == yum.constants.TS_UPDATE:
> + repos[po.repo] = repos.get(po.repo, 0) + po.size
> + for repo in repos:
> + try: md = repo.repoXML.getData('prestodelta')
> + except yum.Errors.YumRepoMDError: continue
> + if int(md.size) > repos[repo]:
> + continue
> +
> + # Presto may use this repository- move it.
> + old = repo.cachedir
> + new = tempfile.mkdtemp(dir=old)
> + fn = repo._retrieveMD('prestodelta')
> + os.link(fn, new +'/'+ os.path.basename(fn))
> + repo._dir_setup_cachedir = new
> + moved.append((repo, old, new))The metadata's official label is "deltainfo" ... but really if we call _retrieveMD() without the lock held we aren't going to have a good time. > # close DBs, unlock > self.repos.close() > self.closeRpmDB() > @@ -601,6 +624,9 @@ class YumBaseCli(yum.YumBase, output.YumOutput): > # remove temporary directories > for tmp in tmpdir.values(): > os.rmdir(tmp) > + for repo, old, new in moved: > + yum.misc.rmdir_f(new) > + repo._dir_setup_cachedir = old > > if len(problems) > 0: > errstring = '' > diff --git a/yum/misc.py b/yum/misc.py > index 0fd3e90..8d23770 100644 > --- a/yum/misc.py > +++ b/yum/misc.py > @@ -1208,3 +1208,13 @@ def cElementTree_xmlparse(filename): > """ Lazily load/run: cElementTree.parse """ > _cElementTree_import() > return __cached_cElementTree.parse(filename) > + > +def rmdir_f(path): > + """ rm -rf path """ > + for fn in os.listdir(path): > + fn = path +'/'+ fn > + if os.path.isdir(fn): > + rmdir_f(fn) > + else: > + os.unlink(fn) > + os.rmdir(path) This is a really bad name, the stat_f and unlink_f functions mean "this function doesn't throw some/all exceptions" ... "rm -rf" is also in the std. library as shutils.rmtree().
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Yum-devel mailing list [email protected] http://lists.baseurl.org/mailman/listinfo/yum-devel
