From a62de1fa9ab27c55cee167411cb96a91cf5b4551 Mon Sep 17 00:00:00 2001 From: Renata Ravanelli Date: Fri, 24 Jan 2025 13:38:56 -0300 Subject: [PATCH] Fix missing extensions in RHCOS release browser for 4.16+ - Fix an issue where extensions were not displayed in the RHCOS release browser for versions 4.16 and later. Signed-off-by: Renata Ravanelli (cherry picked from commit 71220587296f35918de6827fc8542476752d56e7) --- cmd/build-extensions-container.go | 28 +++++++++++++++++++++++++++- src/build-extensions-container.sh | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cmd/build-extensions-container.go b/cmd/build-extensions-container.go index e0e938e3a9..ce60b47420 100644 --- a/cmd/build-extensions-container.go +++ b/cmd/build-extensions-container.go @@ -185,8 +185,34 @@ func buildExtensionContainer() error { SizeInBytes: float64(stat.Size()), SkipCompression: true, } - cosaBuild.MetaStamp = float64(time.Now().UnixNano()) + fmt.Printf("Generating meta.json `extensions` entry for: %s\n", buildID) + // The /tmp/extensions.json file is generated as part of the extension container build process. + // For more details, refer to: + // https://github.com/openshift/os/blob/master/extensions/Dockerfile + extensionsFilePath:= "./tmp/extensions.json" + fileContent, err := os.ReadFile(extensionsFilePath) + if err != nil { + fmt.Printf("Error reading JSON file: %v\n", err) + return err + } + // Parse the JSON content into a map + packages := make(map[string]string) + err = json.Unmarshal(fileContent, &packages) + if err != nil { + fmt.Printf("Error parsing JSON content: %v\n", err) + return err + } + + // Convert to extensionsInterfaceMap + extensionsInterfaceMap := make(map[string]interface{}) + for key, value := range packages { + extensionsInterfaceMap[key] = value + } + cosaBuild.Extensions = &cosa.Extensions { + Manifest: extensionsInterfaceMap, + } + cosaBuild.MetaStamp = float64(time.Now().UnixNano()) newBytes, err := json.MarshalIndent(cosaBuild, "", " ") if err != nil { return err diff --git a/src/build-extensions-container.sh b/src/build-extensions-container.sh index 621600c54e..1ef9893e08 100755 --- a/src/build-extensions-container.sh +++ b/src/build-extensions-container.sh @@ -24,6 +24,7 @@ if [[ -f "${workdir}/src/config.json" ]]; then fi mkdir "${ctx_dir}/hotfixes" +touch "${workdir}/tmp/extensions.json" tar -xC "${ctx_dir}/hotfixes" -f /dev/disk/by-id/virtio-hotfixes # Build the image, replacing the FROM directive with the local image we have. @@ -33,6 +34,7 @@ img=localhost/extensions-container (set -x; podman build --from oci-archive:"$ostree_ociarchive" --network=host \ --build-arg COSA=true --build-arg VARIANT="${variant}" --label version="$buildid" \ --volume /etc/pki/ca-trust:/etc/pki/ca-trust:ro \ + --volume "${workdir}"/tmp/extensions.json:/tmp/extensions.json \ -t "${img}" -f extensions/Dockerfile "${ctx_dir}") # Call skopeo to export it from the container storage to an oci-archive.