2009-07-24 15:10:01 +01:00
|
|
|
# Copyright 2009 Max Howell <max@methylblue.com>
|
|
|
|
#
|
|
|
|
# This file is part of Homebrew.
|
|
|
|
#
|
|
|
|
# Homebrew is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Homebrew is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Homebrew. If not, see <http://www.gnu.org/licenses/>.
|
2009-08-10 16:48:30 +01:00
|
|
|
#
|
|
|
|
class Keg <Pathname
|
|
|
|
def initialize path
|
|
|
|
super path
|
|
|
|
raise "#{to_s} is not a valid keg" unless parent.parent == HOMEBREW_CELLAR
|
|
|
|
raise "#{to_s} is not a directory" unless directory?
|
|
|
|
end
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
def uninstall
|
|
|
|
chmod_R 0777 # ensure we have permission to delete
|
|
|
|
rmtree
|
|
|
|
parent.rmdir_if_possible
|
2009-07-24 15:10:01 +01:00
|
|
|
end
|
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
def link
|
|
|
|
$n=0
|
|
|
|
$d=0
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
mkpaths=(1..9).collect {|x| "man/man#{x}"} <<'man'<<'doc'<<'locale'<<'info'<<'aclocal'
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
# yeah indeed, you have to force anything you need in the main tree into
|
|
|
|
# these dirs REMEMBER that *NOT* everything needs to be in the main tree
|
|
|
|
link_dir('etc') {:mkpath}
|
|
|
|
link_dir('bin') {:link}
|
2009-08-12 09:43:16 +08:00
|
|
|
link_dir('sbin') {:link}
|
2009-08-08 14:10:32 +01:00
|
|
|
link_dir('lib') {|path| :mkpath if %w[pkgconfig php perl5].include? path.to_s}
|
2009-08-10 16:48:30 +01:00
|
|
|
link_dir('include') {:link}
|
|
|
|
link_dir('share') {|path| :mkpath if mkpaths.include? path.to_s}
|
2009-07-29 00:56:22 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
return $n+$d
|
2009-07-24 15:10:01 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
2009-08-10 16:48:30 +01:00
|
|
|
# symlinks the contents of self+foo recursively into /usr/local/foo
|
|
|
|
def link_dir foo
|
|
|
|
root=self+foo
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
root.find do |src|
|
|
|
|
next if src == root
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
dst=HOMEBREW_PREFIX+src.relative_path_from(self)
|
|
|
|
dst.extend ObserverPathnameExtension
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
if src.file?
|
|
|
|
dst.make_relative_symlink src
|
|
|
|
elsif src.directory?
|
2009-07-24 15:10:01 +01:00
|
|
|
# no need to put .app bundles in the path, the user can just use
|
|
|
|
# spotlight, or the open command and actual mac apps use an equivalent
|
2009-08-10 16:48:30 +01:00
|
|
|
Find.prune if src.extname.to_s == '.app'
|
2009-07-24 15:10:01 +01:00
|
|
|
|
2009-08-10 16:48:30 +01:00
|
|
|
case yield src.relative_path_from(root)
|
|
|
|
when :skip then Find.prune
|
|
|
|
when :mkpath then dst.mkpath
|
|
|
|
else dst.make_relative_symlink src; Find.prune
|
2009-07-24 15:10:01 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-08-10 16:48:30 +01:00
|
|
|
end
|