summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Harring <ferringb@gmail.com>2011-09-01 14:36:45 -0700
committerZac Medico <zmedico@gentoo.org>2011-09-12 14:23:10 -0700
commit69613e420d5be52e413c7c60e571710c2597f58d (patch)
tree7c37eed391754ca8feb4f400e86811b2d68a1275
parentf908cddb505b81533861196c4713378e63dac1fa (diff)
downloadportage-69613e420d5be52e413c7c60e571710c2597f58d.tar.gz
portage-69613e420d5be52e413c7c60e571710c2597f58d.tar.bz2
portage-69613e420d5be52e413c7c60e571710c2597f58d.zip
add thin manifest support to the Manifest class
'thin' is just distfiles. This is primarily useful when the ebuild lives in a vcs- git for example, which already has it's own checksums to rely on.
-rw-r--r--pym/portage/manifest.py149
-rw-r--r--pym/portage/package/ebuild/digestcheck.py2
2 files changed, 97 insertions, 54 deletions
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py
index 13efab791..ef1a552e8 100644
--- a/pym/portage/manifest.py
+++ b/pym/portage/manifest.py
@@ -49,6 +49,12 @@ def guessManifestFileType(filename):
else:
return "DIST"
+def guessThinManifestFileType(filename):
+ type = guessManifestFileType(filename)
+ if type != "DIST":
+ return None
+ return "DIST"
+
def parseManifest2(mysplit):
myentry = None
if len(mysplit) > 4 and mysplit[0] in portage.const.MANIFEST2_IDENTIFIERS:
@@ -93,12 +99,14 @@ class Manifest2Entry(ManifestEntry):
class Manifest(object):
parsers = (parseManifest2,)
def __init__(self, pkgdir, distdir, fetchlist_dict=None,
- manifest1_compat=False, from_scratch=False):
+ manifest1_compat=False, from_scratch=False, thin=False):
""" create new Manifest instance for package in pkgdir
and add compability entries for old portage versions if manifest1_compat == True.
Do not parse Manifest file if from_scratch == True (only for internal use)
The fetchlist_dict parameter is required only for generation of
- a Manifest (not needed for parsing and checking sums)."""
+ a Manifest (not needed for parsing and checking sums).
+ If thin is specified, then the manifest carries only info for
+ distfiles."""
self.pkgdir = _unicode_decode(pkgdir).rstrip(os.sep) + os.sep
self.fhashdict = {}
self.hashes = set()
@@ -120,7 +128,11 @@ class Manifest(object):
else:
self.fetchlist_dict = {}
self.distdir = distdir
- self.guessType = guessManifestFileType
+ self.thin = thin
+ if thin:
+ self.guessType = guessThinManifestFileType
+ else:
+ self.guessType = guessManifestFileType
def getFullname(self):
""" Returns the absolute path to the Manifest file for this instance """
@@ -313,64 +325,20 @@ class Manifest(object):
distfilehashes = {}
self.__init__(self.pkgdir, self.distdir,
fetchlist_dict=self.fetchlist_dict, from_scratch=True,
- manifest1_compat=False)
- cpvlist = []
+ manifest1_compat=False, thin=self.thin)
pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
cat = self._pkgdir_category()
pkgdir = self.pkgdir
+ if self.thin:
+ cpvlist = self._update_thin_pkgdir(cat, pn, pkgdir)
+ else:
+ cpvlist = self._update_thick_pkgdir(cat, pn, pkgdir)
- for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
- break
- for f in pkgdir_files:
- try:
- f = _unicode_decode(f,
- encoding=_encodings['fs'], errors='strict')
- except UnicodeDecodeError:
- continue
- if f[:1] == ".":
- continue
- pf = None
- if f[-7:] == '.ebuild':
- pf = f[:-7]
- if pf is not None:
- mytype = "EBUILD"
- ps = portage.versions._pkgsplit(pf)
- cpv = "%s/%s" % (cat, pf)
- if not ps:
- raise PortagePackageException(
- _("Invalid package name: '%s'") % cpv)
- if ps[0] != pn:
- raise PortagePackageException(
- _("Package name does not "
- "match directory name: '%s'") % cpv)
- cpvlist.append(cpv)
- elif manifest2MiscfileFilter(f):
- mytype = "MISC"
- else:
- continue
- self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes)
- recursive_files = []
-
- pkgdir = self.pkgdir
- cut_len = len(os.path.join(pkgdir, "files") + os.sep)
- for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")):
- for f in files:
- try:
- f = _unicode_decode(f,
- encoding=_encodings['fs'], errors='strict')
- except UnicodeDecodeError:
- continue
- full_path = os.path.join(parentdir, f)
- recursive_files.append(full_path[cut_len:])
- for f in recursive_files:
- if not manifest2AuxfileFilter(f):
- continue
- self.fhashdict["AUX"][f] = perform_multiple_checksums(
- os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes)
distlist = set()
for cpv in cpvlist:
distlist.update(self._getCpvDistfiles(cpv))
+
if requiredDistfiles is None:
# This allows us to force removal of stale digests for the
# ebuild --force digest option (no distfiles are required).
@@ -404,6 +372,81 @@ class Manifest(object):
if f in requiredDistfiles:
raise
+ def _is_cpv(self, cat, pn, filename):
+ if not filename.endswith(".ebuild"):
+ return None
+ pf = filename[:-7]
+ if pf is None:
+ return None
+ ps = portage.versions._pkgsplit(pf)
+ cpv = "%s/%s" % (cat, pf)
+ if not ps:
+ raise PortagePackageException(
+ _("Invalid package name: '%s'") % cpv)
+ if ps[0] != pn:
+ raise PortagePackageException(
+ _("Package name does not "
+ "match directory name: '%s'") % cpv)
+ return cpv
+
+ def _update_thin_pkgdir(self, cat, pn, pkgdir):
+ for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
+ break
+ cpvlist = []
+ for f in pkgdir_files:
+ try:
+ f = _unicode_decode(f,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ continue
+ if f[:1] == '.':
+ continue
+ pf = self._is_cpv(cat, pn, f)
+ if pf is not None:
+ cpvlist.append(pf)
+ return cpvlist
+
+ def _update_thick_pkgdir(self, cat, pn, pkgdir):
+ cpvlist = []
+ for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(pkgdir):
+ break
+ for f in pkgdir_files:
+ try:
+ f = _unicode_decode(f,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ continue
+ if f[:1] == ".":
+ continue
+ pf = self._is_cpv(cat, pn, f)
+ if pf is not None:
+ mytype = "EBUILD"
+ cpvlist.append(pf)
+ elif manifest2MiscfileFilter(f):
+ mytype = "MISC"
+ else:
+ continue
+ self.fhashdict[mytype][f] = perform_multiple_checksums(self.pkgdir+f, self.hashes)
+ recursive_files = []
+
+ pkgdir = self.pkgdir
+ cut_len = len(os.path.join(pkgdir, "files") + os.sep)
+ for parentdir, dirs, files in os.walk(os.path.join(pkgdir, "files")):
+ for f in files:
+ try:
+ f = _unicode_decode(f,
+ encoding=_encodings['fs'], errors='strict')
+ except UnicodeDecodeError:
+ continue
+ full_path = os.path.join(parentdir, f)
+ recursive_files.append(full_path[cut_len:])
+ for f in recursive_files:
+ if not manifest2AuxfileFilter(f):
+ continue
+ self.fhashdict["AUX"][f] = perform_multiple_checksums(
+ os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes)
+ return cpvlist
+
def _pkgdir_category(self):
return self.pkgdir.rstrip(os.sep).split(os.sep)[-2]
diff --git a/pym/portage/package/ebuild/digestcheck.py b/pym/portage/package/ebuild/digestcheck.py
index d18430160..466fd059e 100644
--- a/pym/portage/package/ebuild/digestcheck.py
+++ b/pym/portage/package/ebuild/digestcheck.py
@@ -92,7 +92,7 @@ def digestcheck(myfiles, mysettings, strict=False, justmanifest=None, mf=None):
writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1)
writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1)
return 0
- if allow_missing:
+ if allow_missing or mf.thin:
# In this case we ignore any missing digests that
# would otherwise be detected below.
return 1