from portage.exception import DigestException, FileNotFound, \
InvalidDataType, MissingParameter, PermissionDenied, \
PortageException, PortagePackageException
-from portage.const import (MANIFEST2_HASH_DEFAULTS,
- MANIFEST2_HASH_FUNCTIONS, MANIFEST2_REQUIRED_HASH)
+from portage.const import (MANIFEST1_HASH_FUNCTIONS, MANIFEST2_HASH_DEFAULTS,
+ MANIFEST2_HASH_FUNCTIONS, MANIFEST2_IDENTIFIERS, MANIFEST2_REQUIRED_HASH)
from portage.localization import _
class FileNotInManifestException(PortageException):
def parseManifest2(mysplit):
myentry = None
- if len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS:
+ if len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS:
mytype = mysplit[0]
myname = mysplit[1]
try:
self.hashes.difference_update(hashname for hashname in \
list(self.hashes) if hashname not in hashfunc_map)
self.hashes.add("size")
- self.hashes.add(portage.const.MANIFEST2_REQUIRED_HASH)
- for t in portage.const.MANIFEST2_IDENTIFIERS:
+ self.hashes.add(MANIFEST2_REQUIRED_HASH)
+ for t in MANIFEST2_IDENTIFIERS:
self.fhashdict[t] = {}
if not from_scratch:
self._read()
def getDigests(self):
""" Compability function for old digest/manifest code, returns dict of filename:{hashfunction:hashvalue} """
rval = {}
- for t in portage.const.MANIFEST2_IDENTIFIERS:
+ for t in MANIFEST2_IDENTIFIERS:
rval.update(self.fhashdict[t])
return rval
return myhashdict
def _createManifestEntries(self):
- valid_hashes = set(portage.const.MANIFEST2_HASH_FUNCTIONS)
+ valid_hashes = set(MANIFEST2_HASH_FUNCTIONS)
valid_hashes.add('size')
mytypes = list(self.fhashdict)
mytypes.sort()
def checkIntegrity(self):
for t in self.fhashdict:
for f in self.fhashdict[t]:
- if portage.const.MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
- raise MissingParameter(_("Missing %s checksum: %s %s") % (portage.const.MANIFEST2_REQUIRED_HASH, t, f))
+ if MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]:
+ raise MissingParameter(_("Missing %s checksum: %s %s") %
+ (MANIFEST2_REQUIRED_HASH, t, f))
def write(self, sign=False, force=False):
""" Write Manifest instance to disk, optionally signing it """
fname = os.path.join("files", fname)
if not os.path.exists(self.pkgdir+fname) and not ignoreMissing:
raise FileNotFound(fname)
- if not ftype in portage.const.MANIFEST2_IDENTIFIERS:
+ if not ftype in MANIFEST2_IDENTIFIERS:
raise InvalidDataType(ftype)
if ftype == "AUX" and fname.startswith("files"):
fname = fname[6:]
self.fhashdict[ftype][fname] = {}
if hashdict != None:
self.fhashdict[ftype][fname].update(hashdict)
- if not portage.const.MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
+ if not MANIFEST2_REQUIRED_HASH in self.fhashdict[ftype][fname]:
self.updateFileHashes(ftype, fname, checkExisting=False, ignoreMissing=ignoreMissing)
def removeFile(self, ftype, fname):
def findFile(self, fname):
""" Return entrytype of the given file if present in Manifest or None if not present """
- for t in portage.const.MANIFEST2_IDENTIFIERS:
+ for t in MANIFEST2_IDENTIFIERS:
if fname in self.fhashdict[t]:
return t
return None
requiredDistfiles = distlist.copy()
required_hash_types = set()
required_hash_types.add("size")
- required_hash_types.add(portage.const.MANIFEST2_REQUIRED_HASH)
+ required_hash_types.add(MANIFEST2_REQUIRED_HASH)
for f in distlist:
fname = os.path.join(self.distdir, f)
mystat = None
return absname
def checkAllHashes(self, ignoreMissingFiles=False):
- for t in portage.const.MANIFEST2_IDENTIFIERS:
+ for t in MANIFEST2_IDENTIFIERS:
self.checkTypeHashes(t, ignoreMissingFiles=ignoreMissingFiles)
def checkTypeHashes(self, idtype, ignoreMissingFiles=False):
def updateAllHashes(self, checkExisting=False, ignoreMissingFiles=True):
""" Regenerate all hashes for all files in this Manifest. """
- for idtype in portage.const.MANIFEST2_IDENTIFIERS:
+ for idtype in MANIFEST2_IDENTIFIERS:
self.updateTypeHashes(idtype, checkExisting=checkExisting,
ignoreMissingFiles=ignoreMissingFiles)
myfile.close()
for l in lines:
mysplit = l.split()
- if len(mysplit) == 4 and mysplit[0] in portage.const.MANIFEST1_HASH_FUNCTIONS and not 1 in rVal:
+ if len(mysplit) == 4 and mysplit[0] in MANIFEST1_HASH_FUNCTIONS \
+ and 1 not in rVal:
rVal.append(1)
- elif len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
+ elif len(mysplit) > 4 and mysplit[0] in MANIFEST2_IDENTIFIERS \
+ and ((len(mysplit) - 3) % 2) == 0 and not 2 in rVal:
rVal.append(2)
return rVal