Better handle brew bottle --only-json-tab
bottles
- test them in `brew test-bot` (before we do so in homebrew/core) - don't fail if we cannot find the tab/install receipt in a bottle - cache listing the files in a bottle so we don't do it more times than necessary - fix resolution of version and formula names from a bottle if we're getting them from a bottle without a tab/install receipt This will need to be in a tagged release before we can ship tab-less bottles to users.
This commit is contained in:
parent
632e4d6579
commit
75592cbebc
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -234,7 +234,7 @@ jobs:
|
|||||||
|
|
||||||
- run: brew test-bot --only-cleanup-before
|
- run: brew test-bot --only-cleanup-before
|
||||||
|
|
||||||
- run: brew test-bot --only-formulae --test-default-formula
|
- run: brew test-bot --only-formulae --only-json-tab --test-default-formula
|
||||||
|
|
||||||
test-everything:
|
test-everything:
|
||||||
name: test everything (macOS)
|
name: test everything (macOS)
|
||||||
|
@ -326,6 +326,8 @@ module Homebrew
|
|||||||
local_filename = bottle_path.basename.to_s
|
local_filename = bottle_path.basename.to_s
|
||||||
|
|
||||||
tab_path = Utils::Bottles.receipt_path(f.local_bottle_path)
|
tab_path = Utils::Bottles.receipt_path(f.local_bottle_path)
|
||||||
|
raise "This bottle does not contain the file INSTALL_RECEIPT.json: #{bottle_path}" unless tab_path
|
||||||
|
|
||||||
tab_json = Utils.safe_popen_read("tar", "xfO", f.local_bottle_path, tab_path)
|
tab_json = Utils.safe_popen_read("tar", "xfO", f.local_bottle_path, tab_path)
|
||||||
tab = Tab.from_file_content(tab_json, tab_path)
|
tab = Tab.from_file_content(tab_json, tab_path)
|
||||||
|
|
||||||
|
@ -40,32 +40,40 @@ module Utils
|
|||||||
HOMEBREW_BOTTLES_EXTNAME_REGEX.match(filename).to_a
|
HOMEBREW_BOTTLES_EXTNAME_REGEX.match(filename).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bottle_file_list(bottle_file)
|
||||||
|
@bottle_file_list ||= {}
|
||||||
|
@bottle_file_list[bottle_file] ||= Utils.popen_read("tar", "-tzf", bottle_file)
|
||||||
|
.lines
|
||||||
|
.map(&:chomp)
|
||||||
|
end
|
||||||
|
|
||||||
def receipt_path(bottle_file)
|
def receipt_path(bottle_file)
|
||||||
path = Utils.popen_read("tar", "-tzf", bottle_file).lines.map(&:chomp).find do |line|
|
bottle_file_list(bottle_file).find do |line|
|
||||||
line =~ %r{.+/.+/INSTALL_RECEIPT.json}
|
line =~ %r{.+/.+/INSTALL_RECEIPT.json}
|
||||||
end
|
end
|
||||||
raise "This bottle does not contain the file INSTALL_RECEIPT.json: #{bottle_file}" unless path
|
|
||||||
|
|
||||||
path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_formula_names(bottle_file)
|
def resolve_formula_names(bottle_file)
|
||||||
receipt_file_path = receipt_path bottle_file
|
name = bottle_file_list(bottle_file).first.to_s.split("/").first
|
||||||
|
full_name = if (receipt_file_path = receipt_path(bottle_file))
|
||||||
receipt_file = Utils.popen_read("tar", "-xOzf", bottle_file, receipt_file_path)
|
receipt_file = Utils.popen_read("tar", "-xOzf", bottle_file, receipt_file_path)
|
||||||
name = receipt_file_path.split("/").first
|
|
||||||
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
|
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
|
||||||
|
"#{tap}/#{name}" if tap.present? && !tap.core_tap?
|
||||||
full_name = if tap.nil? || tap.core_tap?
|
elsif (bottle_json_path = Pathname(bottle_file.sub(/\.tar\.gz$/, ".json"))) &&
|
||||||
name
|
bottle_json_path.exist? &&
|
||||||
else
|
(bottle_json_path_contents = bottle_json_path.read.presence) &&
|
||||||
"#{tap}/#{name}"
|
(bottle_json = JSON.parse(bottle_json_path_contents).presence) &&
|
||||||
|
bottle_json.is_a?(Hash)
|
||||||
|
bottle_json.keys.first.presence
|
||||||
end
|
end
|
||||||
|
full_name ||= name
|
||||||
|
|
||||||
[name, full_name]
|
[name, full_name]
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve_version(bottle_file)
|
def resolve_version(bottle_file)
|
||||||
PkgVersion.parse receipt_path(bottle_file).split("/").second
|
version = bottle_file_list(bottle_file).first.to_s.split("/").second
|
||||||
|
PkgVersion.parse(version)
|
||||||
end
|
end
|
||||||
|
|
||||||
def formula_contents(bottle_file,
|
def formula_contents(bottle_file,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user