(un)linkapps: allow unlink/link specific formulae.
Closes Homebrew/homebrew#35080. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
d97daa7c1b
commit
fff4b83a52
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,7 @@
|
||||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "BREW" "1" "November 2014" "Homebrew" "brew"
|
||||
.TH "BREW" "1" "December 2014" "Homebrew" "brew"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBbrew\fR \- The missing package manager for OS X
|
||||
@ -251,8 +251,11 @@ If \fB\-\-dry\-run\fR or \fB\-n\fR is passed, Homebrew will list all files which
|
||||
If \fB\-\-force\fR is passed, Homebrew will allow keg\-only formulae to be linked\.
|
||||
.
|
||||
.TP
|
||||
\fBlinkapps [\-\-local]\fR
|
||||
Find all installed formulae that have compiled \fB\.app\fR\-style "application" packages for OS X, and symlink those apps into \fB/Applications\fR, allowing for easier access\.
|
||||
\fBlinkapps [\-\-local] [<formulae>]\fR
|
||||
Find installed formulae that have compiled \fB\.app\fR\-style "application" packages for OS X, and symlink those apps into \fB/Applications\fR, allowing for easier access\.
|
||||
.
|
||||
.IP
|
||||
If no \fIformulae\fR are provided, all of them will have their \.apps symlinked\.
|
||||
.
|
||||
.IP
|
||||
If provided, \fB\-\-local\fR will move them into the user\'s \fB~/Applications\fR folder instead of the system folder\. It may need to be created, first\.
|
||||
@ -376,9 +379,12 @@ Example: \fBbrew install jruby && brew test jruby\fR
|
||||
Remove symlinks for \fIformula\fR from the Homebrew prefix\. This can be useful for temporarily disabling a formula: \fBbrew unlink foo && commands && brew link foo\fR\.
|
||||
.
|
||||
.TP
|
||||
\fBunlinkapps [\-\-local]\fR
|
||||
\fBunlinkapps [\-\-local] [<formulae>]\fR
|
||||
Removes links created by \fBbrew linkapps\fR\.
|
||||
.
|
||||
.IP
|
||||
If no \fIformulae\fR are provided, all linked app will be removed\.
|
||||
.
|
||||
.TP
|
||||
\fBunpack [\-\-git|\-\-patch] [\-\-destdir=<path>]\fR \fIformulae\fR:
|
||||
.
|
||||
|
Loading…
x
Reference in New Issue
Block a user