During the work on Spacewalk I tried to create repomd.xml file with more
checksums in that file. See:
https://www.redhat.com/archives/spacewalk-devel/2009-June/msg00021.html
for more info. But it's safe to skip.
But it takes only few moments that I find in yum code, that yum will
pickup only last checksum it will find... :(
So I created patch for yum which will pickup only checksums, which are
known to yum.
See attachment.
Can you please review it and if find appropriate, merge to git?
I tested it only on repomd.xml, but would like to have the same
functionality on filelists.xml.gz, other.xml.gz, primary.xml.gz.
I did not try to fiddle with those tree yet. Does repoMDObject.py parse
those file too. Or some other file does that job, can you give me pointers?
--
Miroslav Suchy
Red Hat Satellite Engineering
>From 44eaca365095f45a03a9bcdc4c554bc43c85744a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miroslav=20Such=C3=BD?= <msuchy@xxxxxxxxxx>
Date: Fri, 26 Jun 2009 16:09:21 +0200
Subject: [PATCH] recognize sha as equal to sha1
---
yum/misc.py | 9 +++------
1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/yum/misc.py b/yum/misc.py
index 9f47262..9c5e7ff 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -24,13 +24,13 @@ except ImportError:
gpgme = None
try:
import hashlib
- _available_checksums = ['md5', 'sha1', 'sha256', 'sha512']
+ _available_checksums = ['md5', 'sha', 'sha1', 'sha256', 'sha512']
_default_checksums = ['sha256']
except ImportError:
# Python-2.4.z ... gah!
import sha
import md5
- _available_checksums = ['md5', 'sha1']
+ _available_checksums = ['md5', 'sha', 'sha1']
_default_checksums = ['sha1']
class hashlib:
@@ -38,7 +38,7 @@ except ImportError:
def new(algo):
if algo == 'md5':
return md5.new()
- if algo == 'sha1':
+ if algo == 'sha1' or algo=='sha':
return sha.new()
raise ValueError, "Bad checksum type"
@@ -278,9 +278,6 @@ def checksum(sumtype, file, CHUNK=2**16):
else:
fo = open(file, 'r', CHUNK)
- if sumtype == 'sha':
- sumtype = 'sha1'
-
data = Checksums([sumtype])
while data.read(fo, CHUNK):
pass
--
1.5.5.6
>From 12ffab161002286f86b500ceb40898996aa96726 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miroslav=20Such=C3=BD?= <msuchy@xxxxxxxxxx>
Date: Fri, 26 Jun 2009 16:32:57 +0200
Subject: [PATCH] accept more checksums in repomd file, pickup only which we know
---
yum/repoMDObject.py | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index 298d369..a11f9ba 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -23,7 +23,7 @@ from Errors import RepoMDError
import sys
import types
-from misc import AutoFileChecksums
+from misc import AutoFileChecksums, _available_checksums
def ns_cleanup(qn):
if qn.find('}') == -1: return qn
@@ -53,7 +53,8 @@ class RepoData:
elif child_name == 'checksum':
csum_value = child.text
csum_type = child.attrib.get('type')
- self.checksum = (csum_type,csum_value)
+ if csum_type in _available_checksums:
+ self.checksum = (csum_type,csum_value)
elif child_name == 'open-checksum':
csum_value = child.text
--
1.5.5.6
>From 73414b1d28fd15788dd7cadc12f9bdcc886ff741 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Miroslav=20Such=C3=BD?= <msuchy@xxxxxxxxxx>
Date: Fri, 26 Jun 2009 16:44:25 +0200
Subject: [PATCH] prefer default checksums rather then some other
---
yum/repoMDObject.py | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/yum/repoMDObject.py b/yum/repoMDObject.py
index a11f9ba..b01edf5 100755
--- a/yum/repoMDObject.py
+++ b/yum/repoMDObject.py
@@ -23,7 +23,7 @@ from Errors import RepoMDError
import sys
import types
-from misc import AutoFileChecksums, _available_checksums
+from misc import AutoFileChecksums, _available_checksums, _default_checksums
def ns_cleanup(qn):
if qn.find('}') == -1: return qn
@@ -54,7 +54,9 @@ class RepoData:
csum_value = child.text
csum_type = child.attrib.get('type')
if csum_type in _available_checksums:
- self.checksum = (csum_type,csum_value)
+ if (self.checksum and csum_type in _default_checksums) \
+ or self.checksum == (None, None):
+ self.checksum = (csum_type,csum_value)
elif child_name == 'open-checksum':
csum_value = child.text
--
1.5.5.6
_______________________________________________
Yum mailing list
Yum@xxxxxxxxxxxxxxxxx
http://lists.baseurl.org/mailman/listinfo/yum