osbuild-worker-executor: fix tar warning and log unexpected output

This commit fixes a warning from tar that the archive cannot contain
itself. It also makes any tar output a warning (maybe even an error?)
as we do not expect anything from the tar command. The test is updated
to also check this.
This commit is contained in:
Michael Vogt 2024-06-06 10:49:12 +02:00 committed by Sanne Raymaekers
parent 1f52150ff1
commit 22769305d8
2 changed files with 11 additions and 2 deletions

View file

@ -85,6 +85,7 @@ func runOsbuild(logger *logrus.Logger, buildDir string, control *controlJSON, ou
// #nosec G204
cmd = exec.Command(
"tar",
"--exclude=output/output.tar",
"-Scf",
filepath.Join(outputDir, "output.tar"),
"output",
@ -97,7 +98,10 @@ func runOsbuild(logger *logrus.Logger, buildDir string, control *controlJSON, ou
_, _ = mw.Write([]byte(err.Error()))
return "", err
}
logger.Infof("tar output:\n%s", out)
if len(out) > 0 {
logger.Warnf("unexpected tar output:\n%s", out)
}
return outputDir, nil
}