[yum-commits] Branch 'yum-3_2_X' - 3 commits - yum/metalink.py yum/misc.py yum/repoMDObject.py yum/transactioninfo.py yum/yumRepo.py

James Antill james at osuosl.org
Tue Dec 8 18:07:42 UTC 2009


 yum/metalink.py        |    1 +
 yum/misc.py            |   12 ++++++++----
 yum/repoMDObject.py    |    7 ++++---
 yum/transactioninfo.py |    2 +-
 yum/yumRepo.py         |   12 +++---------
 5 files changed, 17 insertions(+), 17 deletions(-)

New commits:
commit e3759dbba8f9fa1d824cbc81001c5215ed3ed685
Author: James Antill <james at and.org>
Date:   Tue Dec 8 13:07:17 2009 -0500

    Don't die if sha2+ is not available, and we aren't using metalink

diff --git a/yum/misc.py b/yum/misc.py
index 642f9a2..1d2ef15 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -210,7 +210,7 @@ class Checksums:
     """ Generate checksum(s), on given pieces of data. Producing the
         Length and the result(s) when complete. """
 
-    def __init__(self, checksums=None, ignore_missing=False):
+    def __init__(self, checksums=None, ignore_missing=False, ignore_none=False):
         if checksums is None:
             checksums = _default_checksums
         self._sumalgos = []
@@ -233,7 +233,7 @@ class Checksums:
             done.add(sumtype)
             self._sumtypes.append(sumtype)
             self._sumalgos.append(sumalgo)
-        if not done:
+        if not done and not ignore_none:
             raise MiscError, 'Error Checksumming, no valid checksum type'
 
     def __len__(self):
@@ -257,6 +257,8 @@ class Checksums:
 
     def hexdigest(self, checksum=None):
         if checksum is None:
+            if not self._sumtypes:
+                return None
             checksum = self._sumtypes[0]
         if checksum == 'sha':
             checksum = 'sha1'
@@ -270,6 +272,8 @@ class Checksums:
 
     def digest(self, checksum=None):
         if checksum is None:
+            if not self._sumtypes:
+                return None
             checksum = self._sumtypes[0]
         if checksum == 'sha':
             checksum = 'sha1'
@@ -280,9 +284,9 @@ class AutoFileChecksums:
     """ Generate checksum(s), on given file/fileobject. Pretending to be a file
         object (overrrides read). """
 
-    def __init__(self, fo, checksums, ignore_missing=False):
+    def __init__(self, fo, checksums, ignore_missing=False, ignore_none=False):
         self._fo       = fo
-        self.checksums = Checksums(checksums, ignore_missing)
+        self.checksums = Checksums(checksums, ignore_missing, ignore_none)
 
     def __getattr__(self, attr):
         return getattr(self._fo, attr)
diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index 2931816..0021d94 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -97,7 +97,7 @@ class RepoMD:
 
         # We trust any of these to mean the repomd.xml is valid.
         infile = AutoFileChecksums(infile, ['sha256', 'sha512'],
-                                   ignore_missing=True)
+                                   ignore_missing=True, ignore_none=True)
         parser = iterparse(infile)
         
         try:
commit 22ecad28c78dfbf08bc3d3cb80c4c1915f2bb3f8
Author: James Antill <james at and.org>
Date:   Mon Dec 7 19:08:45 2009 -0500

    Fix md5 == abort() code path, only generate/trust sha2+ for metalink=>repomd

diff --git a/yum/metalink.py b/yum/metalink.py
index c7f5f83..24da633 100755
--- a/yum/metalink.py
+++ b/yum/metalink.py
@@ -55,6 +55,7 @@ class MetaLinkFile:
     """ Parse the file metadata out of a metalink file. """
 
     def __init__(self, elem):
+        # We aren't "using" any of these, just storing them.
         chksums = set(["md5", 'sha1', 'sha256', 'sha512'])
 
         for celem in elem:
diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index 9f70f1d..2931816 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -94,8 +94,9 @@ class RepoMD:
         else:
             # srcfile is a file object
             infile = srcfile
-        
-        infile = AutoFileChecksums(infile, ['md5', 'sha1', 'sha256'],
+
+        # We trust any of these to mean the repomd.xml is valid.
+        infile = AutoFileChecksums(infile, ['sha256', 'sha512'],
                                    ignore_missing=True)
         parser = iterparse(infile)
         
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 765a595..b97f05a 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1145,22 +1145,16 @@ class YumRepository(Repository, config.RepoConf):
         if repoXML.length != repomd.size:
             return False
 
-        #  MirrorManager isn't generating sha256 yet, and we should probably
-        # not require all of the checksums we produce.
-        done = set()
         for checksum in repoXML.checksums:
             if checksum not in repomd.chksums:
                 continue
 
             if repoXML.checksums[checksum] != repomd.chksums[checksum]:
                 return False
-            done.add(checksum)
 
-        #  Only allow approved checksums, might want to not "approve" of
-        # sha1/md5
-        for checksum in ('sha512', 'sha256', 'sha1', 'md5'):
-            if checksum in done:
-                return True
+            #  If we don't trust the checksum, then don't generate it in
+            # repoMDObject().
+            return True
 
         return False
 
commit 78f12c4a965f8444ab4ef7d377c4a55f33365139
Author: James Antill <james at and.org>
Date:   Fri Dec 4 11:02:07 2009 -0500

    Output txmbr evr as e:v-r instead of e-v-r

diff --git a/yum/transactioninfo.py b/yum/transactioninfo.py
index a00342c..c235e69 100644
--- a/yum/transactioninfo.py
+++ b/yum/transactioninfo.py
@@ -666,7 +666,7 @@ class TransactionMember:
         return object.__hash__(self)
             
     def __str__(self):
-        return "%s.%s %s-%s-%s - %s" % (self.name, self.arch, self.epoch,
+        return "%s.%s %s:%s-%s - %s" % (self.name, self.arch, self.epoch,
                                         self.version, self.release, self.ts_state)
 
     def __repr__(self):


More information about the Yum-commits mailing list