[yum-commits] 5 commits - plugins/aliases plugins/security plugins/versionlock yum-utils.spec

James Antill james at osuosl.org
Fri Jul 17 19:28:57 UTC 2009


 plugins/aliases/aliases.py         |    2 
 plugins/security/security.py       |    4 
 plugins/versionlock/versionlock.py |  162 +++++++++++++++++++++++++++++++------
 yum-utils.spec                     |    2 
 4 files changed, 144 insertions(+), 26 deletions(-)

New commits:
commit 6997518f853e35f94b62aa7354ee06ef1b75f3be
Author: James Antill <james at and.org>
Date:   Fri Jul 17 15:23:17 2009 -0400

    Bump require version for new versionlock

diff --git a/yum-utils.spec b/yum-utils.spec
index d3c3d4a..1215c9c 100644
--- a/yum-utils.spec
+++ b/yum-utils.spec
@@ -75,7 +75,7 @@ Group: System Environment/Base
 Provides: yum-versionlock = %{version}-%{release}
 Obsoletes: yum-versionlock < 1.1.20-0
 Conflicts: yum-versionlock < 1.1.20-0
-Requires: yum >= 3.0
+Requires: yum >= 3.2.24
 
 %description -n yum-plugin-versionlock
 This plugin takes a set of name/versions for packages and excludes all other
commit ee60fbcf793652f027d0b716b6ede74a214e76a6
Author: James Antill <james at and.org>
Date:   Thu Jul 16 16:05:46 2009 -0400

    Add excluderids, so we don't get N versions

diff --git a/plugins/versionlock/versionlock.py b/plugins/versionlock/versionlock.py
index ec6c26c..68209e2 100644
--- a/plugins/versionlock/versionlock.py
+++ b/plugins/versionlock/versionlock.py
@@ -178,7 +178,8 @@ def exclude_hook(conduit):
         return
 
     ape = conduit._base.pkgSack.addPackageExcluder
-    ape(None, 'wash.marked')
-    ape(None, 'mark.name.in', _version_lock_excluder_n)
-    ape(None, 'wash.nevr.in', _version_lock_excluder_nevr)
-    ape(None, 'exclude.marked')
+    exid = 'yum-utils.versionlock.'
+    ape(None, exid + str(1), 'wash.marked')
+    ape(None, exid + str(2), 'mark.name.in', _version_lock_excluder_n)
+    ape(None, exid + str(3), 'wash.nevr.in', _version_lock_excluder_nevr)
+    ape(None, exid + str(4), 'exclude.marked')
commit 21937bb11f46b00df7db79a2dbe0bf31340be8da
Author: James Antill <james at and.org>
Date:   Thu Jul 16 01:00:03 2009 -0400

    Move versionlock to use pkgExcluder, add versionlock command

diff --git a/plugins/versionlock/versionlock.py b/plugins/versionlock/versionlock.py
index 8b4294b..ec6c26c 100644
--- a/plugins/versionlock/versionlock.py
+++ b/plugins/versionlock/versionlock.py
@@ -22,22 +22,26 @@ from rpmUtils.miscutils import splitFilename, compareEVR
 import urlgrabber
 import urlgrabber.grabber
 
+import os
+import fnmatch
+import tempfile
+
 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)
+_version_lock_excluder_n      = set()
+_version_lock_excluder_nevr   = set()
 
-def exclude_hook(conduit):
-    conduit.info(2, 'Reading version lock configuration')
+#  In theory we could do full nevra/pkgtup ... but having foo-1.i386 and not
+# foo-1.x86_64 would be pretty weird. So just do "archless".
+# _version_lock_excluder_pkgtup = set()
+
+fileurl = None
+
+def _read_locklist():
     locklist = []
-    location = conduit.confString('main', 'locklist')
-    if not location:
-        raise PluginYumExit('Locklist not set')
     try:
-        llfile = urlgrabber.urlopen(location)
+        llfile = urlgrabber.urlopen(fileurl)
         for line in llfile.readlines():
             if line.startswith('#') or line.strip() == '':
                 continue
@@ -45,29 +49,136 @@ def exclude_hook(conduit):
         llfile.close()
     except urlgrabber.grabber.URLGrabError, e:
         raise PluginYumExit('Unable to read version lock configuration: %s' % e)
