Add a new debugging / development tool `osbuild-package-sets` for printing JSON object with all package sets of a specific distro x arch x image type combination. This is useful, since due to the way package sets are implemented in composer, the actual package set of a vanilla image type is very difficult to determine just by looking at the code. Example usage: `go run cmd/osbuild-package-sets/main.go -distro rhel-90 -arch x86_64 -image qcow2`
46 lines
1 KiB
Go
46 lines
1 KiB
Go
// Simple tool to dump a JSON object containing all package sets for a specific
|
|
// distro x arch x image type.
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/osbuild/osbuild-composer/internal/blueprint"
|
|
"github.com/osbuild/osbuild-composer/internal/distroregistry"
|
|
)
|
|
|
|
func main() {
|
|
var distroName string
|
|
var archName string
|
|
var imageName string
|
|
|
|
flag.StringVar(&distroName, "distro", "", "Distribution name")
|
|
flag.StringVar(&archName, "arch", "", "Architecture name")
|
|
flag.StringVar(&imageName, "image", "", "Image name")
|
|
flag.Parse()
|
|
|
|
dr := distroregistry.NewDefault()
|
|
|
|
distro := dr.GetDistro(distroName)
|
|
if distro == nil {
|
|
panic(fmt.Errorf("Distro %q does not exist", distro))
|
|
}
|
|
|
|
arch, err := distro.GetArch(archName)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
image, err := arch.GetImageType(imageName)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
encoder := json.NewEncoder(os.Stdout)
|
|
encoder.SetIndent("", " ")
|
|
pkgset := image.PackageSets(blueprint.Blueprint{})
|
|
_ = encoder.Encode(pkgset)
|
|
}
|