[yum-commits] Branch 'yum-3_2_X' - 7 commits - output.py test/simpleupdatetests.py test/testbase.py yum/__init__.py
James Antill
james at osuosl.org
Tue Dec 9 15:48:31 UTC 2008
output.py | 15 ++---
test/simpleupdatetests.py | 123 +++++++++++++++++++++++++++++++++++++++++++++-
test/testbase.py | 1
yum/__init__.py | 25 ++++-----
4 files changed, 139 insertions(+), 25 deletions(-)
New commits:
commit c8b7bd81ed89cbcd1ccc4bd8ad078c0004763da8
Author: James Antill <james at and.org>
Date: Mon Dec 8 11:47:45 2008 -0500
Sync format_number with urlgrabber
diff --git a/output.py b/output.py
index b6bd005..9cdac35 100755
--- a/output.py
+++ b/output.py
@@ -763,18 +763,15 @@ class YumOutput:
thresh = 999
depth = 0
+ max_depth = len(symbols) - 1
- # we want numbers between
- while number > thresh:
+ # we want numbers between 0 and thresh, but don't exceed the length
+ # of our list. In that event, the formatting will be screwed up,
+ # but it'll still show the right number.
+ while number > thresh and depth < max_depth:
depth = depth + 1
number = number / step
- # just in case someone needs more than 1000 yottabytes!
- diff = depth - len(symbols) + 1
- if diff > 0:
- depth = depth - diff
- number = number * thresh**depth
-
if type(number) == type(1) or type(number) == type(1L):
format = '%i%s%s'
elif number < 9.95:
@@ -784,7 +781,7 @@ class YumOutput:
else:
format = '%.0f%s%s'
- return(format % (number, space, symbols[depth]))
+ return(format % (float(number or 0), space, symbols[depth]))
@staticmethod
def format_time(seconds, use_hours=0):
commit 44f6a767e8544fc9e9ecd3fe4e0698347cf83163
Author: James Antill <james at and.org>
Date: Sun Dec 7 19:12:36 2008 -0500
Only get the updates tuples when we'll use them
diff --git a/yum/__init__.py b/yum/__init__.py
index 5b4bdf5..ff7b02a 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2632,15 +2632,15 @@ class YumBase(depsolve.Depsolve):
# if no po do kwargs
# uninstalled pkgs called for update get returned with errors in a list, maybe?
- updates = self.up.getUpdatesTuples()
- if self.conf.obsoletes:
- obsoletes = self.up.getObsoletesTuples(newest=1)
- else:
- obsoletes = []
-
tx_return = []
if not po and not kwargs: # update everything (the easy case)
self.verbose_logger.log(logginglevels.DEBUG_2, _('Updating Everything'))
+ updates = self.up.getUpdatesTuples()
+ if self.conf.obsoletes:
+ obsoletes = self.up.getObsoletesTuples(newest=1)
+ else:
+ obsoletes = []
+
for (obsoleting, installed) in obsoletes:
obsoleting_pkg = self.getPackageObject(obsoleting)
installed_pkg = self.rpmdb.searchPkgTuple(installed)[0]
commit 8b4668d4b89afd15ba83eda717fb086334868fe1
Author: James Antill <james at and.org>
Date: Sun Dec 7 19:06:19 2008 -0500
Add "update *" to the bad-multi-install tests
diff --git a/test/simpleupdatetests.py b/test/simpleupdatetests.py
index 8d60cba..10ddd4f 100644
--- a/test/simpleupdatetests.py
+++ b/test/simpleupdatetests.py
@@ -447,3 +447,35 @@ class SimpleUpdateTests(OperationsTests):
[foo20, bar12])
self.assert_(res=='ok', msg)
self.assertResult((bar12,))
+
+ def testUpdateBadMultiInstall7(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+ bar11 = FakePackage('bar', '1', '1', '0', 'i386')
+ bar12 = FakePackage('bar', '1', '2', '0', 'i386')
+ bar12.addRequires('foo', 'EQ', ('0', '2', '0'))
+
+ res, msg = self.runOperation(['update', '*'],
+ [foo11, foo12, foo13, bar11],
+ [foo20, bar12])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,bar12))
+
+ def testUpdateBadMultiInstall8(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+ bar11 = FakePackage('bar', '1', '1', '0', 'i386')
+ bar12 = FakePackage('bar', '1', '2', '0', 'i386')
+ bar12.addObsoletes('foo', None, (None, None, None))
+
+ res, msg = self.runOperation(['update', '*'],
+ [foo11, foo12, foo13, bar11],
+ [foo20, bar12])
+ self.assert_(res=='ok', msg)
+ self.assertResult((bar12,))
commit 15ce4168608e960d20ca6d6948a31b7c1922c989
Author: James Antill <james at and.org>
Date: Sun Dec 7 19:05:43 2008 -0500
Always look for available pkgs, on pattern updates
diff --git a/yum/__init__.py b/yum/__init__.py
index 2038328..5b4bdf5 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2694,8 +2694,10 @@ class YumBase(depsolve.Depsolve):
else:
instpkgs.extend(depmatches)
- # if we can't find an installed package then look at available pkgs
- if not instpkgs:
+ # Always look for available packages, it doesn't seem to do any
+ # harm (apart from some time). And it fixes weird edge cases where
+ # "update a" (which requires a new b) is different from "update b"
+ if True or not instpkgs:
(e, m, u) = self.pkgSack.matchPackageNames([kwargs['pattern']])
availpkgs.extend(e)
availpkgs.extend(m)
commit 3e02b899c5cc64d3a381be751b26cdadcd6ceb16
Author: James Antill <james at and.org>
Date: Sun Dec 7 19:03:14 2008 -0500
Don't do the package updates by hand, just call into ourself
diff --git a/yum/__init__.py b/yum/__init__.py
index 681ddc7..2038328 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2655,12 +2655,7 @@ class YumBase(depsolve.Depsolve):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s'),
old)
else:
- updating_pkg = self.getPackageObject(new)
- updated_pkg = self.rpmdb.searchPkgTuple(old)[0]
- txmbr = self.tsInfo.addUpdate(updating_pkg, updated_pkg)
- if requiringPo:
- txmbr.setAsDep(requiringPo)
- tx_return.append(txmbr)
+ tx_return.extend(self.update(po=self.getPackageObject(new)))
return tx_return
commit 4b89d857fc07c0e544159025282c1568022e964a
Author: James Antill <james at and.org>
Date: Sun Dec 7 18:57:41 2008 -0500
Add showdupesfromrepos so "maybe you meant" works when called from testcases
diff --git a/test/testbase.py b/test/testbase.py
index bed2267..d0ff1c3 100644
--- a/test/testbase.py
+++ b/test/testbase.py
@@ -41,6 +41,7 @@ class FakeConf(object):
self.disable_excludes = []
self.multilib_policy = 'best'
self.persistdir = '/should-not-exist-bad-test!'
+ self.showdupesfromrepos = False
class FakeRepo(object):
commit 4fe026943d30cd379825a379037ba7b234dce43c
Author: James Antill <james at and.org>
Date: Sun Dec 7 18:55:33 2008 -0500
Add some test cases to try and trigger the searchPkgTuple()[0] problems.
... didn't succeed, but found weird multiple pkgs installed edge cases.
Also made noarch => arch update follow the same behaviour as install would.
diff --git a/test/simpleupdatetests.py b/test/simpleupdatetests.py
index 4efe382..8d60cba 100644
--- a/test/simpleupdatetests.py
+++ b/test/simpleupdatetests.py
@@ -92,9 +92,9 @@ class SimpleUpdateTests(OperationsTests):
p = self.pkgs
res, msg = self.runOperation(['update'], [p.installed_noarch], [p.update_i386, p.update_x86_64])
self.assert_(res=='ok', msg)
- if new_behavior:
+ if True or new_behavior: # We update from .noarch to just the .x86_64
self.assertResult((p.update_x86_64,), (p.update_i386,)) # ?
- else:
+ else: # Updates to both...
self.assertResult((p.update_i386, p.update_x86_64))
def testUpdatenoarchToMultilibForDependencyRev(self):
p = self.pkgs
@@ -360,3 +360,90 @@ class SimpleUpdateTests(OperationsTests):
res, msg = self.runOperation(['install', 'foo'], [foo11, bar11], [foo12, bar12, bar21])
self.assert_(res=='ok', msg)
self.assertResult((foo12, bar12))
+
+ def testUpdateBadMultiInstall1(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+
+ res, msg = self.runOperation(['install', 'foo'],
+ [foo11, foo12, foo13],
+ [foo20])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,))
+
+ def testUpdateBadMultiInstall2(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+
+ res, msg = self.runOperation(['update', 'foo'],
+ [foo11, foo12, foo13],
+ [foo20])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,))
+
+ def testUpdateBadMultiInstall3(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+
+ res, msg = self.runOperation(['update'],
+ [foo11, foo12, foo13],
+ [foo20])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,))
+
+ def testUpdateBadMultiInstall4(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+ bar11 = FakePackage('bar', '1', '1', '0', 'i386')
+ bar12 = FakePackage('bar', '1', '2', '0', 'i386')
+ bar12.addRequires('foo', 'EQ', ('0', '2', '0'))
+
+ res, msg = self.runOperation(['update', 'bar'],
+ [foo11, foo12, foo13, bar11],
+ [foo20, bar12])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,bar12))
+
+ def testUpdateBadMultiInstall5(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+ bar11 = FakePackage('bar', '1', '1', '0', 'i386')
+ bar12 = FakePackage('bar', '1', '2', '0', 'i386')
+ bar12.addRequires('foo', 'EQ', ('0', '2', '0'))
+
+ res, msg = self.runOperation(['update'],
+ [foo11, foo12, foo13, bar11],
+ [foo20, bar12])
+ self.assert_(res=='ok', msg)
+ self.assertResult((foo20,bar12))
+
+ def testUpdateBadMultiInstall6(self):
+ # This is a bug, but we shouldn't die too badly on it...
+ foo11 = FakePackage('foo', '1', '1', '0', 'i386')
+ foo12 = FakePackage('foo', '1', '2', '0', 'i386')
+ foo13 = FakePackage('foo', '1', '3', '0', 'i386')
+ foo20 = FakePackage('foo', '2', '0', '0', 'i386')
+ bar11 = FakePackage('bar', '1', '1', '0', 'i386')
+ bar12 = FakePackage('bar', '1', '2', '0', 'i386')
+ bar12.addObsoletes('foo', None, (None, None, None))
+
+ res, msg = self.runOperation(['update'],
+ [foo11, foo12, foo13, bar11],
+ [foo20, bar12])
+ self.assert_(res=='ok', msg)
+ self.assertResult((bar12,))
More information about the Yum-commits
mailing list