#228 Non-zero exit when rpmbuild fails in local command
Merged 6 years ago by cqi. Opened 6 years ago by cqi.

file modified
+11 -2
@@ -2196,8 +2196,17 @@ 

              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):

Signed-off-by: Chenxiong Qi cqi@redhat.com

I assume the lowercase version is for zsh, right? According to https://unix.stackexchange.com/a/14276 the indexing in there starts from 1.

My fault :( it should be 1 for zsh. I'll fix it.

I tested with bash and it seems to work fine. :+1: from me.

Ideally we would just drop the tee from the pipeline, but then it's hard to stream the output to the console and store it in log file at the same time. I'm not sure if the log is actually useful since it only contains stdout and not stderr, but let's keep this PR small and focused.

rebased

6 years ago

Fixed wrong index for zsh. Also added a comment to describe usage of pipestatus.

Pull-Request has been merged by cqi

6 years ago
Metadata