-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
class GnuTar < Formula | ||
desc "GNU version of the tar archiving utility" | ||
homepage "https://www.gnu.org/software/tar/" | ||
url "https://ftp.gnu.org/gnu/tar/tar-1.35.tar.gz" | ||
mirror "https://ftpmirror.gnu.org/tar/tar-1.35.tar.gz" | ||
sha256 "14d55e32063ea9526e057fbf35fcabd53378e769787eff7919c3755b02d2b57e" | ||
license "GPL-3.0-or-later" | ||
|
||
bottle do | ||
root_url "https://github.com/gromgit/homebrew-core/releases/download/gnu-tar-1.35" | ||
sha256 cellar: :any_skip_relocation, aarch64_linux: "83ef8ba466c84d5045fc67fbb30341fa392b38610ac08d759015c8b497ab5a98" | ||
end | ||
|
||
head do | ||
url "https://git.savannah.gnu.org/git/tar.git", branch: "master" | ||
|
||
depends_on "autoconf" => :build | ||
depends_on "automake" => :build | ||
depends_on "gettext" => :build | ||
end | ||
|
||
on_linux do | ||
depends_on "acl" | ||
end | ||
|
||
def install | ||
args = %W[ | ||
--prefix=#{prefix} | ||
--mandir=#{man} | ||
--disable-nls | ||
] | ||
|
||
args << if OS.mac? | ||
"--program-prefix=g" | ||
else | ||
"--without-selinux" | ||
end | ||
|
||
# iconv is detected during configure process but -liconv is missing | ||
# from LDFLAGS as of gnu-tar 1.35. Remove once iconv linking works | ||
# without this. See https://savannah.gnu.org/bugs/?64441. | ||
# fix commit, https://git.savannah.gnu.org/cgit/tar.git/commit/?id=8632df39, remove in next release | ||
ENV.append "LDFLAGS", "-liconv" if OS.mac? | ||
|
||
system "./bootstrap" if build.head? | ||
system "./configure", *args | ||
system "make", "install" | ||
|
||
return unless OS.mac? | ||
|
||
# Symlink the executable into libexec/gnubin as "tar" | ||
(libexec/"gnubin").install_symlink bin/"gtar" => "tar" | ||
(libexec/"gnuman/man1").install_symlink man1/"gtar.1" => "tar.1" | ||
(libexec/"gnubin").install_symlink "../gnuman" => "man" | ||
end | ||
|
||
def caveats | ||
on_macos do | ||
<<~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" | ||
EOS | ||
end | ||
end | ||
|
||
test do | ||
(testpath/"test").write("test") | ||
if OS.mac? | ||
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") | ||
else | ||
system bin/"tar", "-czvf", "test.tar.gz", "test" | ||
assert_match "test", shell_output("#{bin}/tar -xOzf test.tar.gz") | ||
end | ||
end | ||
end |