Merge pull request #11321 from Bo98/gzip
dev-cmd/bottle: make gzip creation consistent across platforms
This commit is contained in:
commit
a92c194bfb
@ -10,6 +10,7 @@ require "cli/parser"
|
|||||||
require "utils/inreplace"
|
require "utils/inreplace"
|
||||||
require "erb"
|
require "erb"
|
||||||
require "archive"
|
require "archive"
|
||||||
|
require "zlib"
|
||||||
|
|
||||||
BOTTLE_ERB = <<-EOS
|
BOTTLE_ERB = <<-EOS
|
||||||
bottle do
|
bottle do
|
||||||
@ -29,6 +30,7 @@ BOTTLE_ERB = <<-EOS
|
|||||||
EOS
|
EOS
|
||||||
|
|
||||||
MAXIMUM_STRING_MATCHES = 100
|
MAXIMUM_STRING_MATCHES = 100
|
||||||
|
GZIP_BUFFER_SIZE = 64 * 1024
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
extend T::Sig
|
extend T::Sig
|
||||||
@ -440,9 +442,14 @@ 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).
|
||||||
safe_system "gzip", "-f", relocatable_tar_path
|
gz = Zlib::GzipWriter.open(bottle_path)
|
||||||
|
gz.mtime = tab.source_modified_time
|
||||||
|
gz.orig_name = relocatable_tar_path
|
||||||
|
File.open(relocatable_tar_path, "rb") do |tarfile|
|
||||||
|
gz.write(tarfile.read(GZIP_BUFFER_SIZE)) until tarfile.eof?
|
||||||
|
end
|
||||||
|
gz.close
|
||||||
sudo_purge
|
sudo_purge
|
||||||
mv "#{relocatable_tar_path}.gz", bottle_path
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ohai "Detecting if #{local_filename} is relocatable..." if bottle_path.size > 1 * 1024 * 1024
|
ohai "Detecting if #{local_filename} is relocatable..." if bottle_path.size > 1 * 1024 * 1024
|
||||||
|
Loading…
x
Reference in New Issue
Block a user