treewide: add product info to OCI OS images
Add the product info to the OCI OS image config.
Change-Id: I70c572f2698c8d8bb0edc0ba969d8c6b37ae4c00
Reviewed-on: https://review.monogon.dev/c/monogon/+/4193
Reviewed-by: Tim Windelschmidt <tim@monogon.tech>
Tested-by: Jenkins CI
diff --git a/osbase/build/mkoci/main.go b/osbase/build/mkoci/main.go
index 16dd268..1fb2254 100644
--- a/osbase/build/mkoci/main.go
+++ b/osbase/build/mkoci/main.go
@@ -28,6 +28,7 @@
var payloadNameRegexp = regexp.MustCompile(`^[0-9A-Za-z-](?:[0-9A-Za-z._-]{0,78}[0-9A-Za-z_-])?$`)
var (
+ productInfoPath = flag.String("product_info", "", "Path to the product info JSON file")
payloadName = flag.String("payload_name", "", "Payload name for the next payload_file flag")
compressionLevel = flag.Int("compression_level", int(zstd.SpeedDefault), "Compression level")
outPath = flag.String("out", "", "Output OCI Image Layout directory path")
@@ -201,9 +202,19 @@
})
flag.Parse()
+ rawProductInfo, err := os.ReadFile(*productInfoPath)
+ if err != nil {
+ log.Fatalf("Failed to read product info file: %v", err)
+ }
+ var productInfo osimage.ProductInfo
+ err = json.Unmarshal(rawProductInfo, &productInfo)
+ if err != nil {
+ log.Fatal(err)
+ }
+
// Create blobs directory.
blobsPath := filepath.Join(*outPath, "blobs", "sha256")
- err := os.MkdirAll(blobsPath, 0755)
+ err = os.MkdirAll(blobsPath, 0755)
if err != nil {
log.Fatal(err)
}
@@ -223,6 +234,7 @@
// Write the OS image config.
imageConfig := osimage.Config{
FormatVersion: osimage.ConfigVersion,
+ ProductInfo: productInfo,
Payloads: payloadInfos,
}
imageConfigBytes, err := json.MarshalIndent(imageConfig, "", "\t")