diff --git a/cmd/osbuild-playground/playground.go b/cmd/osbuild-playground/playground.go index 54faffcc0..c280a437a 100644 --- a/cmd/osbuild-playground/playground.go +++ b/cmd/osbuild-playground/playground.go @@ -55,7 +55,7 @@ func RunPlayground(img image.ImageKind, d distro.Distro, arch distro.Arch, repos store := path.Join(state_dir, "osbuild-store") - _, err = osbuild.RunOSBuild(bytes, store, "./", manifest.GetExports(), manifest.GetCheckpoints(), false, os.Stdout) + _, err = osbuild.RunOSBuild(bytes, store, "./", manifest.GetExports(), manifest.GetCheckpoints(), nil, false, os.Stdout) if err != nil { fmt.Fprintf(os.Stderr, "could not run osbuild: %s", err.Error()) } diff --git a/cmd/osbuild-worker/jobimpl-osbuild.go b/cmd/osbuild-worker/jobimpl-osbuild.go index 2733291a0..17a698a28 100644 --- a/cmd/osbuild-worker/jobimpl-osbuild.go +++ b/cmd/osbuild-worker/jobimpl-osbuild.go @@ -307,7 +307,7 @@ func (impl *OSBuildJobImpl) Run(job worker.Job) error { } // Run osbuild and handle two kinds of errors - osbuildJobResult.OSBuildOutput, err = osbuild.RunOSBuild(jobArgs.Manifest, impl.Store, outputDirectory, exports, nil, true, os.Stderr) + osbuildJobResult.OSBuildOutput, err = osbuild.RunOSBuild(jobArgs.Manifest, impl.Store, outputDirectory, exports, nil, nil, true, os.Stderr) // First handle the case when "running" osbuild failed if err != nil { osbuildJobResult.JobError = clienterrors.WorkerClientError(clienterrors.ErrorBuildJob, "osbuild build failed") diff --git a/internal/osbuild/osbuild-exec.go b/internal/osbuild/osbuild-exec.go index 6c3715a3c..a842f54a4 100644 --- a/internal/osbuild/osbuild-exec.go +++ b/internal/osbuild/osbuild-exec.go @@ -14,7 +14,7 @@ import ( // Note that osbuild returns non-zero when the pipeline fails. This function // does not return an error in this case. Instead, the failure is communicated // with its corresponding logs through osbuild.Result. -func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpoints []string, result bool, errorWriter io.Writer) (*Result, error) { +func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpoints, extraEnv []string, result bool, errorWriter io.Writer) (*Result, error) { var stdoutBuffer bytes.Buffer var res Result @@ -39,6 +39,11 @@ func RunOSBuild(manifest []byte, store, outputDirectory string, exports, checkpo } else { cmd.Stdout = os.Stdout } + + if len(extraEnv) > 0 { + cmd.Env = append(os.Environ(), extraEnv...) + } + cmd.Stderr = errorWriter stdin, err := cmd.StdinPipe() if err != nil {