Merge pull request #11131 from MikeMcQuaid/only_json_tab_handling
Better handle `brew bottle --only-json-tab` bottles
This commit is contained in:
commit
bc9b98aa0b
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-formulae --test-default-formula
|
||||
- run: brew test-bot --only-formulae --only-json-tab --test-default-formula
|
||||
|
||||
test-everything:
|
||||
name: test everything (macOS)
|
||||
|
@ -326,6 +326,8 @@ module Homebrew
|
||||
local_filename = bottle_path.basename.to_s
|
||||
|
||||
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 = Tab.from_file_content(tab_json, tab_path)
|
||||
|
||||
|
@ -40,32 +40,40 @@ module Utils
|
||||
HOMEBREW_BOTTLES_EXTNAME_REGEX.match(filename).to_a
|
||||
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)
|
||||
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}
|
||||
end
|
||||
raise "This bottle does not contain the file INSTALL_RECEIPT.json: #{bottle_file}" unless path
|
||||
|
||||
path
|
||||
end
|
||||
|
||||
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)
|
||||
name = receipt_file_path.split("/").first
|
||||
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
|
||||
|
||||
full_name = if tap.nil? || tap.core_tap?
|
||||
name
|
||||
else
|
||||
"#{tap}/#{name}"
|
||||
"#{tap}/#{name}" if tap.present? && !tap.core_tap?
|
||||
elsif (bottle_json_path = Pathname(bottle_file.sub(/\.tar\.gz$/, ".json"))) &&
|
||||
bottle_json_path.exist? &&
|
||||
(bottle_json_path_contents = bottle_json_path.read.presence) &&
|
||||
(bottle_json = JSON.parse(bottle_json_path_contents).presence) &&
|
||||
bottle_json.is_a?(Hash)
|
||||
bottle_json.keys.first.presence
|
||||
end
|
||||
full_name ||= name
|
||||
|
||||
[name, full_name]
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def formula_contents(bottle_file,
|
||||
|
Loading…
x
Reference in New Issue
Block a user