diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-04-07 13:17:58 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-04-07 13:17:58 -0700 |
commit | a9964a380476f7585465f310f230e85a0d783be8 (patch) | |
tree | 322f2abfa035826635426978ae7f76573316bbb7 | |
parent | 1e82e57e254ae5f90a39d6f1bc7e791681c0a1f3 (diff) | |
download | portage-a9964a380476f7585465f310f230e85a0d783be8.tar.gz portage-a9964a380476f7585465f310f230e85a0d783be8.tar.bz2 portage-a9964a380476f7585465f310f230e85a0d783be8.zip |
Eliminate redundant code in Scheduler._run_pkg_pretend() and remove unused
quiet_config variables.
-rw-r--r-- | pym/_emerge/Scheduler.py | 63 |
1 files changed, 19 insertions, 44 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index f7c644ec0..b80fa9007 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -857,13 +857,6 @@ class Scheduler(PollScheduler): def _run_pkg_pretend(self): shown_verifying_msg = False - quiet_settings = {} - for myroot, pkgsettings in self.pkgsettings.items(): - quiet_config = portage.config(clone=pkgsettings) - quiet_config["PORTAGE_QUIET"] = "1" - quiet_config.backup_changes("PORTAGE_QUIET") - quiet_settings[myroot] = quiet_config - del quiet_config failures = 0 @@ -889,10 +882,13 @@ class Scheduler(PollScheduler): portage.util.writemsg_stdout(out_str, noiselevel=-1) root_config = x.root_config - quiet_config = quiet_settings[root_config.root] settings = self.pkgsettings[root_config.root] + tmpdir = tempfile.mkdtemp() + tmpdir_orig = settings["PORTAGE_TMPDIR"] + settings["PORTAGE_TMPDIR"] = tmpdir if x.built: + tree = "bintree" bintree = root_config.trees["bintree"].dbapi.bintree if bintree.isremote(x.cpv): fetcher = BinpkgPrefetcher(background=self._background, @@ -903,57 +899,36 @@ class Scheduler(PollScheduler): tbz2_file = bintree.getname(x.cpv) ebuild_file_name = x.cpv.split("/")[1] + ".ebuild" ebuild_file_contents = portage.xpak.tbz2(tbz2_file).getfile(ebuild_file_name) - tmpdir = tempfile.mkdtemp() os.makedirs(os.path.join(tmpdir, x.category, x.pf)) ebuild_path = os.path.join(tmpdir, x.category, x.pf, ebuild_file_name) file = open(ebuild_path, 'w') file.write(ebuild_file_contents) file.close() - quiet_config["O"] = os.path.dirname(ebuild_path) - tmpdir_orig = settings["PORTAGE_TMPDIR"] - settings["PORTAGE_TMPDIR"] = tmpdir - - portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, "pretend", - root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1), - mydbapi=self.trees[settings["ROOT"]]["bintree"].dbapi, use_cache=1) - prepare_build_dirs(root_config.root, settings, cleanup=0) - pretend_phase = EbuildPhase(background=self._background, pkg=x, phase="pretend", - scheduler=self._sched_iface, settings=settings, tree="bintree") - pretend_phase.start() - ret = pretend_phase.wait() - - portage.elog.elog_process(x.cpv, settings) - - if ret == os.EX_OK: - shutil.rmtree(tmpdir) - settings["PORTAGE_TMPDIR"] = tmpdir_orig else: + tree = "porttree" portdb = root_config.trees["porttree"].dbapi 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) - - tmpdir = tempfile.mkdtemp() - tmpdir_orig = settings["PORTAGE_TMPDIR"] - settings["PORTAGE_TMPDIR"] = tmpdir - portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, "pretend", - root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1), - mydbapi=self.trees[settings["ROOT"]]["porttree"].dbapi, use_cache=1) - prepare_build_dirs(root_config.root, settings, cleanup=0) - pretend_phase = EbuildPhase(background=self._background, pkg=x, phase="pretend", - scheduler=self._sched_iface, settings=settings, tree="porttree") + portage.package.ebuild.doebuild.doebuild_environment(ebuild_path, + "pretend", root_config.root, settings, + debug=(settings.get("PORTAGE_DEBUG", "") == 1), + mydbapi=self.trees[settings["ROOT"]][tree].dbapi, use_cache=1) + prepare_build_dirs(root_config.root, settings, cleanup=0) + pretend_phase = EbuildPhase(background=self._background, pkg=x, + phase="pretend", scheduler=self._sched_iface, + settings=settings, tree=tree) - pretend_phase.start() - ret = pretend_phase.wait() + pretend_phase.start() + ret = pretend_phase.wait() - portage.elog.elog_process(x.cpv, settings) + portage.elog.elog_process(x.cpv, settings) - if ret == os.EX_OK: - shutil.rmtree(tmpdir) - settings["PORTAGE_TMPDIR"] = tmpdir_orig + if ret == os.EX_OK: + shutil.rmtree(tmpdir) + settings["PORTAGE_TMPDIR"] = tmpdir_orig if ret != os.EX_OK: failures += 1 |