From ade71180572c82120a96ca7ff72ce7244a80a91f Mon Sep 17 00:00:00 2001 From: hyuraku <32809703+hyuraku@users.noreply.github.com> Date: Tue, 7 Feb 2023 19:17:00 +0900 Subject: [PATCH] add new method: gnutar_args --- Library/Homebrew/dev-cmd/bottle.rb | 10 ++++++++++ Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb | 10 +--------- Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb | 10 +--------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 9ed113632d..f12609bafe 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -242,6 +242,16 @@ module Homebrew alias generic_setup_tar_and_args! setup_tar_and_args! + def gnutar_args(mtime) + # Ensure tar is set up for reproducibility. + # https://reproducible-builds.org/docs/archives/ + [ + "--format", "pax", "--owner", "0", "--group", "0", "--sort", "name", "--mtime=#{mtime}", + # 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" + ].freeze + end + def formula_ignores(f) ignores = [] cellar_regex = Regexp.escape(HOMEBREW_CELLAR) diff --git a/Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb b/Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb index 81dee4eaf9..13d5e5e9cb 100644 --- a/Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb +++ b/Library/Homebrew/extend/os/linux/dev-cmd/bottle.rb @@ -9,15 +9,7 @@ module Homebrew def setup_tar_and_args!(args, mtime) generic_setup_tar_and_args!(args, mtime) - # Ensure tar is set up for reproducibility. - # https://reproducible-builds.org/docs/archives/ - gnutar_args = [ - "--format", "pax", "--owner", "0", "--group", "0", "--sort", "name", "--mtime=#{mtime}", - # 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" - ].freeze - - ["tar", gnutar_args].freeze + ["tar", gnutar_args(mtime)].freeze end def formula_ignores(f) diff --git a/Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb b/Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb index c28ef48b2c..752ea0c6e5 100644 --- a/Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb +++ b/Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb @@ -18,14 +18,6 @@ module Homebrew ensure_formula_installed!(gnu_tar, reason: "bottling") - # Ensure tar is set up for reproducibility. - # https://reproducible-builds.org/docs/archives/ - gnutar_args = [ - "--format", "pax", "--owner", "0", "--group", "0", "--sort", "name", "--mtime=#{mtime}", - # 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" - ].freeze - - ["#{gnu_tar.opt_bin}/gtar", gnutar_args].freeze + ["#{gnu_tar.opt_bin}/gtar", gnutar_args(mtime)].freeze end end