Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GNU formulas: remove default-names option #35720

Closed
wants to merge 12 commits into from
12 changes: 4 additions & 8 deletions Formula/coreutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,14 @@ def install
end

def caveats; <<~EOS
All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

PATH="#{opt_libexec}/gnubin:$PATH"
PATH="#{opt_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="#{opt_libexec}/gnuman:$MANPATH"

MANPATH="#{opt_libexec}/gnuman:$MANPATH"
EOS
end

Expand Down
37 changes: 21 additions & 16 deletions Formula/ed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,39 @@ class Ed < Formula
sha256 "d8d925d35a5e3a08353960f029423b4f6e7427b2ecc916407ae7e541b0ba3cfa" => :yosemite
end

option "with-default-names", "Don't prepend 'g' to the binaries"

deprecated_option "default-names" => "with-default-names"

def install
ENV.deparallelize

args = ["--prefix=#{prefix}"]
args << "--program-prefix=g" if build.without? "default-names"

system "./configure", *args
system "./configure", "--prefix=#{prefix}", "--program-prefix=g"
system "make"
system "make", "install"
end

def caveats
if build.without? "default-names" then <<~EOS
The command has been installed with the prefix "g".
If you do not want the prefix, reinstall using the "with-default-names" option.
EOS
%w[ed red].each do |prog|
(libexec/"gnubin").install_symlink bin/"g#{prog}" => prog
(libexec/"gnuman/man1").install_symlink man1/"g#{prog}.1" => "#{prog}.1"
end
end

def caveats; <<~EOS
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="#{opt_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="#{opt_libexec}/gnuman:$MANPATH"
EOS
end

test do
testfile = testpath/"test"
testfile.write "Hello world\n"
cmd = build.with?("default-names") ? "ed" : "ged"
pipe_output("#{bin}/#{cmd} -s #{testfile}", ",s/o//\nw\n", 0)

pipe_output("#{bin}/ged -s #{testfile}", ",s/o//\nw\n", 0)
assert_equal "Hell world\n", testfile.read

pipe_output("#{opt_libexec}/gnubin/ed -s #{testfile}", ",s/l//g\nw\n", 0)
assert_equal "He word\n", testfile.read
end
end
54 changes: 20 additions & 34 deletions Formula/findutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class Findutils < Formula
sha256 "bc20b7e2a97c3277ea13fd91b44fbc0015628e8684a2bba203c38a4c7357f6c7" => :el_capitan
end

option "with-default-names", "Do not prepend 'g' to the binary"

deprecated_option "default-names" => "with-default-names"

def install
# Work around unremovable, nested dirs bug that affects lots of
# GNU projects. See:
Expand All @@ -31,29 +27,26 @@ def install
--localstatedir=#{var}/locate
--disable-dependency-tracking
--disable-debug
--program-prefix=g
]
args << "--program-prefix=g" if build.without? "default-names"

system "./configure", *args
system "make", "install"

# https://savannah.gnu.org/bugs/index.php?46846
# https://github.com/Homebrew/homebrew/issues/47791
updatedb = (build.with?("default-names") ? "updatedb" : "gupdatedb")
(libexec/"bin").install bin/updatedb
(bin/updatedb).write <<~EOS
(libexec/"bin").install bin/"gupdatedb"
(bin/"gupdatedb").write <<~EOS
#!/bin/sh
export LC_ALL='C'
exec "#{libexec}/bin/#{updatedb}" "$@"
exec "#{libexec}/bin/gupdatedb" "$@"
EOS

if build.without? "default-names"
[[prefix, bin], [share, man/"*"]].each do |base, path|
Dir[path/"g*"].each do |p|
f = Pathname.new(p)
gnupath = "gnu" + f.relative_path_from(base).dirname
(libexec/gnupath).install_symlink f => f.basename.sub(/^g/, "")
end
[[prefix, bin], [share, man/"*"]].each do |base, path|
Dir[path/"g*"].each do |p|
f = Pathname.new(p)
gnupath = "gnu" + f.relative_path_from(base).dirname
(libexec/gnupath).install_symlink f => f.basename.sub(/^g/, "")
end
end
end
Expand All @@ -62,28 +55,21 @@ def post_install
(var/"locate").mkpath
end

def caveats
if build.without? "default-names"
<<~EOS
All commands have been installed with the prefix 'g'.
If you do not want the prefix, install using the "with-default-names" option.

If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
def caveats; <<~EOS
All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="#{opt_libexec}/gnubin:$PATH"

PATH="#{opt_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="#{opt_libexec}/gnuman:$MANPATH"
EOS
end
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="#{opt_libexec}/gnuman:$MANPATH"
EOS
end

test do
find = (build.with?("default-names") ? "find" : "gfind")
touch "HOMEBREW"
assert_match "HOMEBREW", shell_output("#{bin}/#{find} .")
assert_match "HOMEBREW", shell_output("#{bin}/gfind .")
assert_match "HOMEBREW", shell_output("#{opt_libexec}/gnubin/find .")
end
end
27 changes: 17 additions & 10 deletions Formula/gnu-indent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ class GnuIndent < Formula
sha256 "d31ad8b842092150f18dd706d369a0fa6db7fbb41302247eac601c97785218af" => :el_capitan
end

option "with-default-names", "Do not prepend 'g' to the binary"

deprecated_option "default-names" => "with-default-names"

depends_on "gettext"

def install
Expand All @@ -25,17 +21,28 @@ def install
--disable-dependency-tracking
--prefix=#{prefix}
--mandir=#{man}
--program-prefix=g
]

args << "--program-prefix=g" if build.without? "default-names"

system "./configure", *args
system "make", "install"

if build.without? "default-names"
(libexec/"gnubin").install_symlink bin/"gindent" => "indent"
(libexec/"gnuman/man1").install_symlink man1/"gindent.1" => "indent.1"
end
(libexec/"gnubin").install_symlink bin/"gindent" => "indent"
(libexec/"gnuman/man1").install_symlink man1/"gindent.1" => "indent.1"
end

def caveats; <<~EOS
GNU "indent" has been installed as "gindent".
If you need to use it as "indent", you can add a "gnubin" directory
to your PATH from your bashrc like:

PATH="#{opt_libexec}/gnubin:$PATH"

Additionally, you can access its man page with normal name if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

MANPATH="#{opt_libexec}/gnuman:$MANPATH"
EOS
end

test do
Expand Down
44 changes: 19 additions & 25 deletions Formula/gnu-sed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,42 @@ class GnuSed < Formula
sha256 "5c090deefc2dd3769191d97378b981b2dfdd64f1e0259de22682d434ad07e427" => :sierra
end

option "with-default-names", "Do not prepend 'g' to the binary"

deprecated_option "default-names" => "with-default-names"

conflicts_with "ssed", :because => "both install share/info/sed.info"

def install
args = ["--prefix=#{prefix}", "--disable-dependency-tracking"]
args << "--program-prefix=g" if build.without? "default-names"
args = %W[
--prefix=#{prefix}
--disable-dependency-tracking
--program-prefix=g
]

system "./configure", *args
system "make", "install"

if build.without? "default-names"
(libexec/"gnubin").install_symlink bin/"gsed" =>"sed"
(libexec/"gnuman/man1").install_symlink man1/"gsed.1" => "sed.1"
end
(libexec/"gnubin").install_symlink bin/"gsed" =>"sed"
(libexec/"gnuman/man1").install_symlink man1/"gsed.1" => "sed.1"
end

def caveats
if build.without? "default-names" then <<~EOS
The command has been installed with the prefix "g".
If you do not want the prefix, install using the "with-default-names" option.
def caveats; <<~EOS
GNU "sed" has been installed as "gsed".
If you need to use it as "sed", you can add a "gnubin" directory
to your PATH from your bashrc like:

If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="#{opt_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:
Additionally, you can access its man page with normal name if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

MANPATH="#{opt_libexec}/gnuman:$MANPATH"
EOS
end
EOS
end

test do
(testpath/"test.txt").write "Hello world!"
if build.with? "default-names"
system "#{bin}/sed", "-i", "s/world/World/g", "test.txt"
else
system "#{bin}/gsed", "-i", "s/world/World/g", "test.txt"
end
system "#{bin}/gsed", "-i", "s/world/World/g", "test.txt"
assert_match /Hello World!/, File.read("test.txt")

