Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,6 @@ jobs:

- run: brew test-bot --only-setup

- run: brew install gnu-tar

- run: brew test-bot --only-formulae --only-json-tab --test-default-formula
22 changes: 17 additions & 5 deletions Library/Homebrew/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,26 @@ def self.tar_args
[].freeze
end

sig { params(gnu_tar_formula: Formula).returns(String) }
def self.gnu_tar(gnu_tar_formula)
"#{gnu_tar_formula.opt_bin}/tar"
end

sig { params(mtime: String).returns(T::Array[String]) }
def self.reproducible_gnutar_args(mtime)
# Ensure gnu tar is set up for reproducibility.
# https://reproducible-builds.org/docs/archives/
[
"--format", "pax", "--owner", "0", "--group", "0", "--sort", "name", "--mtime=#{mtime}",
# File modification times
"--mtime=#{mtime}",
# File ordering
"--sort=name",
# Users, groups and numeric ids
"--owner=0", "--group=0", "--numeric-owner",
# PAX headers
"--format=pax",
# Set exthdr names to exclude PID (for GNU tar <1.33). Also don't store atime and ctime.
"--pax-option", "globexthdr.name=/GlobalHead.%n,exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
"--pax-option=globexthdr.name=/GlobalHead.%n,exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
].freeze
end

Expand All @@ -253,14 +265,14 @@ def self.setup_tar_and_args!(args, mtime)

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

ensure_formula_installed!(gnu_tar, reason: "bottling")
ensure_formula_installed!(gnu_tar_formula, reason: "bottling")

["#{gnu_tar.opt_bin}/gtar", reproducible_gnutar_args(mtime)].freeze
[gnu_tar(gnu_tar_formula), reproducible_gnutar_args(mtime)].freeze
end

def self.formula_ignores(formula)
Expand Down
6 changes: 1 addition & 5 deletions Library/Homebrew/extend/os/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# typed: strict
# frozen_string_literal: true

if OS.mac?
require "extend/os/mac/dev-cmd/bottle"
elsif OS.linux?
require "extend/os/linux/dev-cmd/bottle"
end
require "extend/os/mac/dev-cmd/bottle" if OS.mac?
12 changes: 0 additions & 12 deletions Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb

This file was deleted.

5 changes: 5 additions & 0 deletions Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ def self.tar_args
[].freeze
end
end

sig { params(gnu_tar_formula: Formula).returns(String) }
def self.gnu_tar(gnu_tar_formula)
"#{gnu_tar_formula.opt_bin}/gtar"
end
end