From 36dac3d41feafa09f82dedb63e51fabf5f0ea358 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 14 Jan 2020 15:09:13 +0000 Subject: [PATCH] dev-cmd/bottle: add HOMEBREW_BOTTLE_SUDO_PURGE. Add environment variable to optionally run `sudo purge` a few times to potentially work around #6539. --- Library/Homebrew/dev-cmd/bottle.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 3495d428ef..31efc3c08b 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -205,6 +205,12 @@ module Homebrew erb.result(bottle.instance_eval { binding }).gsub(/^\s*$\n/, "") end + def sudo_purge + return unless ENV["HOMEBREW_BOTTLE_SUDO_PURGE"] + + system "/usr/bin/sudo", "/usr/sbin/purge" + end + def bottle_formula(f) return ofail "Formula not installed or up-to-date: #{f.full_name}" unless f.latest_version_installed? @@ -285,13 +291,16 @@ module Homebrew end cd cellar do + sudo_purge safe_system "tar", "cf", tar_path, "#{f.name}/#{f.pkg_version}" + sudo_purge tar_path.utime(tab.source_modified_time, tab.source_modified_time) relocatable_tar_path = "#{f}-bottle.tar" mv tar_path, relocatable_tar_path # Use gzip, faster to compress than bzip2, faster to uncompress than bzip2 # or an uncompressed tarball (and more bandwidth friendly). safe_system "gzip", "-f", relocatable_tar_path + sudo_purge mv "#{relocatable_tar_path}.gz", bottle_path end