[yum-commits] 2 commits - plugins/auto-update-debuginfo
James Antill
james at osuosl.org
Fri Nov 12 17:09:18 UTC 2010
plugins/auto-update-debuginfo/auto-update-debuginfo.py | 52 ++++++++++++++++-
1 file changed, 49 insertions(+), 3 deletions(-)
New commits:
commit acd713e603ab79ce4045aef2f14be362c526e105
Author: James Antill <james at and.org>
Date: Fri Nov 12 11:45:33 2010 -0500
Add rpmdb caching to a-u-di.
diff --git a/plugins/auto-update-debuginfo/auto-update-debuginfo.py b/plugins/auto-update-debuginfo/auto-update-debuginfo.py
index 8684a3f..f03841b 100644
--- a/plugins/auto-update-debuginfo/auto-update-debuginfo.py
+++ b/plugins/auto-update-debuginfo/auto-update-debuginfo.py
@@ -21,6 +21,8 @@
from yum.plugins import TYPE_CORE
+import os, os.path
+
requires_api_version = '2.1'
plugin_type = (TYPE_CORE,)
@@ -42,9 +44,53 @@ def enable_debuginfo_repos(yb, conduit):
if hasattr(r, opt):
setattr(r, opt, getattr(baserepo, opt))
+def _read_cached(cfname):
+ try:
+ fo = open(cfname)
+ crpmdbv = fo.readline()[:-1]
+ cnum = int(fo.readline())
+ return crpmdbv, cnum
+ except:
+ return None, None
+
+def _write_cached(cfname, rpmdbv, num):
+ cdname = os.path.dirname(cfname)
+ if not os.access(cdname, os.W_OK):
+ if os.path.exists(cdname):
+ return
+
+ try:
+ os.makedirs(cdname)
+ except (IOError, OSError), e:
+ return
+
+ fo = open(cfname + ".tmp", "w")
+ fo.write(str(rpmdbv))
+ fo.write('\n')
+ fo.write(str(num))
+ fo.write('\n')
+ fo.close()
+ os.rename(cfname + ".tmp", cfname)
+
def prereposetup_hook(conduit):
yb = conduit._base
- num = len(yb.rpmdb.returnPackages(patterns=['*-debuginfo']))
+
+ caching = hasattr(yb.rpmdb, 'simpleVersion')
+ num = None
+ if caching:
+ cfname = yb.conf.persistdir + '/plugins/auto-update-debuginfo/num'
+ crpmdbv, num = _read_cached(cfname)
+ if num is not None:
+ rpmdbv = yb.rpmdb.simpleVersion(main_only=True)[0]
+ if rpmdbv != crpmdbv:
+ num = None
+
+ if num is None:
+ num = len(yb.rpmdb.returnPackages(patterns=['*-debuginfo']))
+ if caching:
+ rpmdbv = yb.rpmdb.simpleVersion(main_only=True)[0]
+ _write_cached(cfname, rpmdbv, num)
+
if num:
if hasattr(conduit, 'registerPackageName'):
conduit.registerPackageName("yum-plugin-auto-update-debug-info")
commit 4db84660d838d918d8c4286f5652ec7c724fd1c6
Author: James Antill <james at and.org>
Date: Fri Nov 12 11:31:17 2010 -0500
Be less verbose in a-u-di.
diff --git a/plugins/auto-update-debuginfo/auto-update-debuginfo.py b/plugins/auto-update-debuginfo/auto-update-debuginfo.py
index 6a20dde..8684a3f 100644
--- a/plugins/auto-update-debuginfo/auto-update-debuginfo.py
+++ b/plugins/auto-update-debuginfo/auto-update-debuginfo.py
@@ -34,7 +34,7 @@ def enable_debuginfo_repos(yb, conduit):
continue
baserepo = baserepos[repoid]
for r in yb.repos.findRepos(di):
- conduit.info(2, 'Enabling %s: %s' % (r.id, r.name))
+ conduit.info(3, 'Enabling %s: %s' % (r.id, r.name))
r.enable()
r.skip_if_unavailable = True
# Note: This is shared with debuginfo-install
@@ -48,5 +48,5 @@ def prereposetup_hook(conduit):
if num:
if hasattr(conduit, 'registerPackageName'):
conduit.registerPackageName("yum-plugin-auto-update-debug-info")
- conduit.info(2, "Found %d installed debuginfo package(s)" % num)
+ conduit.info(3, "Found %d installed debuginfo package(s)" % num)
enable_debuginfo_repos(yb, conduit)
More information about the Yum-commits
mailing list