-Use python-debian for parsing RFC 822 files.
-
-There are already routines for parsing these files, so there is no need
-to write more. In the AptPackages, change the Release file parsing to
-use the python-debian routines.
-
-
Packages.diff files need to be considered.
The Packages.diff/Index files contain hashes of Packages.diff/rred.gz
import apt_pkg, apt_inst
from apt import OpProgress
+from debian_bundle import deb822
from Hash import HashObject
read_packages = False
f = file_path.open('r')
- for line in f:
- line = line.rstrip()
-
- if line[:1] != " ":
- read_packages = False
- try:
- # Read the various headers from the file
- h, v = line.split(":", 1)
- if h == "MD5Sum" or h == "SHA1" or h == "SHA256":
- read_packages = True
- hash_type = h
- except:
- # Bad header line, just ignore it
- log.msg("WARNING: Ignoring badly formatted Release line: %s" % line)
-
- # Skip to the next line
- continue
+ rel = deb822.Release(f, fields = ['MD5Sum', 'SHA1', 'SHA256'])
+ for hash_type in rel:
+ for file in rel[hash_type]:
+ self.indexrecords[cache_path].setdefault(file['name'], {})[hash_type.upper()] = (file['hash_type'], file['size'])
- # Read file names from the multiple hash sections of the file
- if read_packages:
- p = line.split()
- self.indexrecords[cache_path].setdefault(p[2], {})[hash_type] = (p[0], p[1])
-
f.close()
def file_updated(self, cache_path, file_path):
{'name': 'md5',
'AptPkgRecord': 'MD5Hash',
'AptSrcRecord': True,
- 'AptIndexRecord': 'MD5Sum',
+ 'AptIndexRecord': 'MD5SUM',
'old_module': 'md5',
'hashlib_func': 'md5',
},