From f35baa27522997712b6c1a45ef19793ad839b6f9 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Sat, 3 Apr 2021 15:01:44 -0700 Subject: [PATCH 1/2] OCI: Add sh.brew.tab to the image manifest The tab is needed to install the package using the SHA-256 of the single-architecture image. --- Library/Homebrew/github_packages.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index cb1419d68d..29bd9f7b0d 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -272,6 +272,7 @@ class GitHubPackages "org.opencontainers.image.title" => "#{formula_full_name} #{tag}", "com.github.package.type" => GITHUB_PACKAGE_TYPE, "sh.brew.bottle.glibc.version" => glibc_version, + "sh.brew.tab" => tab.to_json, }).compact.sort.to_h image_manifest = { From e627885e16b5ea2df0414ddc5dd6f5a44abe4d13 Mon Sep 17 00:00:00 2001 From: Shaun Jackman Date: Sat, 3 Apr 2021 18:58:52 -0700 Subject: [PATCH 2/2] OCI: Move CPU variant to sh.brew.cpu.variant --- Library/Homebrew/github_packages.rb | 49 +++++++++++++---------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index 29bd9f7b0d..c5def150f5 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -194,6 +194,7 @@ class GitHubPackages created_date = bottle_hash["bottle"]["date"] formula_annotations_hash = { + "com.github.package.type" => GITHUB_PACKAGE_TYPE, "org.opencontainers.image.created" => created_date, "org.opencontainers.image.description" => bottle_hash["formula"]["desc"], "org.opencontainers.image.documentation" => documentation, @@ -233,24 +234,17 @@ class GitHubPackages raise TypeError, "unknown tab['built_on']['os']: #{tab["built_on"]["os"]}" if os.blank? os_version = tab["built_on"]["os_version"] if tab["built_on"].present? - os_version = case os + case os when "darwin" - os_version || "macOS #{MacOS::Version.from_symbol(bottle_tag)}" + os_version ||= "macOS #{MacOS::Version.from_symbol(bottle_tag)}" when "linux" - (os_version || "Ubuntu 16.04.7").delete_suffix " LTS" - else - os_version + os_version = (os_version || "Ubuntu 16.04.7").delete_suffix " LTS" + glibc_version = (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || "2.23" + cpu_variant = tab["oldest_cpu_family"] || "core2" end - glibc_version = if os == "linux" - (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || "2.23" - end - - variant = tab["oldest_cpu_family"] || "core2" if os == "linux" - platform_hash = { architecture: architecture, - variant: variant, os: os, "os.version" => os_version, }.compact @@ -265,15 +259,21 @@ class GitHubPackages tag = GitHubPackages.version_rebuild(version, rebuild, bottle_tag) - annotations_hash = formula_annotations_hash.merge({ - "org.opencontainers.image.created" => created_date, - "org.opencontainers.image.documentation" => documentation, - "org.opencontainers.image.ref.name" => tag, - "org.opencontainers.image.title" => "#{formula_full_name} #{tag}", - "com.github.package.type" => GITHUB_PACKAGE_TYPE, - "sh.brew.bottle.glibc.version" => glibc_version, - "sh.brew.tab" => tab.to_json, - }).compact.sort.to_h + descriptor_annotations_hash = { + "org.opencontainers.image.ref.name" => tag, + "sh.brew.bottle.cpu.variant" => cpu_variant, + "sh.brew.bottle.digest" => tar_gz_sha256, + "sh.brew.bottle.glibc.version" => glibc_version, + "sh.brew.tab" => tab.to_json, + }.compact + + annotations_hash = formula_annotations_hash.merge(descriptor_annotations_hash).merge( + { + "org.opencontainers.image.created" => created_date, + "org.opencontainers.image.documentation" => documentation, + "org.opencontainers.image.title" => "#{formula_full_name} #{tag}", + }, + ).compact.sort.to_h image_manifest = { schemaVersion: 2, @@ -300,12 +300,7 @@ class GitHubPackages digest: "sha256:#{manifest_json_sha256}", size: manifest_json_size, platform: platform_hash, - annotations: { - "org.opencontainers.image.ref.name" => tag, - "sh.brew.bottle.digest" => tar_gz_sha256, - "sh.brew.bottle.glibc.version" => glibc_version, - "sh.brew.tab" => tab.to_json, - }.compact, + annotations: descriptor_annotations_hash, } end