From be5484da8c1970b5175db91a4983420ece6ed434 Mon Sep 17 00:00:00 2001 From: AnastasiaSulyagina Date: Tue, 26 Jul 2016 00:15:21 +0300 Subject: [PATCH] update-report: allow Casks migration to formulae. Closes #588. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/update-report.rb | 28 +++++++++++++++++++++++++-- Library/Homebrew/cmd/update.sh | 2 ++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 4d018290e8..b9f5a9cb83 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -193,7 +193,7 @@ class Reporter dst = Pathname.new paths.last next unless dst.extname == ".rb" - next unless paths.any? { |p| tap.formula_file?(p) } + next unless paths.any? { |p| tap.formula_file?(p)} case status when "A", "D" @@ -249,8 +249,32 @@ class Reporter def migrate_tap_migration report[:D].each do |full_name| name = full_name.split("/").last + new_tap_name = tap.tap_migrations[name] + next if new_tap_name.nil? # skip if not in tap_migrations list. + + if tap == "caskroom/cask" + next unless (HOMEBREW_REPOSITORY/"Caskroom"/name).exist? + new_tap = Tap.fetch(new_tap_name) + new_tap.install unless new_tap.installed? + ohai "#{name} has been moved to Homebrew.", <<-EOS.undent + To uninstall the cask run: + brew cask uninstall --force #{name} + EOS + new_full_name = "#{new_tap_name}/#{name}" + next if (HOMEBREW_CELLAR/name.split("/").last).directory? + ohai "Installing #{name}..." + system HOMEBREW_BREW_FILE, "install", new_full_name + begin + unless Formulary.factory(new_full_name).keg_only? + system HOMEBREW_BREW_FILE, "link", new_full_name, "--force" + end + rescue Exception => e + onoe e if ARGV.homebrew_developer? + end + next + end + next unless (dir = HOMEBREW_CELLAR/name).exist? # skip if formula is not installed. - next unless new_tap_name = tap.tap_migrations[name] # skip if formula is not in tap_migrations list. tabs = dir.subdirs.map { |d| Tab.for_keg(Keg.new(d)) } next unless tabs.first.tap == tap # skip if installed formula is not from this tap. new_tap = Tap.fetch(new_tap_name) diff --git a/Library/Homebrew/cmd/update.sh b/Library/Homebrew/cmd/update.sh index 9feb0a7b9e..3621cfde81 100644 --- a/Library/Homebrew/cmd/update.sh +++ b/Library/Homebrew/cmd/update.sh @@ -359,6 +359,8 @@ EOS # only allow one instance of brew update lock update + # prevent recursive updates + export HOMEBREW_NO_AUTO_UPDATE="1" git_init_if_necessary # rename Taps directories