diff options
| author | Xu Cheng | 2014-12-18 15:13:04 +0800 |
|---|---|---|
| committer | Mike McQuaid | 2014-12-19 16:35:45 +0000 |
| commit | fff4b83a52afa32cac83981bc7ccc06658621b9c (patch) | |
| tree | d7bab26b260d2a6b5db34d26cf1fd33a981d7083 /Library/Homebrew | |
| parent | d97daa7c1b2203be02c69124bc7b3ae5f2b50f99 (diff) | |
| download | brew-fff4b83a52afa32cac83981bc7ccc06658621b9c.tar.bz2 | |
(un)linkapps: allow unlink/link specific formulae.
Closes Homebrew/homebrew#35080.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/caveats.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/linkapps.rb | 17 | ||||
| -rw-r--r-- | Library/Homebrew/cmd/unlinkapps.rb | 22 | ||||
| -rw-r--r-- | Library/Homebrew/manpages/brew.1.md | 10 |
4 files changed, 34 insertions, 17 deletions
diff --git a/Library/Homebrew/caveats.rb b/Library/Homebrew/caveats.rb index e3ff6332c..0eb5b2af2 100644 --- a/Library/Homebrew/caveats.rb +++ b/Library/Homebrew/caveats.rb @@ -97,7 +97,7 @@ class Caveats if keg and keg.app_installed? <<-EOS.undent .app bundles were installed. - Run `brew linkapps` to symlink these to /Applications. + Run `brew linkapps #{keg.name}` to symlink these to /Applications. EOS end end diff --git a/Library/Homebrew/cmd/linkapps.rb b/Library/Homebrew/cmd/linkapps.rb index 50df5daa2..7e8430c75 100644 --- a/Library/Homebrew/cmd/linkapps.rb +++ b/Library/Homebrew/cmd/linkapps.rb @@ -11,12 +11,19 @@ module Homebrew exit 1 end - HOMEBREW_CELLAR.subdirs.each do |rack| - kegs = rack.subdirs.map { |d| Keg.new(d) } - next if kegs.empty? - - keg = kegs.detect(&:linked?) || kegs.max {|a,b| a.version <=> b.version} + if ARGV.named.empty? + racks = HOMEBREW_CELLAR.subdirs + kegs = racks.map do |rack| + keg = rack.subdirs.map { |d| Keg.new(d) } + next if keg.empty? + keg.detect(&:linked?) || keg.max {|a,b| a.version <=> b.version} + end + else + kegs = ARGV.kegs + end + kegs.each do |keg| + keg = keg.opt_record if keg.optlinked? Dir["#{keg}/*.app", "#{keg}/bin/*.app", "#{keg}/libexec/*.app"].each do |app| puts "Linking #{app}" app_name = File.basename(app) diff --git a/Library/Homebrew/cmd/unlinkapps.rb b/Library/Homebrew/cmd/unlinkapps.rb index 864e33b27..ef11db602 100644 --- a/Library/Homebrew/cmd/unlinkapps.rb +++ b/Library/Homebrew/cmd/unlinkapps.rb @@ -5,15 +5,11 @@ module Homebrew def unlinkapps target_dir = ARGV.include?("--local") ? File.expand_path("~/Applications") : "/Applications" - unless File.exist? target_dir - opoo "#{target_dir} does not exist, stopping." - puts "Run `mkdir #{target_dir}` first." - exit 1 - end + return unless File.exist? target_dir - cellar_apps = Dir[target_dir + '/*.app'].select do |app| - if File.symlink?(app) && File.readlink(app).match(HOMEBREW_CELLAR) - File.readlink app + cellar_apps = Dir[target_dir + "/*.app"].select do |app| + if File.symlink?(app) + should_unlink? File.readlink(app) end end @@ -24,4 +20,14 @@ module Homebrew puts "Finished unlinking from #{target_dir}" if cellar_apps end + + private + + def should_unlink? file + if ARGV.named.empty? + file.match(HOMEBREW_CELLAR) || file.match("#{HOMEBREW_PREFIX}/opt") + else + ARGV.kegs.any? { |keg| file.match(keg.to_s) || file.match(keg.opt_record.to_s) } + end + end end diff --git a/Library/Homebrew/manpages/brew.1.md b/Library/Homebrew/manpages/brew.1.md index 4edb54022..35a6755d6 100644 --- a/Library/Homebrew/manpages/brew.1.md +++ b/Library/Homebrew/manpages/brew.1.md @@ -234,11 +234,13 @@ Note that these flags should only appear after a command. If `--force` is passed, Homebrew will allow keg-only formulae to be linked. - * `linkapps [--local]`: - Find all installed formulae that have compiled `.app`-style "application" + * `linkapps [--local] [<formulae>]`: + Find installed formulae that have compiled `.app`-style "application" packages for OS X, and symlink those apps into `/Applications`, allowing for easier access. + If no <formulae> are provided, all of them will have their .apps symlinked. + If provided, `--local` will move them into the user's `~/Applications` folder instead of the system folder. It may need to be created, first. @@ -355,9 +357,11 @@ Note that these flags should only appear after a command. for temporarily disabling a formula: `brew unlink foo && commands && brew link foo`. - * `unlinkapps [--local]`: + * `unlinkapps [--local] [<formulae>]`: Removes links created by `brew linkapps`. + If no <formulae> are provided, all linked app will be removed. + * `unpack [--git|--patch] [--destdir=<path>]` <formulae>: Unpack the source files for <formulae> into subdirectories of the current |
