[yum-git] 3 commits - plugins/filter-data plugins/security

James Antill james at linux.duke.edu
Wed Apr 9 18:47:14 UTC 2008


 plugins/filter-data/filter-data.py |   52 +++++++++++++++++++++++++------------
 plugins/security/security.py       |   10 +++----
 2 files changed, 41 insertions(+), 21 deletions(-)

New commits:
commit f7b1fd902345e2efa2dcca980166d537722e54ce
Author: James Antill <james at and.org>
Date:   Wed Apr 9 14:46:57 2008 -0400

    Minor tidy thanks to pychecker

diff --git a/plugins/filter-data/filter-data.py b/plugins/filter-data/filter-data.py
index a78d5f5..76e437e 100644
--- a/plugins/filter-data/filter-data.py
+++ b/plugins/filter-data/filter-data.py
@@ -25,15 +25,10 @@
 #
 #  yum --filter-groups='App*/Sys*' list updates
 
-import yum
 from yum.plugins import TYPE_INTERACTIVE
 
 import fnmatch
 
-# For baseurl
-import urlparse
-
-
 requires_api_version = '2.5'
 plugin_type = (TYPE_INTERACTIVE,)
 
commit 78319f98f82c7c9d58ec81984d811cd35dbebdaa
Author: James Antill <james at and.org>
Date:   Wed Apr 9 13:53:27 2008 -0400

    Merge the security fix into filter-data

diff --git a/plugins/filter-data/filter-data.py b/plugins/filter-data/filter-data.py
index d8fe136..a78d5f5 100644
--- a/plugins/filter-data/filter-data.py
+++ b/plugins/filter-data/filter-data.py
@@ -334,30 +334,55 @@ def preresolve_hook(conduit):
     
     conduit.info(2, 'Limiting package lists to filtered ones')
 
-    def fd_del_pkg(tspkg, which):
+    def fd_del_pkg(tspkg):
         """ Deletes a package within a transaction. """
-        conduit.info(3," --> %s from %s excluded (filter: %s)" %
-                     (tspkg.po, tspkg.po.repoid, which[0]))
+        conduit.info(3," --> %s from %s excluded" %
+                     (tspkg.po, tspkg.po.repoid))
         tsinfo.remove(tspkg.pkgtup)
 
     if opts.filter_groups:
         fd_make_group_data(conduit._base, opts)
     tot = 0
-    cnt = 0
     used_map = fd_gen_used_map(opts)
     tsinfo = conduit.getTsInfo()
     tspkgs = tsinfo.getMembers()
+    # Ok, here we keep any pkgs that pass "filter" tests, then we keep all
+    # related pkgs ... Ie. "installed" version marked for removal.
+    keep_pkgs = set()
     for tspkg in tspkgs:
         tot += 1
-        which = fd_should_filter_pkg(conduit._base, opts, tspkg.po, used_map)
-        if which:
-            fd_del_pkg(tspkg, which)
-        else:
-            cnt += 1
+        if not fd_should_filter_pkg(conduit._base, opts, tspkg.po, used_map):
+            keep_pkgs.add(tspkg.po)
+
+    scnt = len(keep_pkgs)
+    mini_depsolve_again = True
+    while mini_depsolve_again:
+        mini_depsolve_again = False
+
+        for tspkg in tspkgs:
+            if tspkg.po in keep_pkgs:
+                # Find any related pkgs, and add them:
+                for (rpkg, reason) in tspkg.relatedto:
+                    if rpkg not in keep_pkgs:
+                        keep_pkgs.add(rpkg)
+                        mini_depsolve_again = True
+            else:
+                # If related to any keep pkgs, add us
+                for (rpkg, reason) in tspkg.relatedto:
+                    if rpkg in keep_pkgs:
+                        keep_pkgs.add(tspkg.po)
+                        mini_depsolve_again = True
+                        break
+
+    for tspkg in tspkgs:
+        if tspkg.po not in keep_pkgs:
+            fd_del_pkg(tspkg)
+
+    acnt = len(keep_pkgs)
     fd_chk_used_map(used_map, lambda x: conduit.error(2, x))
     
-    if cnt:
-        conduit.info(2, 'Left with %d of %d packages, after filters applied' % (cnt, tot))
+    if acnt:
+        conduit.info(2, 'Left with %d (+%d related) of %d packages, after filters applied' % (scnt, acnt - scnt, tot))
     else:
         conduit.info(2, 'No packages passed the filters, %d available' % tot)
     fd_free_group_data()
commit 5de090f53dfaef715b51a4d322a51d9265efba3e
Author: James Antill <james at and.org>
Date:   Wed Apr 9 13:38:00 2008 -0400

    Give slightly better messages for update/upgrade

diff --git a/plugins/security/security.py b/plugins/security/security.py
index b70fe35..e1cdec2 100755
--- a/plugins/security/security.py
+++ b/plugins/security/security.py
@@ -413,7 +413,6 @@ def preresolve_hook(conduit):
         tsinfo.remove(tspkg.pkgtup)
 
     tot = 0
-    cnt = 0
     opts.sec_cmds = []
     used_map = ysp_gen_used_map(opts)
     tsinfo = conduit.getTsInfo()
@@ -426,6 +425,7 @@ def preresolve_hook(conduit):
         if ysp_should_keep_pkg(opts, tspkg.po, md_info, used_map):
             keep_pkgs.add(tspkg.po)
 
+    scnt = len(keep_pkgs)
     mini_depsolve_again = True
     while mini_depsolve_again:
         mini_depsolve_again = False
@@ -449,13 +449,13 @@ def preresolve_hook(conduit):
         if tspkg.po not in keep_pkgs:
             ysp_del_pkg(tspkg)
 
-    cnt = len(keep_pkgs)
+    acnt = len(keep_pkgs)
     ysp_chk_used_map(used_map, lambda x: conduit.error(2, x))
     
-    if cnt:
-        conduit.info(2, 'Needed %d of %d packages, for security' % (cnt, tot))
+    if acnt:
+        conduit.info(2, 'Needed %d (+%d related) of %d transaction packages, for security' % (scnt, acnt - scnt, tot))
     else:
-        conduit.info(2, 'No packages needed, for security, %d available' % tot)
+        conduit.info(2, 'No transaction packages needed, for security, %d available' % tot)
 
 if __name__ == '__main__':
     print "This is a plugin that is supposed to run from inside YUM"



More information about the Yum-cvs-commits mailing list