diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-04-02 13:14:14 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-04-02 13:14:14 -0700 |
commit | 27ae77a5977741bcad9b0cb9323812de9fc1515b (patch) | |
tree | 2c94226d3dba9e68da6b729e5e81b9970e6fcb40 | |
parent | Add a test which calls bash -n on all scripts with bash shebang. (diff) | |
parent | Implement emerge part of pkg_pretend (diff) | |
download | portage-idfetch-27ae77a5977741bcad9b0cb9323812de9fc1515b.tar.gz portage-idfetch-27ae77a5977741bcad9b0cb9323812de9fc1515b.tar.bz2 portage-idfetch-27ae77a5977741bcad9b0cb9323812de9fc1515b.zip |
Merge remote branch 'fews-portage-branch/pkg_pretend'
-rw-r--r-- | pym/_emerge/Scheduler.py | 84 | ||||
-rw-r--r-- | pym/portage/const.py | 2 | ||||
-rw-r--r-- | pym/portage/package/ebuild/doebuild.py | 5 |
3 files changed, 86 insertions, 5 deletions
diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 4d9b3a56..bf39e658 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -5,7 +5,9 @@ from __future__ import print_function import codecs import logging +import shutil import sys +import tempfile import textwrap import time import weakref @@ -27,6 +29,7 @@ from portage.util import writemsg, writemsg_level from portage.package.ebuild.digestcheck import digestcheck from portage.package.ebuild.digestgen import digestgen +from _emerge.BinpkgFetcher import BinpkgFetcher from _emerge.BinpkgPrefetcher import BinpkgPrefetcher from _emerge.Blocker import Blocker from _emerge.BlockerDB import BlockerDB @@ -852,8 +855,83 @@ class Scheduler(PollScheduler): os.environ["PORTAGE_NICENESS"] = "0" os.execv(mynewargv[0], mynewargv) - def merge(self): + 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 + + for x in self._mergelist: + if not isinstance(x, Package): + continue + + if x.operation == "uninstall": + continue + if x.metadata["EAPI"] in ("0", "1", "2", "3"): + continue + + if "pretend" not in x.metadata.defined_phases: + continue + + if not shown_verifying_msg: + shown_verifying_msg = True + self._status_msg("Running pkg_pretend") + + root_config = x.root_config + quiet_config = quiet_settings[root_config.root] + settings = self.pkgsettings[root_config.root] + + if x.built: + bintree = root_config.trees["bintree"].dbapi.bintree + if bintree.isremote(x.cpv): + fetcher = BinpkgFetcher(background=False, + logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=x, scheduler=self._sched_iface) + fetcher.start() + fetcher.wait() + bintree.inject(x.cpv) + + 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) + + ret = portage.package.ebuild.doebuild.doebuild(ebuild_path, "pretend", \ + root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1), + mydbapi=self.trees[settings["ROOT"]]["bintree"].dbapi, tree="bintree") + ret = os.EX_OK + + shutil.rmtree(tmpdir) + else: + 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) + + ret = portage.package.ebuild.doebuild.doebuild(ebuild_path, "pretend", \ + root_config.root, settings, debug=(settings.get("PORTAGE_DEBUG", "") == 1), + mydbapi=self.trees[settings["ROOT"]]["porttree"].dbapi, tree="porttree") + + if ret != os.EX_OK: + failures += 1 + if failures: + return 1 + return os.EX_OK + + def merge(self): if "--resume" in self.myopts: # We're resuming. portage.writemsg_stdout( @@ -909,6 +987,10 @@ class Scheduler(PollScheduler): if rval != os.EX_OK and not keep_going: return rval + rval = self._run_pkg_pretend() + if rval != os.EX_OK: + return rval + while True: rval = self._merge() if rval == os.EX_OK or fetchonly or not keep_going: diff --git a/pym/portage/const.py b/pym/portage/const.py index 1450fe2e..4171b999 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -80,7 +80,7 @@ INCREMENTALS = ("USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "CONFIG_PROTECT_MASK", "CONFIG_PROTECT", "PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES") -EBUILD_PHASES = ("setup", "unpack", "prepare", "configure", +EBUILD_PHASES = ("pretend", "setup", "unpack", "prepare", "configure", "compile", "test", "install", "package", "preinst", "postinst","prerm", "postrm", "nofetch", "config", "info", "other") diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index e5716f0a..b64e10d4 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -301,7 +301,6 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, fetchonly=0, cleanup=0, dbkey=None, use_cache=1, fetchall=0, tree=None, mydbapi=None, vartree=None, prev_mtimes=None, fd_pipes=None, returnpid=False): - """ Wrapper function that invokes specific ebuild phases through the spawning of ebuild.sh @@ -523,7 +522,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # we can temporarily override PORTAGE_TMPDIR with a random temp dir # so that there's no need for locking and it can be used even if the # user isn't in the portage group. - if mydo in ("info",): + if mydo in ("info", "pretend"): tmpdir = tempfile.mkdtemp() tmpdir_orig = mysettings["PORTAGE_TMPDIR"] mysettings["PORTAGE_TMPDIR"] = tmpdir @@ -785,7 +784,7 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, writemsg(_("!!! post postinst failed; exiting.\n"), noiselevel=-1) return phase_retval - elif mydo in ("prerm", "postrm", "config", "info"): + elif mydo in ("prerm", "postrm", "config", "info", "pretend"): retval = spawn( _shell_quote(ebuild_sh_binary) + " " + mydo, mysettings, debug=debug, free=1, logfile=logfile, |