GitHub Packages cleanup
- `download_strategy`: only request image index JSON for downloading the manifest for the tab - use a shared `OS` constant for the version of `glibc` we use in CI - fix `skoepeo` typo - ensure that blank hash values are deleted (again) rather than just `nil` ones - use a shared `Hardware::CPU` constant for oldest CPU we're supporting/using on Intel 64-bit - re-add comment to `software_spec`
This commit is contained in:
parent
698c49067d
commit
cdaeee03c4
@ -563,7 +563,8 @@ class CurlGitHubPackagesDownloadStrategy < CurlDownloadStrategy
|
|||||||
|
|
||||||
def initialize(url, name, version, **meta)
|
def initialize(url, name, version, **meta)
|
||||||
meta ||= {}
|
meta ||= {}
|
||||||
meta[:header] = ["Authorization: Bearer", "Accept: application/vnd.oci.image.index.v1+json"]
|
meta[:headers] ||= []
|
||||||
|
meta[:headers] << ["Authorization: Bearer"]
|
||||||
super(url, name, version, meta)
|
super(url, name, version, meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -343,7 +343,7 @@ module Homebrew
|
|||||||
return unless @core_tap
|
return unless @core_tap
|
||||||
|
|
||||||
version = formula.version.to_s
|
version = formula.version.to_s
|
||||||
return if version == "2.23"
|
return if version == OS::GLIBC_CI_VERSION
|
||||||
|
|
||||||
problem "The glibc version must be #{version}, as this is the version used by our CI on Linux. " \
|
problem "The glibc version must be #{version}, as this is the version used by our CI on Linux. " \
|
||||||
"Glibc is for users who have a system Glibc with a lower version, " \
|
"Glibc is for users who have a system Glibc with a lower version, " \
|
||||||
|
|||||||
@ -58,7 +58,7 @@ class GitHubPackages
|
|||||||
HOMEBREW_PREFIX/"bin/skopeo",
|
HOMEBREW_PREFIX/"bin/skopeo",
|
||||||
].compact.first
|
].compact.first
|
||||||
unless skopeo.exist?
|
unless skopeo.exist?
|
||||||
odie "no `skoepeo` and HOMEBREW_FORCE_HOMEBREW_ON_LINUX is set!" if Homebrew::EnvConfig.force_homebrew_on_linux?
|
odie "no `skopeo` and HOMEBREW_FORCE_HOMEBREW_ON_LINUX is set!" if Homebrew::EnvConfig.force_homebrew_on_linux?
|
||||||
|
|
||||||
ohai "Installing `skopeo` for upload..."
|
ohai "Installing `skopeo` for upload..."
|
||||||
safe_system HOMEBREW_BREW_FILE, "install", "--formula", "skopeo"
|
safe_system HOMEBREW_BREW_FILE, "install", "--formula", "skopeo"
|
||||||
@ -206,7 +206,8 @@ class GitHubPackages
|
|||||||
"org.opencontainers.image.url" => bottle_hash["formula"]["homepage"],
|
"org.opencontainers.image.url" => bottle_hash["formula"]["homepage"],
|
||||||
"org.opencontainers.image.vendor" => org,
|
"org.opencontainers.image.vendor" => org,
|
||||||
"org.opencontainers.image.version" => version,
|
"org.opencontainers.image.version" => version,
|
||||||
}.compact
|
}
|
||||||
|
delete_blank_hash_values(formula_annotations_hash)
|
||||||
|
|
||||||
manifests = bottle_hash["bottle"]["tags"].map do |bottle_tag, tag_hash|
|
manifests = bottle_hash["bottle"]["tags"].map do |bottle_tag, tag_hash|
|
||||||
local_file = tag_hash["local_filename"]
|
local_file = tag_hash["local_filename"]
|
||||||
@ -239,15 +240,17 @@ class GitHubPackages
|
|||||||
os_version ||= "macOS #{MacOS::Version.from_symbol(bottle_tag)}"
|
os_version ||= "macOS #{MacOS::Version.from_symbol(bottle_tag)}"
|
||||||
when "linux"
|
when "linux"
|
||||||
os_version = (os_version || "Ubuntu 16.04.7").delete_suffix " LTS"
|
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"
|
glibc_version = (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || OS::GLIBC_CI_VERSION
|
||||||
cpu_variant = tab["oldest_cpu_family"] || "core2"
|
cpu_variant = tab["oldest_cpu_family"] || Hardware::CPU::INTEL_64BIT_OLDEST_CPU.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
platform_hash = {
|
platform_hash = {
|
||||||
architecture: architecture,
|
architecture: architecture,
|
||||||
os: os,
|
os: os,
|
||||||
"os.version" => os_version,
|
"os.version" => os_version,
|
||||||
}.compact
|
}
|
||||||
|
delete_blank_hash_values(platform_hash)
|
||||||
|
|
||||||
tar_sha256 = Digest::SHA256.hexdigest(
|
tar_sha256 = Digest::SHA256.hexdigest(
|
||||||
Utils.safe_popen_read("gunzip", "--stdout", "--decompress", local_file),
|
Utils.safe_popen_read("gunzip", "--stdout", "--decompress", local_file),
|
||||||
)
|
)
|
||||||
@ -265,7 +268,8 @@ class GitHubPackages
|
|||||||
"sh.brew.bottle.digest" => tar_gz_sha256,
|
"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
|
}
|
||||||
|
delete_blank_hash_values(descriptor_annotations_hash)
|
||||||
|
|
||||||
annotations_hash = formula_annotations_hash.merge(descriptor_annotations_hash).merge(
|
annotations_hash = formula_annotations_hash.merge(descriptor_annotations_hash).merge(
|
||||||
{
|
{
|
||||||
@ -273,7 +277,8 @@ class GitHubPackages
|
|||||||
"org.opencontainers.image.documentation" => documentation,
|
"org.opencontainers.image.documentation" => documentation,
|
||||||
"org.opencontainers.image.title" => "#{formula_full_name} #{tag}",
|
"org.opencontainers.image.title" => "#{formula_full_name} #{tag}",
|
||||||
},
|
},
|
||||||
).compact.sort.to_h
|
).sort.to_h
|
||||||
|
delete_blank_hash_values(annotations_hash)
|
||||||
|
|
||||||
image_manifest = {
|
image_manifest = {
|
||||||
schemaVersion: 2,
|
schemaVersion: 2,
|
||||||
@ -381,4 +386,10 @@ class GitHubPackages
|
|||||||
|
|
||||||
[sha256, json.size]
|
[sha256, json.size]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_blank_hash_values(hash)
|
||||||
|
hash.each do |key, value|
|
||||||
|
hash.delete(key) if value.blank?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -20,6 +20,8 @@ module Hardware
|
|||||||
*ARM_64BIT_ARCHS,
|
*ARM_64BIT_ARCHS,
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
INTEL_64BIT_OLDEST_CPU = :core2
|
||||||
|
|
||||||
class << self
|
class << self
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
|
|
||||||
@ -198,7 +200,7 @@ module Hardware
|
|||||||
def oldest_cpu(_version = nil)
|
def oldest_cpu(_version = nil)
|
||||||
if Hardware::CPU.intel?
|
if Hardware::CPU.intel?
|
||||||
if Hardware::CPU.is_64_bit?
|
if Hardware::CPU.is_64_bit?
|
||||||
:core2
|
Hardware::CPU::INTEL_64BIT_OLDEST_CPU
|
||||||
else
|
else
|
||||||
:core
|
:core
|
||||||
end
|
end
|
||||||
|
|||||||
@ -37,6 +37,8 @@ module OS
|
|||||||
|
|
||||||
::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
|
::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
|
||||||
|
|
||||||
|
GLIBC_CI_VERSION = "2.23"
|
||||||
|
|
||||||
if OS.mac?
|
if OS.mac?
|
||||||
require "os/mac"
|
require "os/mac"
|
||||||
# Don't tell people to report issues on unsupported configurations.
|
# Don't tell people to report issues on unsupported configurations.
|
||||||
|
|||||||
@ -306,6 +306,7 @@ class Bottle
|
|||||||
|
|
||||||
filename = Filename.create(formula, tag, spec.rebuild).bintray
|
filename = Filename.create(formula, tag, spec.rebuild).bintray
|
||||||
|
|
||||||
|
# TODO: this will need adjusted when if we use GitHub Packages by default
|
||||||
path, resolved_basename = if spec.root_url.match?(GitHubPackages::URL_REGEX)
|
path, resolved_basename = if spec.root_url.match?(GitHubPackages::URL_REGEX)
|
||||||
["#{@name}/blobs/sha256:#{checksum}", filename]
|
["#{@name}/blobs/sha256:#{checksum}", filename]
|
||||||
else
|
else
|
||||||
@ -400,8 +401,10 @@ class Bottle
|
|||||||
version_rebuild = GitHubPackages.version_rebuild(@resource.version, rebuild)
|
version_rebuild = GitHubPackages.version_rebuild(@resource.version, rebuild)
|
||||||
resource.version(version_rebuild)
|
resource.version(version_rebuild)
|
||||||
|
|
||||||
resource.url("#{@spec.root_url}/#{name}/manifests/#{version_rebuild}",
|
resource.url("#{@spec.root_url}/#{name}/manifests/#{version_rebuild}", {
|
||||||
using: CurlGitHubPackagesDownloadStrategy)
|
using: CurlGitHubPackagesDownloadStrategy,
|
||||||
|
headers: ["Accept: application/vnd.oci.image.index.v1+json"],
|
||||||
|
})
|
||||||
resource.downloader.resolved_basename = "#{name}-#{version_rebuild}.bottle_manifest.json"
|
resource.downloader.resolved_basename = "#{name}-#{version_rebuild}.bottle_manifest.json"
|
||||||
resource
|
resource
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user