cmd: add new build command

This commit adds the `build` command. It takes the same flags as
`manifest` and will build the specified image.
This commit is contained in:
Michael Vogt 2024-12-03 10:17:47 +01:00 committed by Ondřej Budai
parent ce8dd45821
commit e5b3ccd6ed
5 changed files with 193 additions and 16 deletions

View file

@ -0,0 +1,24 @@
package main
import (
"fmt"
"path/filepath"
"github.com/osbuild/images/pkg/imagefilter"
"github.com/osbuild/images/pkg/osbuild"
)
func buildImage(res *imagefilter.Result, osbuildManifest []byte) error {
osbuildStoreDir := ".store"
// XXX: support output dir via commandline
// XXX2: support output filename via commandline (c.f.
// https://github.com/osbuild/images/pull/1039)
outputDir := "."
buildName := fmt.Sprintf("%s-%s-%s", res.Distro.Name(), res.ImgType.Name(), res.Arch.Name())
jobOutputDir := filepath.Join(outputDir, buildName)
// XXX: support stremaing via images/pkg/osbuild/monitor.go
_, err := osbuild.RunOSBuild(osbuildManifest, osbuildStoreDir, jobOutputDir, res.ImgType.Exports(), nil, nil, false, osStderr)
return err
}