Bug #286522 - Check all portdbapi.findname return values in case it
authorZac Medico <zmedico@gentoo.org>
Sat, 26 Sep 2009 23:37:34 +0000 (23:37 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 26 Sep 2009 23:37:34 +0000 (23:37 -0000)
returns None, and raise 'ebuild not found' exceptions when necessary.

svn path=/main/trunk/; revision=14442

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 55c20ec096fefbbde13dcd926b02e672aac0d6a3..930b5c6df3be57d6556b14a794b0cf2d7241b15c 100644 (file)
@@ -37,7 +37,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 ffb40a06ca889d82432c74ae06cb0e817393f693..e501357e77871f77ac95471c5d7bb7a6b73fba6b 100644 (file)
@@ -31,6 +31,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 76ae5bf750df8a585a153e3840eaacd9fd7e5233..228d15bb2050bfef68533c31b09dd36c364a19bc 100644 (file)
@@ -22,6 +22,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 d67eb341dd695290e392db8062bd292f8949ce03..deaba19550e5b2d7879388c48090066c8bf1a64d 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()