From 7a6a2598c417b0079036a37e3203d3451bb49654 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sat, 26 Sep 2009 23:37:34 +0000 Subject: [PATCH] Bug #286522 - Check all portdbapi.findname return values in case it returns None, and raise 'ebuild not found' exceptions when necessary. svn path=/main/trunk/; revision=14442 --- pym/_emerge/EbuildBinpkg.py | 4 +++- pym/_emerge/EbuildBuild.py | 4 +++- pym/_emerge/EbuildBuildDir.py | 3 +++ pym/_emerge/EbuildFetcher.py | 2 ++ pym/_emerge/EbuildFetchonly.py | 4 ++++ pym/_emerge/MetadataRegen.py | 2 ++ pym/_emerge/Scheduler.py | 12 ++++++------ pym/_emerge/depgraph.py | 20 +++++++++++++------- pym/portage/dbapi/porttree.py | 11 +++++++---- 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/pym/_emerge/EbuildBinpkg.py b/pym/_emerge/EbuildBinpkg.py index 8d742d640..73297ed6b 100644 --- a/pym/_emerge/EbuildBinpkg.py +++ b/pym/_emerge/EbuildBinpkg.py @@ -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" diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py index 55c20ec09..930b5c6df 100644 --- a/pym/_emerge/EbuildBuild.py +++ b/pym/_emerge/EbuildBuild.py @@ -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 diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py index ffb40a06c..e501357e7 100644 --- a/pym/_emerge/EbuildBuildDir.py +++ b/pym/_emerge/EbuildBuildDir.py @@ -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" diff --git a/pym/_emerge/EbuildFetcher.py b/pym/_emerge/EbuildFetcher.py index 76ae5bf75..228d15bb2 100644 --- a/pym/_emerge/EbuildFetcher.py +++ b/pym/_emerge/EbuildFetcher.py @@ -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) diff --git a/pym/_emerge/EbuildFetchonly.py b/pym/_emerge/EbuildFetchonly.py index 256a06c69..147e824f2 100644 --- a/pym/_emerge/EbuildFetchonly.py +++ b/pym/_emerge/EbuildFetchonly.py @@ -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, diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py index 287312e17..6ff61f571 100644 --- a/pym/_emerge/MetadataRegen.py +++ b/pym/_emerge/MetadataRegen.py @@ -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: diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 78b9e57d8..b6f08307d 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -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 diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index d67eb341d..deaba1955 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -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: diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index eb68ae2b5..f7c8288d5 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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() -- 2.26.2