class Findutils < Formula desc "Collection of GNU find, xargs, and locate" homepage "https://www.gnu.org/software/findutils/" url "https://ftp.gnu.org/gnu/findutils/findutils-4.6.0.tar.gz" mirror "https://ftpmirror.gnu.org/findutils/findutils-4.6.0.tar.gz" sha256 "ded4c9f73731cd48fec3b6bdaccce896473b6d8e337e9612e16cf1431bb1169d" bottle do rebuild 2 sha256 "8411fd3a9a42a2be0c52b4ae8cad2dd60add473a4cf882620200ab43442fb5c2" => :high_sierra sha256 "c1ecad1c780cb569d268ca5648570dcc753cca720ead2783943aea0363af728e" => :sierra sha256 "bc20b7e2a97c3277ea13fd91b44fbc0015628e8684a2bba203c38a4c7357f6c7" => :el_capitan end deprecated_option "default-names" => "with-default-names" 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: # https://github.com/Homebrew/homebrew/issues/45273 # https://github.com/Homebrew/homebrew/issues/44993 # This is thought to be an el_capitan bug: # 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 = %W[ --prefix=#{prefix} --localstatedir=#{var}/locate --disable-dependency-tracking --disable-debug ] 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 #!/bin/sh export LC_ALL='C' exec "#{libexec}/bin/#{updatedb}" "$@" 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 end end end 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: 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 end test do find = (build.with?("default-names") ? "find" : "gfind") touch "HOMEBREW" assert_match "HOMEBREW", shell_output("#{bin}/#{find} .") end end