diff --git a/pisi/build.py b/pisi/build.py index 706e7e04..5782e0ae 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -91,7 +91,7 @@ class PisiBuild: # check if source already cached destpath = fetch.filedest + "/" + fetch.filename if os.access(destpath, os.R_OK): - if util.md5_file(destpath) == self.spec.source.archiveMD5: + if util.sha1_file(destpath) == self.spec.source.archiveSHA1: ui.info('%s [cached]\n' % self.spec.source.archiveName) return diff --git a/pisi/files.py b/pisi/files.py index a7d0b4ef..706bdd55 100644 --- a/pisi/files.py +++ b/pisi/files.py @@ -7,7 +7,7 @@ class FileInfo: self.path = getNodeText(getNode(node, "Path")) self.type = getNodeText(getNode(node, "Type")) self.size = int(getNodeText(getNode(node, "Size"))) - self.md5Sum = getNodeText(getNode(node, "MD5Sum")) + self.hash = getNodeText(getNode(node, "Hash")) def elt(self, dom): ## FIXME: looking for a better way to do it @@ -19,12 +19,12 @@ class FileInfo: typeElt.appendChild(dom.createTextNode(type)) sizeElt = dom.createElement("Size") sizeElt.appendChild(dom.createTextNode(str(size))) - md5Elt = dom.createElement("MD5Sum") - md5Elt.appendChild(dom.createTextNode(md5sum)) + hashElt = dom.createElement("Hash") + hashElt.appendChild(dom.createTextNode(hash)) elt.appendChild(pathElt) elt.appendChild(typeElt) elt.appendChild(sizeElt) - elt.appendChild(md5Elt) + elt.appendChild(hashElt) return elt class Files(XmlFile): diff --git a/pisi/specfile.py b/pisi/specfile.py index ac25175d..b654108b 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -63,7 +63,7 @@ class SpecFile(XmlFile): self.source.archiveUri = getNodeText(archiveNode).strip() self.source.archiveName = basename(self.source.archiveUri) self.source.archiveType = getNodeAttribute(archiveNode, "archType") - self.source.archiveMD5 = getNodeAttribute(archiveNode, "md5sum") + self.source.archiveSHA1 = getNodeAttribute(archiveNode, "sha1sum") patchElts = self.getChildElts("Source/Patches") if patchElts: self.source.patches = [PatchInfo(p) for p in patchElts] diff --git a/pisi/util.py b/pisi/util.py index cd700f8e..91723112 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -4,7 +4,7 @@ import os import sys -import md5 +import sha import shutil import statvfs @@ -67,15 +67,15 @@ def get_file_hashes(top): for root, dirs, files in os.walk(top, topdown=False): for file in files: f = os.path.join(root, file) - yield (f, md5_file(f)) + yield (f, sha1_file(f)) def copy_dir(src, dest): """copy source dir to destination dir recursively""" raise UtilError("not implemented") -def md5_file(filename): - """calculate md5 hash of filename""" - m = md5.new() +def sha1_file(filename): + """calculate sha1 hash of filename""" + m = sha.new() f = file(filename, 'rb') for l in f: m.update(l) diff --git a/samples/popt/popt.pspec b/samples/popt/popt.pspec index de4ce80a..03f29f07 100644 --- a/samples/popt/popt.pspec +++ b/samples/popt/popt.pspec @@ -13,7 +13,7 @@ hotmail@redhat.com As-Is - + ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.1.x/popt-1.7.tar.gz diff --git a/tests/archivetests.py b/tests/archivetests.py index 14f639c2..617cb8b9 100644 --- a/tests/archivetests.py +++ b/tests/archivetests.py @@ -34,8 +34,8 @@ class ArchiveFileTestCase(unittest.TestCase): assert pathexists(testfile) # check file integrity - self.assertEqual(util.md5_file(testfile), - "171545adab7b51ebf6ec5575d3000a95") + self.assertEqual(util.sha1_file(testfile), + "5af9dd7d754f788cf511c57ce0af3d555fed009d") def testUnpackZip(self): ctx = context.Context("tests/sandbox/sandbox.pspec") @@ -57,8 +57,8 @@ class ArchiveFileTestCase(unittest.TestCase): assert pathexists(testfile) # check file integrity - self.assertEqual(util.md5_file(testfile), - "1e0c3f1e4664ee8ca67caea8b6b12ea4") + self.assertEqual(util.sha1_file(testfile), + "06d0ee5ba49eccae6bc20552d55b3ba5ad52995e") # check for symbolic links testfile = targetDir + "/sandbox/deneme/hed" diff --git a/tests/fetchertests.py b/tests/fetchertests.py index 03ae0ad0..a67f7102 100644 --- a/tests/fetchertests.py +++ b/tests/fetchertests.py @@ -16,8 +16,8 @@ class FetcherTestCase(unittest.TestCase): self.fetch.fetch() destpath = self.fetch.filedest + "/" + self.fetch.filename if os.access(destpath, os.R_OK): - self.assertEqual(util.md5_file(destpath), - self.ctx.spec.source.archiveMD5) + self.assertEqual(util.sha1_file(destpath), + self.ctx.spec.source.archiveSHA1) suite = unittest.makeSuite(FetcherTestCase) diff --git a/tests/sandbox/sandbox.pspec b/tests/sandbox/sandbox.pspec index 5660d106..a0eb04e5 100644 --- a/tests/sandbox/sandbox.pspec +++ b/tests/sandbox/sandbox.pspec @@ -13,7 +13,7 @@ meren@uludag.org.tr As-Is - + http://cekirdek.uludag.org.tr/~meren/sandbox.zip diff --git a/tests/specfiletests.py b/tests/specfiletests.py index f5a4d060..ca9d6b63 100644 --- a/tests/specfiletests.py +++ b/tests/specfiletests.py @@ -20,9 +20,9 @@ class SpecReadTestCase(unittest.TestCase): self.assertEqual(self.spec.source.release, "3") - def testMD5Sum(self): - self.assertEqual(self.spec.source.archiveMD5, - "5988e7aeb0ae4dac8d83561265984cc9") + def testSHA1Sum(self): + self.assertEqual(self.spec.source.archiveSHA1, + "66f3c77b87a160951b180447f4a6dce68ad2f71b") def testLenPackages(self): self.assertEqual(len(self.spec.packages), 1)