Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev-cmd/bottle: install gnu-tar before keg lock. #15889

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@
return merge(args: args)
end

gnu_tar_formula_ensure_installed_if_needed!(only_json_tab: args.only_json_tab?)

Check warning on line 101 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L101

Added line #L101 was not covered by tests

args.named.to_resolved_formulae(uniq: false).each do |formula|
bottle_formula formula, args: args
end
Expand Down Expand Up @@ -257,20 +259,30 @@
].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"]

Check warning on line 265 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L265

Added line #L265 was not covered by tests
rescue FormulaUnavailableError
nil

Check warning on line 267 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L267

Added line #L267 was not covered by tests
end
return if gnu_tar_formula.blank?

ensure_formula_installed!(gnu_tar_formula, reason: "bottling")

Check warning on line 271 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L271

Added line #L271 was not covered by tests

gnu_tar_formula

Check warning on line 273 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L273

Added line #L273 was not covered by tests
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?)

Check warning on line 284 in Library/Homebrew/dev-cmd/bottle.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bottle.rb#L284

Added line #L284 was not covered by tests
return default_tar_args if gnu_tar_formula.blank?

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