diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-12-10 02:30:07 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-12-10 02:30:07 +0000 |
commit | 13db952dc45c29fe2057e60dcafbe84776b1c77a (patch) | |
tree | d2d08c259ce8453e159bc62bdb9b7e0af445252a | |
parent | 73bf16c7e0cfd4a9f2c8b4b65c28b25e9c0d1f21 (diff) | |
download | portage-13db952dc45c29fe2057e60dcafbe84776b1c77a.tar.gz portage-13db952dc45c29fe2057e60dcafbe84776b1c77a.tar.bz2 portage-13db952dc45c29fe2057e60dcafbe84776b1c77a.zip |
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.
svn path=/main/trunk/; revision=12191
-rw-r--r-- | pym/_emerge/__init__.py | 13 | ||||
-rw-r--r-- | 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 fc320ad75..617a81ec1 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -2867,17 +2867,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 5e6fc9125..cf966195a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -5504,9 +5504,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: |