homebrew-core/Formula/coreutils.rb
Jaeho Shin cf05a5f208 coreutils: Add man dir with de-prefixed names
Closes Homebrew/homebrew#15876.

Signed-off-by: Charlie Sharpsteen <source@sharpsteen.net>
2012-11-11 08:32:59 -08:00

49 lines
1.5 KiB
Ruby

require 'formula'
class Coreutils < Formula
homepage 'http://www.gnu.org/software/coreutils'
url 'http://ftpmirror.gnu.org/coreutils/coreutils-8.19.tar.xz'
mirror 'http://ftp.gnu.org/gnu/coreutils/coreutils-8.19.tar.xz'
sha256 'ad3873183fd8cfc7672b3ba54644672e59352f9b2dc7e3ad251c1174dde8a9e7'
depends_on 'xz' => :build
def install
system "./configure", "--prefix=#{prefix}", "--program-prefix=g"
system "make install"
# Symlink all commands into libexec/gnubin without the 'g' prefix
coreutils_filenames(bin).each do |cmd|
(libexec/'gnubin').install_symlink bin/"g#{cmd}" => cmd
end
# Symlink all man(1) pages into libexec/gnuman without the 'g' prefix
coreutils_filenames(man1).each do |cmd|
(libexec/'gnuman'/'man1').install_symlink man1/"g#{cmd}" => cmd
end
end
def caveats; <<-EOS.undent
All commands have been installed with the prefix 'g'.
If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"
Additionally, you can access their man pages with normal names if you add
the "gnuman" directory to your MANPATH from your bashrc as well:
MANPATH="$(brew --prefix coreutils)/libexec/gnuman:$MANPATH"
EOS
end
def coreutils_filenames (dir)
filenames = []
dir.find do |path|
next if path.directory? or path.basename.to_s == '.DS_Store'
filenames << path.basename.to_s.sub(/^g/,'')
end
filenames.sort
end
end