dev-cmd/bottle: use Utils::Gzip.compress_with_options

This commit is contained in:
Caleb Xu 2023-01-04 22:37:35 -05:00
parent f6474c5048
commit e0915a2c34
No known key found for this signature in database
GPG Key ID: 47E6040D07B8407D

View File

@ -9,7 +9,7 @@ require "formula_versions"
require "cli/parser" require "cli/parser"
require "utils/inreplace" require "utils/inreplace"
require "erb" require "erb"
require "zlib" require "utils/gzip"
require "api" require "api"
BOTTLE_ERB = <<-EOS BOTTLE_ERB = <<-EOS
@ -30,7 +30,6 @@ BOTTLE_ERB = <<-EOS
EOS EOS
MAXIMUM_STRING_MATCHES = 100 MAXIMUM_STRING_MATCHES = 100
GZIP_BUFFER_SIZE = 64 * 1024
ALLOWABLE_HOMEBREW_REPOSITORY_LINKS = [ ALLOWABLE_HOMEBREW_REPOSITORY_LINKS = [
%r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Homebrew/os/(mac|linux)/pkgconfig}, %r{#{Regexp.escape(HOMEBREW_LIBRARY)}/Homebrew/os/(mac|linux)/pkgconfig},
@ -425,14 +424,10 @@ module Homebrew
mv tar_path, relocatable_tar_path mv tar_path, relocatable_tar_path
# Use gzip, faster to compress than bzip2, faster to uncompress than bzip2 # Use gzip, faster to compress than bzip2, faster to uncompress than bzip2
# or an uncompressed tarball (and more bandwidth friendly). # or an uncompressed tarball (and more bandwidth friendly).
gz = Zlib::GzipWriter.open(bottle_path) Utils::Gzip.compress_with_options(relocatable_tar_path,
gz.mtime = tab.source_modified_time mtime: tab.source_modified_time,
gz.orig_name = relocatable_tar_path orig_name: relocatable_tar_path,
File.open(relocatable_tar_path, "rb") do |tarfile| output: bottle_path)
gz.write(tarfile.read(GZIP_BUFFER_SIZE)) until tarfile.eof?
end
gz.close
rm_f relocatable_tar_path
sudo_purge sudo_purge
end end