Merged from trunk 8419:8432
authorFabian Groffen <grobian@gentoo.org>
Mon, 5 Nov 2007 21:06:30 +0000 (21:06 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 5 Nov 2007 21:06:30 +0000 (21:06 -0000)
   | 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

bin/emaint
bin/repoman
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/manifest.py
pym/portage/sets/base.py
pym/repoman/errors.py

index b8be2fe722157da0d46e46c2eb547c03cc3818cb..ef03c247720965ff08f00a5f3ea825dff4d08fab 100755 (executable)
@@ -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):
 
index fd9637ac3ca05c07de898ad086c086e738edf591..1eecd5b0513c1eed3795e84bcedaf7c154dbcaeb 100755 (executable)
@@ -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:
index db8b192aedac51be7497be59294ca984a81b9ecf..a4c87fd5aa46c4045ac7434c7bee3047562a1886 100644 (file)
@@ -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:
index ea51f5d7e948dba9eb53b99d5436c86ce70b6902..db2b35aff6aa7af8a60af8d95e9ff37d36254ad0 100644 (file)
@@ -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 " + \
index 3116922b7ef68336fed134845a09868e205cf9fb..93182f7648c544183192fa99bc8b954d1cc95c76 100644 (file)
@@ -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))
index 85f2e410b64a31af6f76cf7a8f01fa605fb9baf3..f360632ede3f3ef4e0fc583fa17751883f167679 100644 (file)
@@ -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)
index 3b3b3c179ff368a7a3fdb295826e245743a7f807..d1aad1d8a2ed7850d453f2e4ff0c35d02a414fe6 100644 (file)
@@ -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'