From 6fe70190204807a893419e5c510cb3e961e35c35 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 19 Sep 2016 15:15:04 +0200 Subject: [PATCH 1/2] Make `HOMEBREW_PREFIX/Caskroom` the default. --- Library/Homebrew/cask/lib/hbc.rb | 1 + Library/Homebrew/cask/lib/hbc/caskroom.rb | 8 ++++++++ Library/Homebrew/cask/lib/hbc/cli/list.rb | 4 ++++ Library/Homebrew/cask/lib/hbc/locations.rb | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/lib/hbc.rb b/Library/Homebrew/cask/lib/hbc.rb index b45a9f3757..fd61558abc 100644 --- a/Library/Homebrew/cask/lib/hbc.rb +++ b/Library/Homebrew/cask/lib/hbc.rb @@ -49,6 +49,7 @@ module Hbc Hbc::Cache.ensure_cache_exists Hbc::Cache.migrate_legacy_cache + Hbc::Caskroom.migrate_caskroom_from_repo_to_prefix Hbc::Caskroom.ensure_caskroom_exists end diff --git a/Library/Homebrew/cask/lib/hbc/caskroom.rb b/Library/Homebrew/cask/lib/hbc/caskroom.rb index cb471a125f..7d02f3fa45 100644 --- a/Library/Homebrew/cask/lib/hbc/caskroom.rb +++ b/Library/Homebrew/cask/lib/hbc/caskroom.rb @@ -1,6 +1,14 @@ module Hbc::Caskroom module_function + def migrate_caskroom_from_repo_to_prefix + repo_caskroom = Hbc.homebrew_repository.join("Caskroom") + if !Hbc.caskroom.exist? && repo_caskroom.directory? + ohai "Moving Caskroom from HOMEBREW_REPOSITORY to HOMEBREW_PREFIX" + FileUtils.mv repo_caskroom, Hbc.caskroom + end + end + def ensure_caskroom_exists unless Hbc.caskroom.exist? ohai "Creating Caskroom at #{Hbc.caskroom}" diff --git a/Library/Homebrew/cask/lib/hbc/cli/list.rb b/Library/Homebrew/cask/lib/hbc/cli/list.rb index ce507a827a..88907a797c 100644 --- a/Library/Homebrew/cask/lib/hbc/cli/list.rb +++ b/Library/Homebrew/cask/lib/hbc/cli/list.rb @@ -79,4 +79,8 @@ class Hbc::CLI::List < Hbc::CLI::Base def self.help "with no args, lists installed Casks; given installed Casks, lists staged files" end + + def self.needs_init? + true + end end diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb index b800cf6b6a..5e18ba8fe6 100644 --- a/Library/Homebrew/cask/lib/hbc/locations.rb +++ b/Library/Homebrew/cask/lib/hbc/locations.rb @@ -9,7 +9,7 @@ module Hbc::Locations end def default_caskroom - @default_caskroom ||= homebrew_repository.join("Caskroom") + @default_caskroom ||= homebrew_prefix.join("Caskroom") end def caskroom From c0cc703516c1c32d42922dbb2af17c09fc340825 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Mon, 19 Sep 2016 15:57:36 +0200 Subject: [PATCH 2/2] update-report: Do not migrate `Caskroom` to `HOMEBREW_REPOSITORY`. --- Library/Homebrew/cmd/update-report.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index f6e73c2eb5..c37a181c9b 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -231,12 +231,8 @@ module Homebrew FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Library/Taps", "#{new_homebrew_repository}/Library/Taps" end - if (HOMEBREW_REPOSITORY/"Caskroom").exist? - FileUtils.cp_r "#{HOMEBREW_REPOSITORY}/Caskroom", "#{new_homebrew_repository}/Caskroom" - end - unremovable_paths = [] - extra_remove_paths = [".git", "Library/Locks", "Library/Taps", "Caskroom", + extra_remove_paths = [".git", "Library/Locks", "Library/Taps", "Library/Homebrew/cask", "Library/Homebrew/test"] (repo_files + extra_remove_paths).each do |file| path = Pathname.new "#{HOMEBREW_REPOSITORY}/#{file}"