OCI: Move CPU variant to sh.brew.cpu.variant

This commit is contained in:
Shaun Jackman 2021-04-03 18:58:52 -07:00
parent f35baa2752
commit e627885e16

View File

@ -194,6 +194,7 @@ class GitHubPackages
created_date = bottle_hash["bottle"]["date"] created_date = bottle_hash["bottle"]["date"]
formula_annotations_hash = { formula_annotations_hash = {
"com.github.package.type" => GITHUB_PACKAGE_TYPE,
"org.opencontainers.image.created" => created_date, "org.opencontainers.image.created" => created_date,
"org.opencontainers.image.description" => bottle_hash["formula"]["desc"], "org.opencontainers.image.description" => bottle_hash["formula"]["desc"],
"org.opencontainers.image.documentation" => documentation, "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? 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 = tab["built_on"]["os_version"] if tab["built_on"].present?
os_version = case os case os
when "darwin" when "darwin"
os_version || "macOS #{MacOS::Version.from_symbol(bottle_tag)}" os_version ||= "macOS #{MacOS::Version.from_symbol(bottle_tag)}"
when "linux" when "linux"
(os_version || "Ubuntu 16.04.7").delete_suffix " LTS" os_version = (os_version || "Ubuntu 16.04.7").delete_suffix " LTS"
else glibc_version = (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || "2.23"
os_version cpu_variant = tab["oldest_cpu_family"] || "core2"
end 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 = { platform_hash = {
architecture: architecture, architecture: architecture,
variant: variant,
os: os, os: os,
"os.version" => os_version, "os.version" => os_version,
}.compact }.compact
@ -265,15 +259,21 @@ class GitHubPackages
tag = GitHubPackages.version_rebuild(version, rebuild, bottle_tag) tag = GitHubPackages.version_rebuild(version, rebuild, bottle_tag)
annotations_hash = formula_annotations_hash.merge({ descriptor_annotations_hash = {
"org.opencontainers.image.created" => created_date,
"org.opencontainers.image.documentation" => documentation,
"org.opencontainers.image.ref.name" => tag, "org.opencontainers.image.ref.name" => tag,
"org.opencontainers.image.title" => "#{formula_full_name} #{tag}", "sh.brew.bottle.cpu.variant" => cpu_variant,
"com.github.package.type" => GITHUB_PACKAGE_TYPE, "sh.brew.bottle.digest" => tar_gz_sha256,
"sh.brew.bottle.glibc.version" => glibc_version, "sh.brew.bottle.glibc.version" => glibc_version,
"sh.brew.tab" => tab.to_json, "sh.brew.tab" => tab.to_json,
}).compact.sort.to_h }.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 = { image_manifest = {
schemaVersion: 2, schemaVersion: 2,
@ -300,12 +300,7 @@ class GitHubPackages
digest: "sha256:#{manifest_json_sha256}", digest: "sha256:#{manifest_json_sha256}",
size: manifest_json_size, size: manifest_json_size,
platform: platform_hash, platform: platform_hash,
annotations: { annotations: descriptor_annotations_hash,
"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,
} }
end end