diff --git a/Library/Homebrew/test/unpack_strategy_spec.rb b/Library/Homebrew/test/unpack_strategy_spec.rb index 055fe3c96..279bf48f3 100644 --- a/Library/Homebrew/test/unpack_strategy_spec.rb +++ b/Library/Homebrew/test/unpack_strategy_spec.rb @@ -32,7 +32,7 @@ describe UnpackStrategy do (mktmpdir/"file.tar").tap do |path| mktmpdir do |dir| (dir/directories).mkpath - system "tar", "-c", "-f", path, "-C", dir, "A/" + system "tar", "--create", "--file", path, "--directory", dir, "A/" end end } @@ -49,7 +49,7 @@ describe UnpackStrategy do (mktmpdir/basename).tap do |path| mktmpdir do |dir| FileUtils.touch dir/"file.txt" - system "tar", "-c", "-f", path, "-C", dir, "file.txt" + system "tar", "--create", "--file", path, "--directory", dir, "file.txt" end end } diff --git a/Library/Homebrew/unpack_strategy/tar.rb b/Library/Homebrew/unpack_strategy/tar.rb index a40ad8f45..33d6ffcb4 100644 --- a/Library/Homebrew/unpack_strategy/tar.rb +++ b/Library/Homebrew/unpack_strategy/tar.rb @@ -30,7 +30,7 @@ module UnpackStrategy return false unless [Bzip2, Gzip, Lzip, Xz].any? { |s| s.can_extract?(path) } # Check if `tar` can list the contents, then it can also extract it. - stdout, _, status = system_command("tar", args: ["tf", path], print_stderr: false) + stdout, _, status = system_command("tar", args: ["--list", "--file", path], print_stderr: false) status.success? && !stdout.empty? end @@ -48,7 +48,9 @@ module UnpackStrategy end system_command! "tar", - args: ["xof", tar_path, "-C", unpack_dir], + args: ["--extract", "--no-same-owner", + "--file", tar_path, + "--directory", unpack_dir], verbose: verbose end end diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 5439e43d9..4e809b1be 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -47,7 +47,7 @@ module Utils end def file_from_bottle(bottle_file, file_path) - Utils.popen_read("tar", "--extract", "--stdout", "--file", bottle_file, file_path) + Utils.popen_read("tar", "--extract", "--to-stdout", "--file", bottle_file, file_path) end def resolve_formula_names(bottle_file) diff --git a/Library/Homebrew/utils/tar.rb b/Library/Homebrew/utils/tar.rb index ced4ed523..53ce635a8 100644 --- a/Library/Homebrew/utils/tar.rb +++ b/Library/Homebrew/utils/tar.rb @@ -26,7 +26,7 @@ module Utils path = Pathname.new(path) return unless TAR_FILE_EXTENSIONS.include? path.extname - return if Utils.popen_read(executable, "-tf", path).match?(%r{/.*\.}) + return if Utils.popen_read(executable, "--list", "--file", path).match?(%r{/.*\.}) odie "#{path} is not a valid tar file!" end