+    return locklist
+
+class VersionLockCommand:
+    created = 1247693044
+
+    def getNames(self):
+        return ["versionlock"]
+
+    def getUsage(self):
+        return '[PACKAGE-wildcard]'
+
+    def getSummary(self):
+        return 'Control package version locks.'
+
+    def doCheck(self, base, basecmd, extcmds):
+        pass
+
+    def doCommand(self, base, basecmd, extcmds):
+        cmd = 'list'
+        if extcmds:
+            if extcmds[0] not in ('add', 'list', 'del', 'delete', 'clear'):
+                cmd = 'add'
+            else:
+                cmd = {'del' : 'delete'}.get(extcmds[0], extcmds[0])
+                extcmds = extcmds[1:]
+
+        filename = fileurl
+        if fileurl.startswith("file:"):
+            filename = fileurl[len("file:"):]
+
+        if not filename.startswith('/') and cmd != 'list':
+            print "Error: versionlock URL isn't local: " + fileurl
+            return 1, ["versionlock %s failed" % (cmd,)]
+
+        if cmd == 'add':
+            pkgs = base.rpmdb.returnPackages(patterns=extcmds)
+            if not pkgs:
+                pkgs = base.pkgSack.returnPackages(patterns=extcmds)
+
+            fo = open(filename, 'a')
+            count = 0
+            done = set()
+            for pkg in pkgs:
+                #  We ignore arch, so only add one entry for foo-1.i386 and
+                # foo-1.x86_64.
+                (n, a, e, v, r) = pkg.pkgtup
+                a = '*'
+                if (n, a, e, v, r) in done:
+                    continue
+                done.add((n, a, e, v, r))
+
+                print "Adding versionlock on: %s:%s-%s-%s" % (e, n, v, r)
+                count += 1
+                (n, a, e, v, r) = pkg.pkgtup
+                fo.write("%s:%s-%s-%s.%s\n" % (e, n, v, r, '*'))
+
+            return 0, ['versionlock added: ' + str(count)]
+
+        if cmd == 'clear':
+            open(filename, 'w')
+            return 0, ['versionlock cleared']
+
+        if cmd == 'delete':
+            dirname = os.path.dirname(filename)
+            (out, tmpfilename) = tempfile.mkstemp(dir=dirname, suffix='.tmp')
+            out = os.fdopen(out, 'w', -1)
+            count = 0
+            for ent in _read_locklist():
+                found = False
+                for match in extcmds:
+                    if fnmatch.fnmatch(ent, match):
+                        found = True
+                        break
+                if found:
+                    print "Deleting versionlock for:", ent
+                    count += 1
+                    continue
+                out.write(ent)
+                out.write('\n')
+            out.close()
+            if not count:
+                os.unlink(tmpfilename)
+                return 1, ['Error: versionlock delete: no matches']
+            os.rename(tmpfilename, filename)
+            return 0, ['versionlock deleted: ' + str(count)]
+
+        assert cmd == 'list'
+        for ent in _read_locklist():
+            print ent
+
+        return 0, ['versionlock list done']
+
+    def needTs(self, base, basecmd, extcmds):
+        return False
+
+def config_hook(conduit):
+    global fileurl
+
+    fileurl = conduit.confString('main', 'locklist')
+
+    if hasattr(conduit._base, 'registerCommand'):
+        conduit.registerCommand(VersionLockCommand())
+
+def exclude_hook(conduit):
+    conduit.info(3, 'Reading version lock configuration')
+
+    if not fileurl:
+        raise PluginYumExit('Locklist not set')
 
     pkgs = {}
-    for ent in locklist:
+    for ent in _read_locklist():
         (n, v, r, e, a) = splitFilename(ent)
         if e == '': 
             e = '0'
-        pkgs.setdefault(n, []).append((e, v, r))
+        _version_lock_excluder_n.add(n)
+        _version_lock_excluder_nevr.add("%s-%s:%s-%s" % (n, e, v, r))
 
     if conduit.confBool('main', 'follow_obsoletes', default=False):
         #  If anything obsoletes something that we have versionlocked ... then
         # remove all traces of that too.
         for (pkgtup, instTup) in conduit._base.up.getObsoletesTuples():
-            if instTup[0] not in pkgs:
+            if instTup[0] not in _version_lock_excluder_n:
                 continue
-            # If anyone versions a pkg this, they need a good kicking
-            pkgs.setdefault(pkgtup[0], []).append(('0', '0', '0'))
-
-    for pkgname in pkgs:
-        for pkg in vl_search(conduit, pkgname):
-            found = False
-            for tup in pkgs[pkgname]:
-                if not compareEVR((pkg.epoch, pkg.version, pkg.release), tup):
-                    found = True
-            if not found:
-                conduit.delPackage(pkg)
-                conduit.info(5, 'Excluding package %s (%s) due to version lock' % (pkg,pkg.repoid))
+            _version_lock_excluder_n.add(pkgtup[0])
+
+    if not _version_lock_excluder_n:
+        return
+
+    ape = conduit._base.pkgSack.addPackageExcluder
+    ape(None, 'wash.marked')
+    ape(None, 'mark.name.in', _version_lock_excluder_n)
+    ape(None, 'wash.nevr.in', _version_lock_excluder_nevr)
+    ape(None, 'exclude.marked')
commit 331e792768cced2ca920e71252692b930f800d10
Author: James Antill <james at and.org>
Date:   Thu Jul 16 00:24:58 2009 -0400

    Add created timestamps to the security plugin commands

diff --git a/plugins/security/security.py b/plugins/security/security.py
index 804d192..88d5433 100755
--- a/plugins/security/security.py
+++ b/plugins/security/security.py
@@ -179,6 +179,8 @@ def ysp_chk_used_map(used_map, msg):
             msg('CVE \"%s\" not found applicable for this system' % i)
 
 class SecurityListCommand:
+    created = 1177064734
+
     def getNames(self):
         return ['list-security', 'list-sec']
 
@@ -327,6 +329,8 @@ def _get_name2oldpkgtup(base):
     return name2tup
 
 class SecurityUpdateCommand:
+    created = 1217002090
+
     def getNames(self):
         return ['update-minimal']
 
commit 008b44132eca12c30b17f2bb6c50eae25d8a750c
Author: James Antill <james at and.org>
Date:   Thu Jul 16 00:24:27 2009 -0400

    Add a created timestamp to the alias command

diff --git a/plugins/aliases/aliases.py b/plugins/aliases/aliases.py
index dc8eae8..2d534cb 100644
--- a/plugins/aliases/aliases.py
+++ b/plugins/aliases/aliases.py
@@ -95,6 +95,8 @@ def resolve_aliases(args, log, skip=0):
             need_rep = recursive
 
 class AliasCommand(AliasedCommand):
+    created = 1198172281
+
     def __init__(self):
         AliasedCommand.__init__(self, "alias")
 


More information about the Yum-commits mailing list