Bug #198398 - Enable Manifest generation when there are no hash
authorZac Medico <zmedico@gentoo.org>
Wed, 21 Nov 2007 03:55:53 +0000 (03:55 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 21 Nov 2007 03:55:53 +0000 (03:55 -0000)
functions available for types such as RMD160. Now it's possible
to generate a Manifest when python-2.5 is built without ssl
support. MANIFEST1_REQUIRED_HASH and MANIFEST2_REQUIRED_HASH
are the only two functions that are strictly required now (MD5
and SHA1). (trunk r8521)

svn path=/main/branches/2.1.2/; revision=8566

pym/portage_const.py
pym/portage_manifest.py

index c27764e4635bbcdbbcb2d7885768e530b2ef6178..42c5dfae6e4c1002c879350efec4348cff1126c8 100644 (file)
@@ -60,6 +60,8 @@ EAPI = 1
 HASHING_BLOCKSIZE        = 32768
 MANIFEST1_HASH_FUNCTIONS = ["MD5","SHA256","RMD160"]
 MANIFEST2_HASH_FUNCTIONS = ["SHA1","SHA256","RMD160"]
+
+MANIFEST1_REQUIRED_HASH = "MD5"
 MANIFEST2_REQUIRED_HASH = "SHA1"
 
 MANIFEST2_IDENTIFIERS = ["AUX","MISC","DIST","EBUILD"]
index 59818adaf1f5f9d151241cbad0bdbf026156ee88..502cc06a10f33fc49f36c6baed748be357a61dec 100644 (file)
@@ -109,11 +109,16 @@ class Manifest(object):
                        a Manifest (not needed for parsing and checking sums)."""
                self.pkgdir = pkgdir.rstrip(os.sep) + os.sep
                self.fhashdict = {}
-               self.hashes = portage_const.MANIFEST2_HASH_FUNCTIONS[:]
-               self.hashes.append("size")
+               self.hashes = set()
+               self.hashes.update(portage_const.MANIFEST2_HASH_FUNCTIONS)
                if manifest1_compat:
-                       self.hashes.extend(portage_const.MANIFEST1_HASH_FUNCTIONS)
-               self.hashes = sets.Set(self.hashes)
+                       self.hashes.update(portage_const.MANIFEST1_HASH_FUNCTIONS)
+               self.hashes.difference_update(hashname for hashname in \
+                       list(self.hashes) if hashname not in hashfunc_map)
+               self.hashes.add("size")
+               if manifest1_compat:
+                       self.hashes.add(portage_const.MANIFEST1_REQUIRED_HASH)
+               self.hashes.add(portage_const.MANIFEST2_REQUIRED_HASH)
                for t in portage_const.MANIFEST2_IDENTIFIERS:
                        self.fhashdict[t] = {}
                self.compat = manifest1_compat
@@ -329,11 +334,16 @@ class Manifest(object):
                if self.compat:
                        cvp_list = self.fetchlist_dict.keys()
                        cvp_list.sort()
+                       manifest1_hashes = set(hashname for hashname in \
+                               portage_const.MANIFEST1_HASH_FUNCTIONS \
+                               if hashname in hashfunc_map)
+                       manifest1_hashes.add(portage_const.MANIFEST1_REQUIRED_HASH)
+                       manifest1_hashes.add("size")
                        for cpv in cvp_list:
                                digest_path = os.path.join("files", "digest-%s" % self._catsplit(cpv)[1])
                                dname = os.path.join(self.pkgdir, digest_path)
                                try:
-                                       myhashes = perform_multiple_checksums(dname, portage_const.MANIFEST1_HASH_FUNCTIONS+["size"])
+                                       myhashes = perform_multiple_checksums(dname, manifest1_hashes)
                                        myhashkeys = myhashes.keys()
                                        myhashkeys.sort()
                                        for h in myhashkeys: