-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
coreutils.rb
126 lines (107 loc) 路 4.25 KB
/
coreutils.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
class Coreutils < Formula
desc "GNU File, Shell, and Text utilities"
homepage "https://www.gnu.org/software/coreutils"
url "https://ftp.gnu.org/gnu/coreutils/coreutils-9.5.tar.xz"
mirror "https://ftpmirror.gnu.org/coreutils/coreutils-9.5.tar.xz"
sha256 "cd328edeac92f6a665de9f323c93b712af1858bc2e0d88f3f7100469470a1b8a"
license "GPL-3.0-or-later"
bottle do
sha256 arm64_sonoma: "b2c643420d7d9de89385d86e0c3f5e9f9ae2404ce378db574dabbfce3ca37a91"
sha256 arm64_ventura: "0f889fb75ebc8e96aa1f38aff6ed1bc7e87c45b70f7644c7e1492f1f9480f352"
sha256 arm64_monterey: "43bb62929309c51bb600e0d156b107ef147094445b29ada1387c222d9a2465c4"
sha256 sonoma: "19eccdcccfcacd67000acf89e3261174dfe30b0a764d10ccc39be82a4b37c0a5"
sha256 ventura: "7c8c3c6eab6032c379bb7266bf78e25b3b3d38d167c4eee92a7c023b131b86e0"
sha256 monterey: "44ce33f1d4d73b54bf312f48c9d93bd7a186f4ce1adc004c9f3168da004eee6c"
sha256 x86_64_linux: "e48884f502b3236e747b1280d5373d058b4bb47f872c99533d90ba2e730f3266"
end
head do
url "https://git.savannah.gnu.org/git/coreutils.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "bison" => :build
depends_on "gettext" => :build
depends_on "texinfo" => :build
depends_on "wget" => :build
depends_on "xz" => :build
end
depends_on "gmp"
uses_from_macos "gperf" => :build
on_macos do
conflicts_with "uutils-coreutils", because: "coreutils and uutils-coreutils install the same binaries"
end
on_linux do
depends_on "attr"
end
conflicts_with "aardvark_shell_utils", because: "both install `realpath` binaries"
conflicts_with "b2sum", because: "both install `b2sum` binaries"
conflicts_with "ganglia", because: "both install `gstat` binaries"
conflicts_with "gfold", because: "both install `gfold` binaries"
conflicts_with "idutils", because: "both install `gid` and `gid.1`"
conflicts_with "md5sha1sum", because: "both install `md5sum` and `sha1sum` binaries"
# https://github.com/Homebrew/homebrew-core/pull/36494
def breaks_macos_users
%w[dir dircolors vdir]
end
def install
system "./bootstrap" if build.head?
args = %W[
--prefix=#{prefix}
--program-prefix=g
--with-libgmp
--without-selinux
]
system "./configure", *args
system "make", "install"
no_conflict = if OS.mac?
[]
else
%w[
b2sum base32 basenc chcon dir dircolors factor hostid md5sum nproc numfmt pinky ptx realpath runcon
sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf stdbuf tac timeout truncate vdir
]
end
# Symlink all commands into libexec/gnubin without the 'g' prefix
coreutils_filenames(bin).each do |cmd|
(libexec/"gnubin").install_symlink bin/"g#{cmd}" => cmd
# Find non-conflicting commands on macOS
which_cmd = which(cmd)
no_conflict << cmd if OS.mac? && (which_cmd.nil? || !which_cmd.to_s.start_with?(%r{(/usr)?/s?bin}))
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
libexec.install_symlink "gnuman" => "man"
no_conflict -= breaks_macos_users if OS.mac?
# Symlink non-conflicting binaries
no_conflict.each do |cmd|
bin.install_symlink "g#{cmd}" => cmd
man1.install_symlink "g#{cmd}.1" => "#{cmd}.1"
end
end
def caveats
msg = "Commands also provided by macOS and the commands #{breaks_macos_users.join(", ")}"
on_linux do
msg = "All commands"
end
<<~EOS
#{msg} 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 with:
PATH="#{opt_libexec}/gnubin:$PATH"
EOS
end
def coreutils_filenames(dir)
filenames = []
dir.find do |path|
next if path.directory? || path.basename.to_s == ".DS_Store"
filenames << path.basename.to_s.sub(/^g/, "")
end
filenames.sort
end
test do
(testpath/"test").write("test")
(testpath/"test.sha1").write("a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 test")
system bin/"gsha1sum", "-c", "test.sha1"
system bin/"gln", "-f", "test", "test.sha1"
end
end