From d113b772b6a015616c0fd911ed6c8f95513d9ffb Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 12 Dec 2008 21:29:26 +0000 Subject: [PATCH] When processing output from the "depend" phase, use the number of lines as a sanity check so that bash's returncode doesn't have to be trusted. (trunk r12191) svn path=/main/branches/2.1.6/; revision=12224 --- pym/_emerge/__init__.py | 13 +++++++++++-- pym/portage/__init__.py | 12 +++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 559894bc6..4349459fe 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -2848,17 +2848,26 @@ class EbuildMetadataPhase(SubProcess): files = self._files self._raw_metadata.append(files.ebuild.read()) if not self._raw_metadata[-1]: + # Split lines here so they can be counted inside _set_returncode(). + self._raw_metadata = "".join(self._raw_metadata).splitlines() self._unregister() self.wait() if self.returncode == os.EX_OK: - metadata = izip(portage.auxdbkeys, - "".join(self._raw_metadata).splitlines()) + metadata = izip(portage.auxdbkeys, self._raw_metadata) self.metadata_callback(self.cpv, self.ebuild_path, self.repo_path, metadata, self.ebuild_mtime) return self._registered + def _set_returncode(self, wait_retval): + SubProcess._set_returncode(self, wait_retval) + if self.returncode == os.EX_OK and \ + len(portage.auxdbkeys) != len(self._raw_metadata): + # Don't trust bash's returncode if the + # number of lines is incorrect. + self.returncode = 1 + class EbuildProcess(SpawnProcess): __slots__ = ("phase", "pkg", "settings", "tree") diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index ae499bcb2..582b65417 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5494,9 +5494,15 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # shift in order to distinguish it from a return value. (just # like portage.process.spawn() would do). if retval & 0xff: - return (retval & 0xff) << 8 - # Otherwise, return its exit code. - return retval >> 8 + retval = (retval & 0xff) << 8 + else: + # Otherwise, return its exit code. + retval = retval >> 8 + if retval == os.EX_OK and len(dbkey) != len(auxdbkeys): + # Don't trust bash's returncode if the + # number of lines is incorrect. + retval = 1 + return retval elif dbkey: mysettings["dbkey"] = dbkey else: -- 2.26.2