Merged from trunk -r14435:14442
authorFabian Groffen <grobian@gentoo.org>
Sun, 27 Sep 2009 09:17:01 +0000 (09:17 -0000)
committerFabian Groffen <grobian@gentoo.org>
Sun, 27 Sep 2009 09:17:01 +0000 (09:17 -0000)
   | 14442   | Bug #286522 - Check all portdbapi.findname return values in  |
   | zmedico | case it returns None, and raise 'ebuild not found'           |
   |         | exceptions when necessary.                                   |

svn path=/main/branches/prefix/; revision=14444

pym/_emerge/EbuildBinpkg.py
pym/_emerge/EbuildBuild.py
pym/_emerge/EbuildBuildDir.py
pym/_emerge/EbuildFetcher.py
pym/_emerge/EbuildFetchonly.py
pym/_emerge/MetadataRegen.py
pym/_emerge/Scheduler.py
pym/_emerge/depgraph.py
pym/portage/dbapi/porttree.py

index 8d742d6405a0a328e1161522027425a2365c7f0b..73297ed6b3c51aebb637dc53b2e50f7e6b89bc54 100644 (file)
@@ -18,7 +18,9 @@ class EbuildBinpkg(EbuildProcess):
                root_config = pkg.root_config
                portdb = root_config.trees["porttree"].dbapi
                bintree = root_config.trees["bintree"]
-               ebuild_path = portdb.findname(self.pkg.cpv)
+               ebuild_path = portdb.findname(pkg.cpv)
+               if ebuild_path is None:
+                       raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
                settings = self.settings
                debug = settings.get("PORTAGE_DEBUG") == "1"
 
index 3bf9b1b3d1f8f7b2132c4b5552d7dcb678e7f9b9..501c74fbe4dbd54bca6cab0bb185b701d378ffcb 100644 (file)
@@ -38,7 +38,9 @@ class EbuildBuild(CompositeTask):
                portdb = root_config.trees[tree].dbapi
                settings.setcpv(pkg)
                settings.configdict["pkg"]["EMERGE_FROM"] = pkg.type_name
-               ebuild_path = portdb.findname(self.pkg.cpv)
+               ebuild_path = portdb.findname(pkg.cpv)
+               if ebuild_path is None:
+                       raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
                self._ebuild_path = ebuild_path
 
                prefetcher = self.prefetcher
index 0a7c958adfc16ecb57c1a69db90294f0e2a207d0..d9e0fbb7bbed104e14c1d1e69b31a552ab6e9455 100644 (file)
@@ -32,6 +32,9 @@ class EbuildBuildDir(SlotObject):
                        root_config = self.pkg.root_config
                        portdb = root_config.trees["porttree"].dbapi
                        ebuild_path = portdb.findname(self.pkg.cpv)
+                       if ebuild_path is None:
+                               raise AssertionError(
+                                       "ebuild not found for '%s'" % self.pkg.cpv)
                        settings = self.settings
                        settings.setcpv(self.pkg)
                        debug = settings.get("PORTAGE_DEBUG") == "1"
index 7b1893ad625939e5089e3ddc6b09320db4a11d0e..cf759a9314d9baec26153603a2bbc80edb397813 100644 (file)
@@ -24,6 +24,8 @@ class EbuildFetcher(SpawnProcess):
                root_config = self.pkg.root_config
                portdb = root_config.trees["porttree"].dbapi
                ebuild_path = portdb.findname(self.pkg.cpv)
+               if ebuild_path is None:
+                       raise AssertionError("ebuild not found for '%s'" % self.pkg.cpv)
                settings = self.config_pool.allocate()
                settings.setcpv(self.pkg)
 
index 256a06c6902d43f5379719e108ad0173496612b5..147e824f285aba32b8da6d14e8ac5fb666aff35b 100644 (file)
@@ -17,6 +17,8 @@ class EbuildFetchonly(SlotObject):
                pkg = self.pkg
                portdb = pkg.root_config.trees["porttree"].dbapi
                ebuild_path = portdb.findname(pkg.cpv)
+               if ebuild_path is None:
+                       raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
                settings.setcpv(pkg)
                debug = settings.get("PORTAGE_DEBUG") == "1"
 
@@ -64,6 +66,8 @@ class EbuildFetchonly(SlotObject):
                root_config = pkg.root_config
                portdb = root_config.trees["porttree"].dbapi
                ebuild_path = portdb.findname(pkg.cpv)
