Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log rpm output to error or info depending on exit code #1212

Merged
merged 1 commit into from
May 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main/scala/com/typesafe/sbt/packager/rpm/RpmHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,15 @@ object RpmHelper {
else Seq.empty
) ++ Seq(spec.meta.name + ".spec")
log.debug("Executing rpmbuild with: " + args.mkString(" "))
// RPM outputs to standard error in non-error cases. So just collect all the output, then dump
// it all to either error log or info log depending on the exit status
val outputBuffer = collection.mutable.ArrayBuffer.empty[String]
(sys.process.Process(args, Some(specsDir)) ! sys.process
.ProcessLogger(o => log.info(o), e => log.error(e))) match {
case 0 => ()
.ProcessLogger(o => outputBuffer.append(o))) match {
case 0 =>
outputBuffer.foreach(log.info(_))
case code =>
outputBuffer.foreach(log.error(_))
sys.error("Unable to run rpmbuild, check output for details. Errorcode " + code)
}
}
Expand Down