(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?
|
if keg and keg.app_installed?
|
||||||
<<-EOS.undent
|
<<-EOS.undent
|
||||||
.app bundles were installed.
|
.app bundles were installed.
|
||||||
Run `brew linkapps` to symlink these to /Applications.
|
Run `brew linkapps #{keg.name}` to symlink these to /Applications.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,12 +11,19 @@ module Homebrew
|
|||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
HOMEBREW_CELLAR.subdirs.each do |rack|
|
if ARGV.named.empty?
|
||||||
kegs = rack.subdirs.map { |d| Keg.new(d) }
|
racks = HOMEBREW_CELLAR.subdirs
|
||||||
next if kegs.empty?
|
kegs = racks.map do |rack|
|
||||||
|
keg = rack.subdirs.map { |d| Keg.new(d) }
|
||||||
keg = kegs.detect(&:linked?) || kegs.max {|a,b| a.version <=> b.version}
|
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|
|
Dir["#{keg}/*.app", "#{keg}/bin/*.app", "#{keg}/libexec/*.app"].each do |app|
|
||||||
puts "Linking #{app}"
|
puts "Linking #{app}"
|
||||||
app_name = File.basename(app)
|
app_name = File.basename(app)
|
||||||
|
@ -5,15 +5,11 @@ module Homebrew
|
|||||||
def unlinkapps
|
def unlinkapps
|
||||||
target_dir = ARGV.include?("--local") ? File.expand_path("~/Applications") : "/Applications"
|
target_dir = ARGV.include?("--local") ? File.expand_path("~/Applications") : "/Applications"
|
||||||
|
|
||||||
unless File.exist? target_dir
|
return unless File.exist? target_dir
|
||||||
opoo "#{target_dir} does not exist, stopping."
|
|
||||||
puts "Run `mkdir #{target_dir}` first."
|
|
||||||
exit 1
|
|
||||||
end
|
|
||||||
|
|
||||||
cellar_apps = Dir[target_dir + '/*.app'].select do |app|
|
cellar_apps = Dir[target_dir + "/*.app"].select do |app|
|
||||||
if File.symlink?(app) && File.readlink(app).match(HOMEBREW_CELLAR)
|
if File.symlink?(app)
|
||||||
File.readlink app
|
should_unlink? File.readlink(app)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -24,4 +20,14 @@ module Homebrew
|
|||||||
|
|
||||||
puts "Finished unlinking from #{target_dir}" if cellar_apps
|
puts "Finished unlinking from #{target_dir}" if cellar_apps
|
||||||
end
|
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
|
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.
|
If `--force` is passed, Homebrew will allow keg-only formulae to be linked.
|
||||||
|
|
||||||
* `linkapps [--local]`:
|
* `linkapps [--local] [<formulae>]`:
|
||||||
Find all installed formulae that have compiled `.app`-style "application"
|
Find installed formulae that have compiled `.app`-style "application"
|
||||||
packages for OS X, and symlink those apps into `/Applications`, allowing
|
packages for OS X, and symlink those apps into `/Applications`, allowing
|
||||||
for easier access.
|
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`
|
If provided, `--local` will move them into the user's `~/Applications`
|
||||||
folder instead of the system folder. It may need to be created, first.
|
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:
|
for temporarily disabling a formula:
|
||||||
`brew unlink foo && commands && brew link foo`.
|
`brew unlink foo && commands && brew link foo`.
|
||||||
|
|
||||||
* `unlinkapps [--local]`:
|
* `unlinkapps [--local] [<formulae>]`:
|
||||||
Removes links created by `brew linkapps`.
|
Removes links created by `brew linkapps`.
|
||||||
|
|
||||||
|
If no <formulae> are provided, all linked app will be removed.
|
||||||
|
|
||||||
* `unpack [--git|--patch] [--destdir=<path>]` <formulae>:
|
* `unpack [--git|--patch] [--destdir=<path>]` <formulae>:
|
||||||
|
|
||||||
Unpack the source files for <formulae> into subdirectories of the current
|
Unpack the source files for <formulae> into subdirectories of the current
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
.\" generated with Ronn/v0.7.3
|
.\" generated with Ronn/v0.7.3
|
||||||
.\" http://github.com/rtomayko/ronn/tree/0.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"
|
.SH "NAME"
|
||||||
\fBbrew\fR \- The missing package manager for OS X
|
\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\.
|
If \fB\-\-force\fR is passed, Homebrew will allow keg\-only formulae to be linked\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBlinkapps [\-\-local]\fR
|
\fBlinkapps [\-\-local] [<formulae>]\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\.
|
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
|
.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\.
|
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\.
|
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
|
.TP
|
||||||
\fBunlinkapps [\-\-local]\fR
|
\fBunlinkapps [\-\-local] [<formulae>]\fR
|
||||||
Removes links created by \fBbrew linkapps\fR\.
|
Removes links created by \fBbrew linkapps\fR\.
|
||||||
.
|
.
|
||||||
|
.IP
|
||||||
|
If no \fIformulae\fR are provided, all linked app will be removed\.
|
||||||
|
.
|
||||||
.TP
|
.TP
|
||||||
\fBunpack [\-\-git|\-\-patch] [\-\-destdir=<path>]\fR \fIformulae\fR:
|
\fBunpack [\-\-git|\-\-patch] [\-\-destdir=<path>]\fR \fIformulae\fR:
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user