[yum-commits] 6 commits - cli.py docs/yum.8 test/skipbroken-tests.py test/testbase.py yumcommands.py yum/depsolve.py yum/__init__.py yum/transactioninfo.py

James Antill james at osuosl.org
Fri Feb 22 19:14:44 UTC 2013


 cli.py                   |    2 -
 docs/yum.8               |    4 +++
 test/skipbroken-tests.py |   48 +++++++++++++++++++++++++++++++++++++++++++++++
 test/testbase.py         |    6 +++++
 yum/__init__.py          |   18 +++++++++++++++++
 yum/depsolve.py          |    2 -
 yum/transactioninfo.py   |   18 +++++++++++++++++
 yumcommands.py           |    4 +--
 8 files changed, 98 insertions(+), 4 deletions(-)

New commits:
commit 19a1e5affde1dd0f166c7034d2e24e9cef45ea54
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:10:28 2013 -0500

    Use txmbr.removeDep(), to unwind deps. in skip-broken better. bz#905899.

diff --git a/yum/__init__.py b/yum/__init__.py
index 367cc21..d485d05 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1537,9 +1537,17 @@ much more problems).
 
     def _getDepsToRemove(self,po, deptree, toRemove):
         for dep in deptree.get(po, []): # Loop trough all deps of po
+            more_deps = False
             for txmbr in self.tsInfo.getMembers(dep.pkgtup):
+                txmbr.removeDep(po)
+                if txmbr.depends_on:
+                    more_deps = True
+                    break
+
                 for pkg in (txmbr.updates + txmbr.obsoletes):
                     toRemove.add(pkg)
+            if more_deps: # Others depend on this pkg, so leave it. bz#905899
+                continue
             if dep in toRemove: #  If this is true we inf. recurse, so check
                 continue        # even though it shouldn't happen. bz#874065
             toRemove.add(dep)
commit 27e2f0f5415638eb2c06610b245683e9f77d8522
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:09:34 2013 -0500

    Add txmbr.removeDep(), so we can unwind deps. in skip-broken, for bz#905899.

diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index 96c75b5..4358564 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -819,6 +819,24 @@ class TransactionMember:
             self.relatedto.append((po, 'dependson'))
             self.depends_on.append(po)
 
+    def removeDep(self, po):
+        """sets the transaction member as a dependency and maps the dep into the
+           relationship list attribute"""
+
+        nrelto = []
+        for data in self.relatedto:
+            if data[0] == po:
+                continue
+            nrelto.append(data)
+        self.relatedto = nrelto
+
+        ndepon = []
+        for data in self.depends_on:
+            if data == po:
+                continue
+            ndepon.append(data)
+        self.depends_on = ndepon
+
     def __cmp__(self, other):
         return cmp(self.po, other.po)
 
commit e9721ad2574b1b0f9b8156d0c1d85c0b751755c3
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:08:56 2013 -0500

    Use setAsDep instead of mangling relatedto directly, for bz#905899.

diff --git a/yum/depsolve.py b/yum/depsolve.py
index 74f9a48..90e1253 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -1095,7 +1095,7 @@ class Depsolve(object):
                     continue
                 for member in self.tsInfo.getMembersWithState(
                     pkgtup=po.pkgtup, output_states=TS_INSTALL_STATES):
-                    member.relatedto.append((txmbr.po, 'dependson'))
+                    member.setAsDep(txmbr.po)
 
         return ret
 
commit 224f517201091b5868cfb4d0e5665e7605643c8d
Author: James Antill <james at and.org>
Date:   Fri Feb 22 14:08:03 2013 -0500

    Add test cases for bz#905899, skip-broken removing too many deps.

diff --git a/test/skipbroken-tests.py b/test/skipbroken-tests.py
index 812785a..4d7561c 100644
--- a/test/skipbroken-tests.py
+++ b/test/skipbroken-tests.py
@@ -809,7 +809,55 @@ class SkipBrokenTests(DepsolveTests):
         members.append(u1)
         self.assertEquals('ok', *self.resolveCode(skip=True))
         self.assertResult(members)
+
+    def test_skipbroken_004_deps_1(self):
+        ''' 
+        this tries to test that when we have two things depending on Y, and we
+        remove one of them we do not want to remove Y. bz#905899.
+        '''
+        members = []
+        ux0 = self.repoString('1:bar-1.0.0-1.i686')
+        members.append(ux0)
+
+        ux1 = self.repoString('1:foo1-1.0.0-1.i686')
+        ux1.addRequires('bar')
+        ux1.addRequires('blah')
+
+        ux2 = self.repoString('1:foo2-1.0.0-1.i686')
+        ux2.addRequires('bar')
+        members.append(ux2)
+
+        self.tsInfo.addInstall(ux1)
+        self.tsInfo.addInstall(ux2)
+
+        self.assertEquals('ok', *self.resolveCode(skip=True))
+        self.assertResult(members)
     