+               if ebuild_path is None:
+                       raise AssertionError("ebuild not found for '%s'" % pkg.cpv)
                debug = settings.get("PORTAGE_DEBUG") == "1"
                retval = portage.doebuild(ebuild_path, "fetch",
                        self.settings["ROOT"], self.settings, debug=debug,
index 287312e17944a56343a9919ec51fa13ece6b6c36..6ff61f571e123cf30947af2a76e408aa1f839e96 100644 (file)
@@ -60,6 +60,8 @@ class MetadataRegen(PollScheduler):
                        for cpv in cpv_list:
                                valid_pkgs.add(cpv)
                                ebuild_path, repo_path = portdb.findname2(cpv)
+                               if ebuild_path is None:
+                                       raise AssertionError("ebuild not found for '%s'" % cpv)
                                metadata, st, emtime = portdb._pull_valid_cache(
                                        cpv, ebuild_path, repo_path)
                                if metadata is not None:
index 78b9e57d8f23165a3bb25a050830bdc4fb6315bc..b6f08307d4e137ec551b80ebd2eeca68cc331d94 100644 (file)
@@ -580,11 +580,8 @@ class Scheduler(PollScheduler):
                                continue
                        portdb = x.root_config.trees['porttree'].dbapi
                        ebuild_path = portdb.findname(x.cpv)
-                       if not ebuild_path:
-                               writemsg_level(
-                                       "!!! Could not locate ebuild for '%s'.\n" \
-                                       % x.cpv, level=logging.ERROR, noiselevel=-1)
-                               return 1
+                       if ebuild_path is None:
+                               raise AssertionError("ebuild not found for '%s'" % x.cpv)
                        pkgsettings['O'] = os.path.dirname(ebuild_path)
                        if not portage.digestgen([], pkgsettings, myportdb=portdb):
                                writemsg_level(
@@ -628,7 +625,10 @@ class Scheduler(PollScheduler):
                        root_config = x.root_config
                        portdb = root_config.trees["porttree"].dbapi
                        quiet_config = quiet_settings[root_config.root]
-                       quiet_config["O"] = os.path.dirname(portdb.findname(x.cpv))
+                       ebuild_path = portdb.findname(x.cpv)
+                       if ebuild_path is None:
+                               raise AssertionError("ebuild not found for '%s'" % x.cpv)
+                       quiet_config["O"] = os.path.dirname(ebuild_path)
                        if not portage.digestcheck([], quiet_config, strict=True):
                                failures |= 1
 
index 30277f94829a1fc18a4f54a3129716582133d826..a5d6c9f609bb42157ea505082160df45d9aaac97 100644 (file)
@@ -4097,10 +4097,11 @@ class depgraph(object):
                                metadata = pkg.metadata
                                ebuild_path = None
                                repo_name = metadata["repository"]
-                               if pkg_type == "ebuild":
-                                       ebuild_path = portdb.findname(pkg_key)
-                                       if not ebuild_path: # shouldn't happen
-                                               raise portage.exception.PackageNotFound(pkg_key)
+                               if pkg.type_name == "ebuild":
+                                       ebuild_path = portdb.findname(pkg.cpv)
+                                       if ebuild_path is None:
+                                               raise AssertionError(
+                                                       "ebuild not found for '%s'" % pkg.cpv)
                                        repo_path_real = os.path.dirname(os.path.dirname(
                                                os.path.dirname(ebuild_path)))
                                else:
@@ -4163,9 +4164,14 @@ class depgraph(object):
                                        if "--changelog" in self._frozen_config.myopts:
                                                inst_matches = vardb.match(pkg.slot_atom)
                                                if inst_matches:
-                                                       changelogs.extend(calc_changelog(
-                                                               portdb.findname(pkg_key),
-                                                               inst_matches[0], pkg_key))
+                                                       ebuild_path_cl = ebuild_path
+                                                       if ebuild_path_cl is None:
+                                                               # binary package
+                                                               ebuild_path_cl = portdb.findname(pkg.cpv)
+
+                                                       if ebuild_path_cl is not None:
+                                                               changelogs.extend(calc_changelog(
+                                                                       ebuild_path_cl, inst_matches[0], pkg.cpv))
                                else:
                                        addl = " " + green("N") + " " + fetch + "  "
                                        if ordered:
index eb68ae2b57f808e3f8c2d82fd8e877a3fda6c93a..f7c8288d588e7d76a9262d9bcec2e7741c195317 100644 (file)
@@ -447,7 +447,7 @@ class portdbapi(dbapi):
                the file we wanted.
                """
                if not mycpv:
-                       return ("", 0)
+                       return (None, 0)
                mysplit = mycpv.split("/")
                psplit = pkgsplit(mysplit[1])
                if psplit is None or len(mysplit) != 2:
@@ -614,9 +614,8 @@ class portdbapi(dbapi):
                myebuild, mylocation = self.findname2(mycpv, mytree)
 
                if not myebuild:
-                       writemsg(_("!!! aux_get(): ebuild path for '%s' not specified:\n") % mycpv,
-                               noiselevel=1)
-                       writemsg("!!!            %s\n" % myebuild, noiselevel=1)
+                       writemsg("!!! aux_get(): %s\n" % \
+                               _("ebuild not found for '%s'") % mycpv, noiselevel=1)
                        raise KeyError(mycpv)
 
                mydata, st, emtime = self._pull_valid_cache(mycpv, myebuild, mylocation)
@@ -783,6 +782,8 @@ class portdbapi(dbapi):
        def getfetchsizes(self, mypkg, useflags=None, debug=0):
                # returns a filename:size dictionnary of remaining downloads
                myebuild = self.findname(mypkg)
+               if myebuild is None:
+                       raise AssertionError("ebuild not found for '%s'" % mypkg)
                pkgdir = os.path.dirname(myebuild)
                mf = Manifest(pkgdir, self.mysettings["DISTDIR"])
                checksums = mf.getDigests()
@@ -826,6 +827,8 @@ class portdbapi(dbapi):
                                useflags = mysettings["USE"].split()
                myfiles = self.getFetchMap(mypkg, useflags=useflags)
                myebuild = self.findname(mypkg)
+               if myebuild is None:
+                       raise AssertionError("ebuild not found for '%s'" % mypkg)
                pkgdir = os.path.dirname(myebuild)
                mf = Manifest(pkgdir, self.mysettings["DISTDIR"])
                mysums = mf.getDigests()