Merge pull request #11251 from MikeMcQuaid/bottle_tar_args
dev-cmd/bottle: tweak tar and tar arguments.
This commit is contained in:
commit
c53ae546cc
@ -254,33 +254,32 @@ module Homebrew
|
|||||||
system "/usr/bin/sudo", "--non-interactive", "/usr/sbin/purge"
|
system "/usr/bin/sudo", "--non-interactive", "/usr/sbin/purge"
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_tar_owner_group_args!
|
def setup_tar_and_args!
|
||||||
# Unset the owner/group for reproducible bottles.
|
# Unset the owner/group for reproducible bottles.
|
||||||
# Use gnu-tar on Linux
|
|
||||||
return ["--owner", "0", "--group", "0"].freeze if OS.linux?
|
|
||||||
|
|
||||||
bsdtar_args = ["--uid", "0", "--gid", "0"].freeze
|
|
||||||
|
|
||||||
# System bsdtar is new enough on macOS Catalina and above.
|
# System bsdtar is new enough on macOS Catalina and above.
|
||||||
return bsdtar_args if OS.mac? && MacOS.version >= :catalina
|
# Set uid and gid for reproducible bottles.
|
||||||
|
return ["tar", ["--uid", "0", "--gid", "0"]].freeze if OS.mac? && MacOS.version >= :catalina
|
||||||
|
|
||||||
# Use newish libarchive on older macOS versions for reproducibility.
|
# Use gnu-tar on Linux
|
||||||
|
# Set owner and group for reproducible bottles.
|
||||||
|
gnutar_args = ["--owner", "0", "--group", "0"]
|
||||||
|
return ["tar", gnutar_args].freeze if OS.linux?
|
||||||
|
|
||||||
|
# Use gnu-tar on older macOS versions for `--owner`/`--group` support (which
|
||||||
|
# old `libarchive` doesn't have).
|
||||||
begin
|
begin
|
||||||
libarchive = Formula["libarchive"]
|
gnu_tar = Formula["gnu-tar"]
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
return [].freeze
|
return ["tar", []].freeze
|
||||||
end
|
end
|
||||||
|
|
||||||
unless libarchive.any_version_installed?
|
unless gnu_tar.any_version_installed?
|
||||||
ohai "Installing `libarchive` for bottling..."
|
ohai "Installing `gnu-tar` for bottling..."
|
||||||
safe_system HOMEBREW_BREW_FILE, "install", "--formula", libarchive.full_name
|
safe_system HOMEBREW_BREW_FILE, "install", "--formula", gnu_tar.full_name
|
||||||
end
|
end
|
||||||
|
|
||||||
path = PATH.new(ENV["PATH"])
|
["#{gnu_tar.opt_bin}/gtar", gnutar_args]
|
||||||
path.prepend(libarchive.opt_bin.to_s)
|
|
||||||
ENV["PATH"] = path
|
|
||||||
|
|
||||||
bsdtar_args
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bottle_formula(f, args:)
|
def bottle_formula(f, args:)
|
||||||
@ -417,9 +416,10 @@ module Homebrew
|
|||||||
cd cellar do
|
cd cellar do
|
||||||
sudo_purge
|
sudo_purge
|
||||||
# Tar then gzip for reproducible bottles.
|
# Tar then gzip for reproducible bottles.
|
||||||
owner_group_args = setup_tar_owner_group_args!
|
tar, tar_args = setup_tar_and_args!
|
||||||
safe_system "tar", "--create", "--numeric-owner",
|
# Use portable tar format to match libarchive format.
|
||||||
*owner_group_args,
|
safe_system tar, "--create", "--numeric-owner", "--format", "ustar",
|
||||||
|
*tar_args,
|
||||||
"--file", tar_path, "#{f.name}/#{f.pkg_version}"
|
"--file", tar_path, "#{f.name}/#{f.pkg_version}"
|
||||||
sudo_purge
|
sudo_purge
|
||||||
# Set more times for reproducible bottles.
|
# Set more times for reproducible bottles.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user