[yum-git] 2 commits - plugins/versionlock
James Antill
james at linux.duke.edu
Wed Feb 20 06:42:02 UTC 2008
plugins/versionlock/versionlock.py | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
New commits:
commit 3a2d1fdf53635a8929693494b4fbacc2a5bf4545
Author: James Antill <james at and.org>
Date: Wed Feb 20 01:40:25 2008 -0500
Fix non-existant version lock file SNAFU
diff --git a/plugins/versionlock/versionlock.py b/plugins/versionlock/versionlock.py
index 664e887..0e558c2 100644
--- a/plugins/versionlock/versionlock.py
+++ b/plugins/versionlock/versionlock.py
@@ -20,6 +20,7 @@ from yum.plugins import TYPE_CORE
from rpmUtils.miscutils import splitFilename, compareEVR
import urlgrabber
import urlgrabber.grabber
+import os
requires_api_version = '2.1'
plugin_type = (TYPE_CORE,)
@@ -30,11 +31,15 @@ def vl_search(conduit, name):
return conduit._base.pkgSack.searchNevra(name=name)
def exclude_hook(conduit):
- conduit.info(2, 'Reading version lock configuration')
locklist = []
location = conduit.confString('main', 'locklist')
if not location:
raise PluginYumExit('Locklist not set')
+
+ if location.startswith('/') and not os.path.exists(location):
+ return # Don't die if the file doesn't exist, just treat as empty
+
+ conduit.info(2, 'Reading version lock configuration')
try:
llfile = urlgrabber.urlopen(location)
for line in llfile.readlines():
commit cea2c7da444204049ba3b82ec66509bdec09773b
Author: James Antill <james at and.org>
Date: Wed Feb 20 01:37:59 2008 -0500
Redo versionlock logic for major speedup in non-update cases
diff --git a/plugins/versionlock/versionlock.py b/plugins/versionlock/versionlock.py
index c9242ac..664e887 100644
--- a/plugins/versionlock/versionlock.py
+++ b/plugins/versionlock/versionlock.py
@@ -24,6 +24,11 @@ import urlgrabber.grabber
requires_api_version = '2.1'
plugin_type = (TYPE_CORE,)
+def vl_search(conduit, name):
+ """ Search for packages with a particular name. """
+ # Note that conduit.getPackageByNevra _almost_ works enough, but doesn't
+ return conduit._base.pkgSack.searchNevra(name=name)
+
def exclude_hook(conduit):
conduit.info(2, 'Reading version lock configuration')
locklist = []
@@ -40,19 +45,11 @@ def exclude_hook(conduit):
except urlgrabber.grabber.URLGrabError, e:
raise PluginYumExit('Unable to read version lock configuration: %s' % e)
- if not locklist:
- return
-
- pkgs = conduit.getPackages()
- locked = {}
for pkg in locklist:
(n, v, r, e, a) = splitFilename("%s" % pkg)
if e == '':
e = '0'
- locked[n] = (e, v, r)
- for pkg in pkgs:
- if locked.has_key(pkg.name):
- (n,a,e,v,r) = pkg.pkgtup
- if compareEVR(locked[pkg.name], (e, v, r)) != 0:
+ for pkg in vl_search(conduit, n):
+ if compareEVR((pkg.epoch, pkg.version, pkg.release), (e, v, r)):
conduit.delPackage(pkg)
conduit.info(5, 'Excluding package %s due to version lock' % pkg)
More information about the Yum-cvs-commits
mailing list