summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-12-05 16:07:48 -0800
committerZac Medico <zmedico@gentoo.org>2010-12-05 16:07:48 -0800
commit803fb3d4037cd54de276ab0af47e50a827a5b023 (patch)
treeb54f1585255f7cf2f73b5f150289ddefd44703de
parentff14714a603064a91966a06a91dcc2bd9f93915f (diff)
downloadportage-803fb3d4037cd54de276ab0af47e50a827a5b023.tar.gz
portage-803fb3d4037cd54de276ab0af47e50a827a5b023.tar.bz2
portage-803fb3d4037cd54de276ab0af47e50a827a5b023.zip
Fix pkg_pretend output and error handling.
-rw-r--r--pym/_emerge/Scheduler.py123
1 files changed, 73 insertions, 50 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py
index 2e383cc67..0a9e52372 100644
--- a/pym/_emerge/Scheduler.py
+++ b/pym/_emerge/Scheduler.py
@@ -33,7 +33,9 @@ from portage.package.ebuild.digestcheck import digestcheck
from portage.package.ebuild.digestgen import digestgen
from portage.package.ebuild.prepare_build_dirs import prepare_build_dirs
+from _emerge.BinpkgFetcher import BinpkgFetcher
from _emerge.BinpkgPrefetcher import BinpkgPrefetcher
+from _emerge.BinpkgVerifier import BinpkgVerifier
from _emerge.Blocker import Blocker
from _emerge.BlockerDB import BlockerDB
from _emerge.clear_caches import clear_caches
@@ -979,9 +981,19 @@ class Scheduler(PollScheduler):
os.execv(mynewargv[0], mynewargv)
def _run_pkg_pretend(self):
+ """
+ Since pkg_pretend output may be important, this method sends all
+ output directly to stdout (regardless of options like --quiet or
+ --jobs).
+ """
failures = 0
+ # Use a local PollScheduler instance here, since we don't
+ # want tasks here to trigger the usual Scheduler callbacks
+ # that handle job scheduling and status display.
+ sched_iface = PollScheduler().sched_iface
+
for x in self._mergelist:
if not isinstance(x, Package):
continue
@@ -1005,60 +1017,71 @@ class Scheduler(PollScheduler):
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,
- logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=x, scheduler=self._sched_iface)
- fetcher.start()
- fetcher.wait()
-
- tbz2_file = bintree.getname(x.cpv)
- infloc = os.path.join(tmpdir, x.category, x.pf, "build-info")
- os.makedirs(infloc)
- portage.xpak.tbz2(tbz2_file).unpackinfo(infloc)
- ebuild_path = os.path.join(infloc, x.pf + ".ebuild")
- settings.configdict["pkg"]["EMERGE_FROM"] = "binary"
- settings.configdict["pkg"]["MERGE_TYPE"] = "binary"
-
- else:
- tree = "porttree"
- portdb = root_config.trees["porttree"].dbapi
- ebuild_path = portdb.findname(x.cpv, myrepo=x.repo)
- if ebuild_path is None:
- raise AssertionError("ebuild not found for '%s'" % x.cpv)
- settings.configdict["pkg"]["EMERGE_FROM"] = "ebuild"
- if self._build_opts.buildpkgonly:
- settings.configdict["pkg"]["MERGE_TYPE"] = "buildonly"
- else:
- settings.configdict["pkg"]["MERGE_TYPE"] = "source"
-
- portage.package.ebuild.doebuild.doebuild_environment(ebuild_path,
- "pretend", settings=settings,
- db=self.trees[settings["ROOT"]][tree].dbapi)
- prepare_build_dirs(root_config.root, settings, cleanup=0)
-
- vardb = root_config.trees['vartree'].dbapi
- settings["REPLACING_VERSIONS"] = " ".join(
- set(portage.versions.cpv_getversion(match) \
- for match in vardb.match(x.slot_atom) + \
- vardb.match('='+x.cpv)))
- pretend_phase = EbuildPhase(background=self._background,
- phase="pretend", scheduler=self._sched_iface,
- settings=settings)
-
- pretend_phase.start()
- ret = pretend_phase.wait()
+ try:
+ if x.built:
+ tree = "bintree"
+ bintree = root_config.trees["bintree"].dbapi.bintree
+
+ # Display fetch on stdout, so that it's always clear what
+ # is consuming time here.
+ if bintree.isremote(x.cpv):
+ fetcher = BinpkgFetcher(pkg=x,
+ scheduler=sched_iface)
+ fetcher.start()
+ if fetcher.wait() != os.EX_OK:
+ failures += 1
+ continue
+
+ verifier = BinpkgVerifier(pkg=x,
+ scheduler=sched_iface)
+ verifier.start()
+ if verifier.wait() != os.EX_OK:
+ failures += 1
+ continue
- portage.elog.elog_process(x.cpv, settings)
+ tbz2_file = bintree.getname(x.cpv)
+ infloc = os.path.join(tmpdir, x.category, x.pf, "build-info")
+ os.makedirs(infloc)
+ portage.xpak.tbz2(tbz2_file).unpackinfo(infloc)
+ ebuild_path = os.path.join(infloc, x.pf + ".ebuild")
+ settings.configdict["pkg"]["EMERGE_FROM"] = "binary"
+ settings.configdict["pkg"]["MERGE_TYPE"] = "binary"
- if ret == os.EX_OK:
+ else:
+ tree = "porttree"
+ portdb = root_config.trees["porttree"].dbapi
+ ebuild_path = portdb.findname(x.cpv, myrepo=x.repo)
+ if ebuild_path is None:
+ raise AssertionError("ebuild not found for '%s'" % x.cpv)
+ settings.configdict["pkg"]["EMERGE_FROM"] = "ebuild"
+ if self._build_opts.buildpkgonly:
+ settings.configdict["pkg"]["MERGE_TYPE"] = "buildonly"
+ else:
+ settings.configdict["pkg"]["MERGE_TYPE"] = "source"
+
+ portage.package.ebuild.doebuild.doebuild_environment(ebuild_path,
+ "pretend", settings=settings,
+ db=self.trees[settings["ROOT"]][tree].dbapi)
+ prepare_build_dirs(root_config.root, settings, cleanup=0)
+
+ vardb = root_config.trees['vartree'].dbapi
+ settings["REPLACING_VERSIONS"] = " ".join(
+ set(portage.versions.cpv_getversion(match) \
+ for match in vardb.match(x.slot_atom) + \
+ vardb.match('='+x.cpv)))
+ pretend_phase = EbuildPhase(
+ phase="pretend", scheduler=sched_iface,
+ settings=settings)
+
+ pretend_phase.start()
+ ret = pretend_phase.wait()
+ if ret != os.EX_OK:
+ failures += 1
+ portage.elog.elog_process(x.cpv, settings)
+ finally:
shutil.rmtree(tmpdir)
- settings["PORTAGE_TMPDIR"] = tmpdir_orig
+ settings["PORTAGE_TMPDIR"] = tmpdir_orig
- if ret != os.EX_OK:
- failures += 1
if failures:
return 1
return os.EX_OK