From: Fabian Groffen Date: Mon, 5 Nov 2007 21:06:30 +0000 (-0000) Subject: Merged from trunk 8419:8432 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=4a08280f838e2ff72bc3f164bf823fbda6dea4d3;p=portage.git Merged from trunk 8419:8432 | 8420 | When evaluating *DEPEND conditionals for the Packages | | zmedico | metadata index, do not use IUSE to filter USE since there is | | | currently no guarantee that IUSE properly defines all of the | | | necessary flags. | | 8421 | In portdbapi.cp_list(), validate the ebuild name to ensure | | zmedico | that it matches the name of the package. | | 8423 | Make Manifest.create() do some basic validation of ebuild | | zmedico | file names like portdbapi.cp_list() would do. | | 8426 | Make exception strings more informative. | | zmedico | | | 8428 | Replace StringIO usage with a simple list of lines. The | | zmedico | iteration interface is practically identical but the list of | | | lines if more efficient because the lines only have to be | | | split one time for each ebuild instead of for each check. | | 8429 | Fix 'TypeError: not all arguments converted during string | | zmedico | formatting' issues with the EbuildNestedDie check. | | 8431 | Add support for package sets in WorldHandler. | | zmedico | | | 8432 | Make WorldHandler lock the world file when in --fix mode. | | zmedico | | svn path=/main/branches/prefix/; revision=8435 --- diff --git a/bin/emaint b/bin/emaint index b8be2fe72..ef03c2477 100755 --- a/bin/emaint +++ b/bin/emaint @@ -24,6 +24,10 @@ class WorldHandler(object): self.not_installed = [] self.invalid_category = [] self.okay = [] + from portage.sets import make_default_config + setconfig = make_default_config(portage.settings, + portage.db[portage.settings["ROOT"]]) + self._sets = setconfig.getSetsWithAliases() def _check_world(self, onProgress): categories = set(portage.settings.categories) @@ -32,13 +36,22 @@ class WorldHandler(object): self.found = os.access(self.world_file, os.R_OK) vardb = portage.db[myroot]["vartree"].dbapi - world_atoms = open(self.world_file).read().split() + from portage.sets import SETPREFIX + sets = self._sets + world_atoms = list(sets["world"]) maxval = len(world_atoms) if onProgress: onProgress(maxval, 0) for i, atom in enumerate(world_atoms): if not portage.isvalidatom(atom): - self.invalid.append(atom) + if atom.startswith(SETPREFIX): + s = atom[len(SETPREFIX):] + if s in sets: + self.okay.append(atom) + else: + self.not_installed.append(atom) + else: + self.invalid.append(atom) if onProgress: onProgress(maxval, i+1) continue @@ -67,14 +80,23 @@ class WorldHandler(object): return errors def fix(self, onProgress=None): - self._check_world(onProgress) - errors = [] + world_set = self._sets["world"] + world_set.lock() try: - portage.write_atomic(self.world_file, - "\n".join(sorted(self.okay)) + "\n") - except portage.exception.PortageException: - errors.append(self.world_file + " could not be opened for writing") - return errors + world_set.load() # maybe it's changed on disk + before = set(world_set) + self._check_world(onProgress) + after = set(self.okay) + errors = [] + if before != after: + try: + world_set.replace(self.okay) + except portage.exception.PortageException: + errors.append("%s could not be opened for writing" % \ + self.world_file) + return errors + finally: + world_set.unlock() class BinhostHandler(object): diff --git a/bin/repoman b/bin/repoman index fd9637ac3..1eecd5b05 100755 --- a/bin/repoman +++ b/bin/repoman @@ -52,11 +52,6 @@ except ImportError: from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \ EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc, EbuildUselessCdS -try: - import cStringIO as StringIO -except ImportError: - import StringIO - import portage.checksum import portage.const import portage.dep @@ -1439,7 +1434,12 @@ for x in scanlist: # Syntax Checks path = checkdir + '/' + y + '.ebuild' myear = time.gmtime(os.stat(path)[ST_MTIME])[0] - contents = StringIO.StringIO(open(path, 'rb').read()) + f = open(path, 'rb') + try: + contents = f.readlines() + finally: + f.close() + del f for check in (EbuildWhitespace, EbuildQuote, EbuildAssignment, EbuildUselessDodoc, EbuildUselessCdS): c = check(contents) @@ -1447,20 +1447,19 @@ for x in scanlist: for e in errors: stats[c.repoman_check_name] += 1 fails[c.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0]) - contents.seek(0) # move fp to the beginning of the StringIO Object del check check = EbuildHeader(contents, str(myear)) errors = check.Run() for e in errors: stats[check.repoman_check_name] += 1 fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0]) - contents.seek(0) del check check = EbuildNestedDie(contents) errors = check.Run() for e in errors: stats[check.repoman_check_name] += 1 - fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e) + fails[check.repoman_check_name].append( + x + '/' + y + '.ebuild: %s' % e[1] % e[0]) del check, errors, path, contents, myear if options.force: diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index db8b192ae..a4c87fd5a 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -807,6 +807,7 @@ class binarytree(object): metadata["DESC"] = metadata["DESCRIPTION"] del metadata["DESCRIPTION"] use = metadata["USE"].split() + raw_use = use iuse = set(metadata["IUSE"].split()) use = [f for f in use if f in iuse] use.sort() @@ -816,7 +817,7 @@ class binarytree(object): for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE": try: deps = paren_reduce(metadata[k]) - deps = use_reduce(deps, uselist=use) + deps = use_reduce(deps, uselist=raw_use) deps = paren_normalize(deps) deps = paren_enclose(deps) except portage.exception.InvalidDependString, e: diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index ea51f5d7e..db2b35aff 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -523,6 +523,10 @@ class portdbapi(dbapi): writemsg("\nInvalid ebuild name: %s\n" % \ os.path.join(oroot, mycp, x), noiselevel=-1) continue + if ps[0] != mysplit[1]: + writemsg("\nInvalid ebuild name: %s\n" % \ + os.path.join(oroot, mycp, x), noiselevel=-1) + continue d[mysplit[0]+"/"+pf] = None if invalid_category and d: writemsg(("\n!!! '%s' has a category that is not listed in " + \ diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 3116922b7..93182f764 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -441,11 +441,25 @@ class Manifest(object): self.__init__(self.pkgdir, self.distdir, fetchlist_dict=self.fetchlist_dict, from_scratch=True, manifest1_compat=self.compat) + cpvlist = [] + pn = os.path.basename(self.pkgdir.rstrip(os.path.sep)) + cat = self._pkgdir_category() for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(self.pkgdir): break for f in pkgdir_files: if f.endswith(".ebuild"): mytype = "EBUILD" + pf = f[:-7] + 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: @@ -462,7 +476,6 @@ class Manifest(object): continue self.fhashdict["AUX"][f] = perform_multiple_checksums( os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes) - cpvlist = [os.path.join(self._pkgdir_category(), x[:-7]) for x in os.listdir(self.pkgdir) if x.endswith(".ebuild")] distlist = set() for cpv in cpvlist: distlist.update(self._getCpvDistfiles(cpv)) diff --git a/pym/portage/sets/base.py b/pym/portage/sets/base.py index 85f2e410b..f360632ed 100644 --- a/pym/portage/sets/base.py +++ b/pym/portage/sets/base.py @@ -58,7 +58,7 @@ class PackageSet(object): def _setAtoms(self, atoms): atoms = map(str.strip, atoms) - nonatoms = set() + self._nonatoms.clear() for a in atoms[:]: if a == "": atoms.remove(a) diff --git a/pym/repoman/errors.py b/pym/repoman/errors.py index 3b3b3c179..d1aad1d8a 100644 --- a/pym/repoman/errors.py +++ b/pym/repoman/errors.py @@ -10,5 +10,5 @@ LEADING_SPACES_ERROR = 'Ebuild contains leading spaces on line: %d' TRAILING_WHITESPACE_ERROR = 'Trailing whitespace error on line: %d' READONLY_ASSIGNMENT_ERROR = 'Ebuild contains assignment to read-only variable on line: %d' MISSING_QUOTES_ERROR = 'Unquoted Variable on line: %d' -NESTED_DIE_ERROR = 'Ebuild calls die in a subshell' +NESTED_DIE_ERROR = 'Ebuild calls die in a subshell on line: %d' REDUNDANT_CD_S_ERROR = 'Ebuild has redundant cd ${S} statement on line: %d'