mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
github_packages: fix OOM with large bottles
This commit is contained in:
parent
279ab47c21
commit
ac9af0dbbc
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
require "utils/curl"
|
require "utils/curl"
|
||||||
require "json"
|
require "json"
|
||||||
|
require "zlib"
|
||||||
|
|
||||||
# GitHub Packages client.
|
# GitHub Packages client.
|
||||||
#
|
#
|
||||||
@ -21,6 +22,9 @@ class GitHubPackages
|
|||||||
|
|
||||||
URL_REGEX = %r{(?:#{Regexp.escape(URL_PREFIX)}|#{Regexp.escape(DOCKER_PREFIX)})([\w-]+)/([\w-]+)}.freeze
|
URL_REGEX = %r{(?:#{Regexp.escape(URL_PREFIX)}|#{Regexp.escape(DOCKER_PREFIX)})([\w-]+)/([\w-]+)}.freeze
|
||||||
|
|
||||||
|
GZIP_BUFFER_SIZE = 64 * 1024
|
||||||
|
private_constant :GZIP_BUFFER_SIZE
|
||||||
|
|
||||||
# Translate Homebrew tab.arch to OCI platform.architecture
|
# Translate Homebrew tab.arch to OCI platform.architecture
|
||||||
TAB_ARCH_TO_PLATFORM_ARCHITECTURE = {
|
TAB_ARCH_TO_PLATFORM_ARCHITECTURE = {
|
||||||
"arm64" => "arm64",
|
"arm64" => "arm64",
|
||||||
@ -338,11 +342,14 @@ class GitHubPackages
|
|||||||
"os.version" => os_version,
|
"os.version" => os_version,
|
||||||
}.reject { |_, v| v.blank? }
|
}.reject { |_, v| v.blank? }
|
||||||
|
|
||||||
tar_sha256 = Digest::SHA256.hexdigest(
|
tar_sha256 = Digest::SHA256.new
|
||||||
Utils.safe_popen_read("gunzip", "--stdout", "--decompress", local_file),
|
Zlib::GzipReader.open(local_file) do |gz|
|
||||||
)
|
while (data = gz.read(GZIP_BUFFER_SIZE))
|
||||||
|
tar_sha256 << data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
config_json_sha256, config_json_size = write_image_config(platform_hash, tar_sha256, blobs)
|
config_json_sha256, config_json_size = write_image_config(platform_hash, tar_sha256.hexdigest, blobs)
|
||||||
|
|
||||||
formulae_dir = tag_hash["formulae_brew_sh_path"]
|
formulae_dir = tag_hash["formulae_brew_sh_path"]
|
||||||
documentation = "https://formulae.brew.sh/#{formulae_dir}/#{formula_name}" if formula_core_tap
|
documentation = "https://formulae.brew.sh/#{formulae_dir}/#{formula_name}" if formula_core_tap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user