Skip to content

Commit

Permalink
Merge pull request #15889 from MikeMcQuaid/gnu_tar_deps_bottling
Browse files Browse the repository at this point in the history
dev-cmd/bottle: install gnu-tar before keg lock.
  • Loading branch information
MikeMcQuaid authored Aug 18, 2023
2 parents 7a974f3 + e7dc14c commit 3cd7290
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Library/Homebrew/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def self.bottle
return merge(args: args)
end

gnu_tar_formula_ensure_installed_if_needed!(only_json_tab: args.only_json_tab?)

args.named.to_resolved_formulae(uniq: false).each do |formula|
bottle_formula formula, args: args
end
Expand Down Expand Up @@ -257,20 +259,30 @@ def self.reproducible_gnutar_args(mtime)
].freeze
end

sig { params(only_json_tab: T::Boolean).returns(T.nilable(Formula)) }
def self.gnu_tar_formula_ensure_installed_if_needed!(only_json_tab:)
gnu_tar_formula = begin
Formula["gnu-tar"]
rescue FormulaUnavailableError
nil
end
return if gnu_tar_formula.blank?

ensure_formula_installed!(gnu_tar_formula, reason: "bottling")

gnu_tar_formula
end

sig { params(args: T.untyped, mtime: String).returns([String, T::Array[String]]) }
def self.setup_tar_and_args!(args, mtime)
# Without --only-json-tab bottles are never reproducible
default_tar_args = ["tar", tar_args].freeze
return default_tar_args unless args.only_json_tab?

# Use gnu-tar as it can be set up for reproducibility better than libarchive.
begin
gnu_tar_formula = Formula["gnu-tar"]
rescue FormulaUnavailableError
return default_tar_args
end

ensure_formula_installed!(gnu_tar_formula, reason: "bottling")
# Use gnu-tar as it can be set up for reproducibility better than libarchive
# and to be consistent between macOS and Linux.
gnu_tar_formula = gnu_tar_formula_ensure_installed_if_needed!(only_json_tab: args.only_json_tab?)
return default_tar_args if gnu_tar_formula.blank?

[gnu_tar(gnu_tar_formula), reproducible_gnutar_args(mtime)].freeze
end
Expand Down

0 comments on commit 3cd7290

Please sign in to comment.