From fdd3469fca62eab96ed0c111451ba0e0a2efbbcc Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Tue, 20 Oct 2015 07:05:21 +0200 Subject: [PATCH] linkapps: stop linking .app bundles from 'bin/' `Keg#app_installed?` only checks the formula prefix and `libexec/` for .app bundles to determine if a formula provides any. This is used by `Caveats#app_caveats` to generate an appropriate message. The same list should be used by `brew linkapps` for consistency. Reduce likelihood of future inconsistencies by creating `Keg#apps` and using it in place of the duplicate code. Closes Homebrew/homebrew#45173. Signed-off-by: Xu Cheng --- Library/Homebrew/cmd/linkapps.rb | 6 ++---- Library/Homebrew/keg.rb | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb index 9a58bd37a9..dba9beaa50 100644 --- a/Library/Homebrew/cmd/linkapps.rb +++ b/Library/Homebrew/cmd/linkapps.rb @@ -23,11 +23,9 @@ module Homebrew end kegs.each do |keg| - keg = keg.opt_record if keg.optlinked? - Dir["#{keg}/*.app", "#{keg}/bin/*.app", "#{keg}/libexec/*.app"].each do |app| + keg.apps.each do |app| puts "Linking #{app} to #{target_dir}." - app_name = File.basename(app) - target = "#{target_dir}/#{app_name}" + target = "#{target_dir}/#{app.basename}" if File.exist?(target) && !File.symlink?(target) onoe "#{target} already exists, skipping." diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 1d03619836..9b548b83af 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -253,8 +253,13 @@ class Keg Dir["#{path}/lib/python2.7/site-packages/*.pth"].any? end + def apps + app_prefix = optlinked? ? opt_record : path + Pathname.glob("#{app_prefix}/{,libexec/}*.app") + end + def app_installed? - Dir["#{path}/{,libexec/}*.app"].any? + !apps.empty? end def elisp_installed?