From 83e73f36215b8e02f5d603c0fc871c13ba3838f7 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 17 2017 14:18:29 +0000 Subject: Non-zero exit when rpmbuild fails in local command local command runs rpmbuild in conjunction with tee in a pipe. The whole command will return zero even if the first rpmbuild fails and exits with non-zero. Both bash and zsh are supported. Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 6e9d301..f6a7fa9 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2196,8 +2196,17 @@ class Commands(object): cmd.append('--quiet') cmd.extend(['-ba', os.path.join(self.path, self.spec)]) logfile = '.build-%s-%s.log' % (self.ver, self.rel) - # Run the command - self._run_command(cmd, shell=True, pipe=['tee', logfile]) + + cmd = '%s | tee %s' % (' '.join(cmd), logfile) + try: + # Since zsh is a widely used, which is supported by fedpkg + # actually, pipestatus is for checking the first command when zsh + # is used. + subprocess.check_call( + '%s; exit "${PIPESTATUS[0]} ${pipestatus[1]}"' % cmd, + shell=True) + except subprocess.CalledProcessError as e: + raise rpkgError(cmd) # Not to be confused with mockconfig the property def mock_config(self, target=None, arch=None):