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)
|
||||
meta ||= {}
|
||||
meta[:header] = ["Authorization: Bearer", "Accept: application/vnd.oci.image.index.v1+json"]
|
||||
meta[:headers] ||= []
|
||||
meta[:headers] << ["Authorization: Bearer"]
|
||||
super(url, name, version, meta)
|
||||
end
|
||||
|
||||
|
||||
@ -343,7 +343,7 @@ module Homebrew
|
||||
return unless @core_tap
|
||||
|
||||
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. " \
|
||||
"Glibc is for users who have a system Glibc with a lower version, " \
|
||||
|
||||
@ -58,7 +58,7 @@ class GitHubPackages
|
||||
HOMEBREW_PREFIX/"bin/skopeo",
|
||||
].compact.first
|
||||
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..."
|
||||
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.vendor" => org,
|
||||
"org.opencontainers.image.version" => version,
|
||||
}.compact
|
||||
}
|
||||
delete_blank_hash_values(formula_annotations_hash)
|
||||
|
||||
manifests = bottle_hash["bottle"]["tags"].map do |bottle_tag, tag_hash|
|
||||
local_file = tag_hash["local_filename"]
|
||||
@ -239,15 +240,17 @@ class GitHubPackages
|
||||
os_version ||= "macOS #{MacOS::Version.from_symbol(bottle_tag)}"
|
||||
when "linux"
|
||||
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"
|
||||
glibc_version = (tab["built_on"]["glibc_version"] if tab["built_on"].present?) || OS::GLIBC_CI_VERSION
|
||||
cpu_variant = tab["oldest_cpu_family"] || Hardware::CPU::INTEL_64BIT_OLDEST_CPU.to_s
|
||||
end
|
||||
|
||||
platform_hash = {
|
||||
architecture: architecture,
|
||||
os: os,
|
||||
"os.version" => os_version,
|
||||
}.compact
|
||||
}
|
||||
delete_blank_hash_values(platform_hash)
|
||||
|
||||
tar_sha256 = Digest::SHA256.hexdigest(
|
||||
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.glibc.version" => glibc_version,
|
||||
"sh.brew.tab" => tab.to_json,
|
||||
}.compact
|
||||
}
|
||||
delete_blank_hash_values(descriptor_annotations_hash)
|
||||
|
||||
annotations_hash = formula_annotations_hash.merge(descriptor_annotations_hash).merge(
|
||||
{
|
||||
@ -273,7 +277,8 @@ class GitHubPackages
|
||||
"org.opencontainers.image.documentation" => documentation,
|
||||
"org.opencontainers.image.title" => "#{formula_full_name} #{tag}",
|
||||
},
|
||||
).compact.sort.to_h
|
||||
).sort.to_h
|
||||
delete_blank_hash_values(annotations_hash)
|
||||
|
||||
image_manifest = {
|
||||
schemaVersion: 2,
|
||||
@ -381,4 +386,10 @@ class GitHubPackages
|
||||
|
||||
[sha256, json.size]
|
||||
end
|
||||
|
||||
def delete_blank_hash_values(hash)
|
||||
hash.each do |key, value|
|
||||
hash.delete(key) if value.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -20,6 +20,8 @@ module Hardware
|
||||
*ARM_64BIT_ARCHS,
|
||||
].freeze
|
||||
|
||||
INTEL_64BIT_OLDEST_CPU = :core2
|
||||
|
||||
class << self
|
||||
extend T::Sig
|
||||
|
||||
@ -198,7 +200,7 @@ module Hardware
|
||||
def oldest_cpu(_version = nil)
|
||||
if Hardware::CPU.intel?
|
||||
if Hardware::CPU.is_64_bit?
|
||||
:core2
|
||||
Hardware::CPU::INTEL_64BIT_OLDEST_CPU
|
||||
else
|
||||
:core
|
||||
end
|
||||
|
||||
@ -37,6 +37,8 @@ module OS
|
||||
|
||||
::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]
|
||||
|
||||
GLIBC_CI_VERSION = "2.23"
|
||||
|
||||
if OS.mac?
|
||||
require "os/mac"
|
||||
# Don't tell people to report issues on unsupported configurations.
|
||||
|
||||
@ -306,6 +306,7 @@ class Bottle
|
||||
|
||||
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)
|
||||
["#{@name}/blobs/sha256:#{checksum}", filename]
|
||||
else
|
||||
@ -400,8 +401,10 @@ class Bottle
|
||||
version_rebuild = GitHubPackages.version_rebuild(@resource.version, rebuild)
|
||||
resource.version(version_rebuild)
|
||||
|
||||
resource.url("#{@spec.root_url}/#{name}/manifests/#{version_rebuild}",
|
||||
using: CurlGitHubPackagesDownloadStrategy)
|
||||
resource.url("#{@spec.root_url}/#{name}/manifests/#{version_rebuild}", {
|
||||
using: CurlGitHubPackagesDownloadStrategy,
|
||||
headers: ["Accept: application/vnd.oci.image.index.v1+json"],
|
||||
})
|
||||
resource.downloader.resolved_basename = "#{name}-#{version_rebuild}.bottle_manifest.json"
|
||||
resource
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user