system "#{opt_libexec}/gnubin/sed", "-i", "s/world/World/g", "test.txt"
assert_match /Hello World!/, File.read("test.txt")
end
end
44 changes: 20 additions & 24 deletions Formula/gnu-tar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class GnuTar < Formula
depends_on "gettext" => :build
end

option "with-default-names", "Do not prepend 'g' to the binary"

def install
# Work around unremovable, nested dirs bug that affects lots of
# GNU projects. See:
Expand All @@ -31,42 +29,40 @@ def install
# https://lists.gnu.org/archive/html/bug-tar/2015-10/msg00017.html
ENV["gl_cv_func_getcwd_abort_bug"] = "no" if MacOS.version == :el_capitan

args = ["--prefix=#{prefix}", "--mandir=#{man}"]
args << "--program-prefix=g" if build.without? "default-names"
args = %W[
--prefix=#{prefix}
--mandir=#{man}
--program-prefix=g
]

system "./bootstrap" if build.head?
system "./configure", *args
system "make", "install"

# Symlink the executable into libexec/gnubin as "tar"
if build.without? "default-names"
(libexec/"gnubin").install_symlink bin/"gtar" =>"tar"
(libexec/"gnuman/man1").install_symlink man1/"gtar.1" => "tar.1"
end
(libexec/"gnubin").install_symlink bin/"gtar" =>"tar"
(libexec/"gnuman/man1").install_symlink man1/"gtar.1" => "tar.1"
end

def caveats
if build.without? "default-names" then <<~EOS
gnu-tar has been installed as "gtar".

If you really need to use it as "tar", you can add a "gnubin" directory
to your PATH from your bashrc like:
def caveats; <<~EOS
GNU "tar" has been installed as "gtar".
If you need to use it as "tar", you can add a "gnubin" directory
to your PATH from your bashrc like:

PATH="#{opt_libexec}/gnubin:$PATH"
PATH="#{opt_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:
Additionally, you can access its man page with normal name if you add
the "gnuman" directory to your MANPATH from your bashrc as well:

MANPATH="#{opt_libexec}/gnuman:$MANPATH"

EOS
end
MANPATH="#{opt_libexec}/gnuman:$MANPATH"
EOS
end

test do
tar = build.with?("default-names") ? bin/"tar" : bin/"gtar"
(testpath/"test").write("test")
system tar, "-czvf", "test.tar.gz", "test"
assert_match /test/, shell_output("#{tar} -xOzf test.tar.gz")
system bin/"gtar", "-czvf", "test.tar.gz", "test"
assert_match /test/, shell_output("#{bin}/gtar -xOzf test.tar.gz")

assert_match /test/, shell_output("#{opt_libexec}/gnubin/tar -xOzf test.tar.gz")
end
end
26 changes: 15 additions & 11 deletions Formula/gnu-time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ class GnuTime < Formula
sha256 "a6ae05233326897ed622ab5c6ee63081e1c445b5e7496c68efa00dd5718b589c" => :el_capitan
end

option "with-default-names", "Do not prepend 'g' to the binary"

def install
args = [
"--prefix=#{prefix}",
"--mandir=#{man}",
"--info=#{info}",
args = %W[
--prefix=#{prefix}
--info=#{info}
--program-prefix=g
]

args << "--program-prefix=g" if build.without? "default-names"

system "./configure", *args
system "make", "install"

if build.without? "default-names"
(libexec/"gnubin").install_symlink bin/"gtime" => "time"
end
(libexec/"gnubin").install_symlink bin/"gtime" => "time"
end

def caveats; <<~EOS
GNU "time" has been installed as "gtime".
If you need to use it as "time", you can add a "gnubin" directory
to your PATH from your bashrc like:

PATH="#{opt_libexec}/gnubin:$PATH"
EOS
end

test do
system bin/"gtime", "ruby", "--version"
system opt_libexec/"gnubin/time", "ruby", "--version"
end
end
Loading