From 15129ab7ac121a0a9f2dd4e767fbb5469f97c9f0 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 12 Dec 2008 21:50:43 +0000 Subject: [PATCH] Fix --getbinpkg to behave as expected with --pretend and --fetchonly. (trunk r12212) svn path=/main/branches/2.1.6/; revision=12243 --- pym/_emerge/__init__.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index d8fb14621..a1783a001 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -3176,7 +3176,7 @@ class Binpkg(CompositeTask): portage.prepare_build_dirs(self.settings["ROOT"], self.settings, 1) fetcher = BinpkgFetcher(background=self.background, logfile=self.settings.get("PORTAGE_LOG_FILE"), pkg=self.pkg, - scheduler=self.scheduler) + pretend=self.opts.pretend, scheduler=self.scheduler) pkg_path = fetcher.pkg_path self._pkg_path = pkg_path @@ -3203,6 +3203,12 @@ class Binpkg(CompositeTask): self.wait() return + if self.opts.pretend: + self._current_task = None + self.returncode = os.EX_OK + self.wait() + return + verifier = None if self._verify: logfile = None @@ -3372,7 +3378,7 @@ class Binpkg(CompositeTask): class BinpkgFetcher(SpawnProcess): - __slots__ = ("pkg", + __slots__ = ("pkg", "pretend", "locked", "pkg_path", "_lock_obj") def __init__(self, **kwargs): @@ -3386,17 +3392,19 @@ class BinpkgFetcher(SpawnProcess): return pkg = self.pkg + pretend = self.pretend bintree = pkg.root_config.trees["bintree"] settings = bintree.settings use_locks = "distlocks" in settings.features pkg_path = self.pkg_path - portage.util.ensure_dirs(os.path.dirname(pkg_path)) - if use_locks: - self.lock() + if not pretend: + portage.util.ensure_dirs(os.path.dirname(pkg_path)) + if use_locks: + self.lock() exists = os.path.exists(pkg_path) resume = exists and os.path.basename(pkg_path) in bintree.invalids - if not resume: + if not (pretend or resume): # Remove existing file or broken symlink. try: os.unlink(pkg_path) @@ -3415,6 +3423,12 @@ class BinpkgFetcher(SpawnProcess): uri = settings["PORTAGE_BINHOST"].rstrip("/") + \ "/" + pkg.pf + ".tbz2" + if pretend: + portage.writemsg_stdout("\n%s\n" % uri, noiselevel=-1) + self.returncode = os.EX_OK + self.wait() + return + protocol = urlparse.urlparse(uri)[0] fcmd_prefix = "FETCHCOMMAND" if resume: -- 2.26.2