+    def test_skipbroken_004_deps_2(self):
+        ''' 
+        this tries to test that when we have two things depending on Y, and we
+        remove both then we do want to remove Y again. bz#905899.
+        '''
+        members = []
+        ux0 = self.repoString('1:bar-1.0.0-1.i686')
+
+        ux0 = self.repoString('1:zoom-1.0.0-1.i686')
+        members.append(ux0)
+
+        ux1 = self.repoString('1:foo1-1.0.0-1.i686')
+        ux1.addRequires('bar')
+        ux1.addRequires('blah')
+
+        ux2 = self.repoString('1:foo2-1.0.0-1.i686')
+        ux2.addRequires('bar')
+        ux2.addRequires('baz')
+
+        self.tsInfo.addInstall(ux0)
+        self.tsInfo.addInstall(ux1)
+        self.tsInfo.addInstall(ux2)
+
+        self.assertEquals('ok', *self.resolveCode(skip=True))
+        self.assertResult(members)
     
     def resolveCode(self,skip = False):
         solver = YumBase()
commit e8286caede327abbc1346d5bf7a4a59d263187cc
Author: James Antill <james at and.org>
Date:   Fri Feb 22 13:45:04 2013 -0500

    Fix FakeConf so that make check doesn't fail now.

diff --git a/test/testbase.py b/test/testbase.py
index 608da70..c9bbb88 100644
--- a/test/testbase.py
+++ b/test/testbase.py
@@ -58,6 +58,12 @@ class FakeConf(object):
         self.upgrade_requirements_on_install = False
         self.recheck_installed_requires = False
         self.group_command = 'compat'
+        self.repopkgsremove_leaf_only = False
+        self.remove_leaf_only = False
+        self.config_file_path = '/dev/null'
+        self.config_file_age = 0
+        self.yumvar = {}
+        self.reposdir = '/tmp/XXXX'
 
 class FakeSack:
     """ Fake PackageSack to use with FakeRepository"""
commit 3b5e46e08e846f1cf516aa4784abefc265034138
Author: James Antill <james at and.org>
Date:   Thu Feb 21 16:57:06 2013 -0500

    Add "list distro-extras", which is like extras but ignores version/arch.

diff --git a/cli.py b/cli.py
index 5f03d35..63a9236 100755
--- a/cli.py
+++ b/cli.py
@@ -1281,7 +1281,7 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
              recent = list of packageObjects
         """
         special = ['available', 'installed', 'all', 'extras', 'updates', 'recent',
-                   'obsoletes']
+                   'obsoletes', 'distro-extras']
         
         pkgnarrow = 'all'
         done_hidden_available = False
diff --git a/docs/yum.8 b/docs/yum.8
index 82aeadd..8f5ecdf 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -679,6 +679,10 @@ shell\-style glob and any matches are printed\&.
 List the packages installed on the system that are not available in any yum
 repository listed in the config file.
 .IP
+.IP "\fByum list distro-extras [glob_exp1] [\&.\&.\&.]\fP"
+List the packages installed on the system that are not available, by name,
+in any yum repository listed in the config file.
+.IP
 .IP "\fByum list obsoletes [glob_exp1] [\&.\&.\&.]\fP"
 List the packages installed on the system that are obsoleted by packages
 in any yum repository listed in the config file.
diff --git a/yum/__init__.py b/yum/__init__.py
index b884a23..367cc21 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2780,6 +2780,16 @@ much more problems).
                 if po.pkgtup not in avail:
                     extras.append(po)
 
+        # not in a repo but installed
+        elif pkgnarrow == 'distro-extras':
+            for po in self.rpmdb.returnPackages(patterns=patterns,
+                                                ignore_case=ic):
+                if not misc.filter_pkgs_repoid([po], repoid):
+                    continue
+                if self.pkgSack.searchNames([po.name]):
+                    continue
+                extras.append(po)
+
         # obsoleting packages (and what they obsolete)
         elif pkgnarrow == 'obsoletes':
             self.conf.obsoletes = 1
diff --git a/yumcommands.py b/yumcommands.py
index ad529cd..153a0af 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -595,7 +595,7 @@ class InfoCommand(YumCommand):
 
         :return: a usage string for this command
         """
-        return "[PACKAGE|all|available|installed|updates|extras|obsoletes|recent]"
+        return "[PACKAGE|all|available|installed|updates|distro-extras|extras|obsoletes|recent]"
 
     def getSummary(self):
         """Return a one line summary of this command.
@@ -741,7 +741,7 @@ class InfoCommand(YumCommand):
         """
         if len(extcmds) and extcmds[0] in ('updates', 'obsoletes'):
             return 'read-only:future'
-        if len(extcmds) and extcmds[0] in ('installed', 'extras', 'recent'):
+        if len(extcmds) and extcmds[0] in ('installed', 'distro-extras', 'extras', 'recent'):
             return 'read-only:past'
         # available/all
         return 'read-only:present'


More information about the Yum-commits mailing list