From c46155aba48b1b4ee99aa9d9fb1e0067e899e1e1 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Sun, 9 Oct 2016 19:43:55 -0400 Subject: keg_relocate: cache files rewritten during brew bottle `brew bottle` replaces instances of the Homebrew prefix, cellar, and repository with placeholders in all text files. Cache these files in INSTALL_RECEIPT.json so that we don't have to check every single text file for placeholders on install. --- Library/Homebrew/dev-cmd/bottle.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index c6a8503b7..4af12a7a7 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -187,12 +187,13 @@ module Homebrew keg.lock do original_tab = nil + changed_files = nil begin unless ARGV.include? "--skip-relocation" keg.relocate_dynamic_linkage prefix, Keg::PREFIX_PLACEHOLDER, cellar, Keg::CELLAR_PLACEHOLDER - keg.relocate_text_files prefix, Keg::PREFIX_PLACEHOLDER, + changed_files = keg.relocate_text_files prefix, Keg::PREFIX_PLACEHOLDER, cellar, Keg::CELLAR_PLACEHOLDER, repository, Keg::REPOSITORY_PLACEHOLDER end @@ -205,6 +206,7 @@ module Homebrew tab.poured_from_bottle = false tab.HEAD = nil tab.time = nil + tab.changed_files = changed_files tab.write keg.find do |file| @@ -268,7 +270,7 @@ module Homebrew Keg::CELLAR_PLACEHOLDER, cellar keg.relocate_text_files Keg::PREFIX_PLACEHOLDER, prefix, Keg::CELLAR_PLACEHOLDER, cellar, - Keg::REPOSITORY_PLACEHOLDER, repository + Keg::REPOSITORY_PLACEHOLDER, repository, changed_files end end end -- cgit v1.2.3 From 9c519bbdbc1723c9f35e4fbc8ba594ac8d81d258 Mon Sep 17 00:00:00 2001 From: Josh Hagins Date: Mon, 10 Oct 2016 12:02:12 -0400 Subject: keg_relocate: refactor relocate_text_files Replace relocate_text_files with three methods that clarify intent: replace_locations_with_placeholders, replace_placeholders_with_locations and replace_text_in_files, the first two calling the third. --- Library/Homebrew/dev-cmd/bottle.rb | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'Library/Homebrew/dev-cmd') diff --git a/Library/Homebrew/dev-cmd/bottle.rb b/Library/Homebrew/dev-cmd/bottle.rb index 4af12a7a7..dcc9e0e98 100644 --- a/Library/Homebrew/dev-cmd/bottle.rb +++ b/Library/Homebrew/dev-cmd/bottle.rb @@ -191,11 +191,7 @@ module Homebrew begin unless ARGV.include? "--skip-relocation" - keg.relocate_dynamic_linkage prefix, Keg::PREFIX_PLACEHOLDER, - cellar, Keg::CELLAR_PLACEHOLDER - changed_files = keg.relocate_text_files prefix, Keg::PREFIX_PLACEHOLDER, - cellar, Keg::CELLAR_PLACEHOLDER, - repository, Keg::REPOSITORY_PLACEHOLDER + changed_files = keg.replace_locations_with_placeholders end keg.delete_pyc_files! @@ -266,11 +262,7 @@ module Homebrew ignore_interrupts do original_tab.write if original_tab unless ARGV.include? "--skip-relocation" - keg.relocate_dynamic_linkage Keg::PREFIX_PLACEHOLDER, prefix, - Keg::CELLAR_PLACEHOLDER, cellar - keg.relocate_text_files Keg::PREFIX_PLACEHOLDER, prefix, - Keg::CELLAR_PLACEHOLDER, cellar, - Keg::REPOSITORY_PLACEHOLDER, repository, changed_files + keg.replace_placeholders_with_locations changed_files end end end -- cgit v1.2.3