132 lines
4.0 KiB
Ruby
132 lines
4.0 KiB
Ruby
class UtilLinux < Formula
|
|
desc "Collection of Linux utilities"
|
|
homepage "https://github.com/karelzak/util-linux"
|
|
url "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.36/util-linux-2.36.2.tar.xz"
|
|
sha256 "f7516ba9d8689343594356f0e5e1a5f0da34adfbc89023437735872bb5024c5f"
|
|
license all_of: [
|
|
"BSD-3-Clause",
|
|
"BSD-4-Clause-UC",
|
|
"GPL-2.0-only",
|
|
"GPL-2.0-or-later",
|
|
"GPL-3.0-or-later",
|
|
"LGPL-2.1-or-later",
|
|
:public_domain,
|
|
]
|
|
|
|
bottle do
|
|
sha256 arm64_big_sur: "ee66c2ac1dd664f78c065d015cd244dac3dff3e268b5633824a84dab03dbfd6f"
|
|
sha256 big_sur: "7561a596823ebb61811d7bf34129d0cac9164e54aa3ae70f79865a4f454ac6b3"
|
|
sha256 catalina: "7f27e259d7013acfe4d22e75c148735de6a7f4b301238be8376ca3a43f20ff73"
|
|
sha256 mojave: "de7bfed47b70d497e2406b7813b966aad7a0436e6fd129d4e12f5df5757e3ef9"
|
|
end
|
|
|
|
keg_only "macOS provides the uuid.h header"
|
|
|
|
depends_on "autoconf" => :build
|
|
depends_on "automake" => :build
|
|
depends_on "libtool" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "gettext"
|
|
|
|
uses_from_macos "ncurses"
|
|
uses_from_macos "zlib"
|
|
|
|
# These binaries are already available in macOS
|
|
def system_bins
|
|
%w[
|
|
cal col colcrt colrm
|
|
getopt
|
|
hexdump
|
|
logger look
|
|
mesg more
|
|
nologin
|
|
renice rev
|
|
ul
|
|
whereis
|
|
]
|
|
end
|
|
|
|
# Fix build for MacOS
|
|
# Remove in the next release
|
|
# Also remove autoconf/automake/libtool/pkg-config dependencies and autogen.sh call
|
|
patch do
|
|
url "https://github.com/karelzak/util-linux/commit/71ba2792ab3f96b5f5d5d3b0a68d35ecfd0f93a2.patch?full_index=1"
|
|
sha256 "bc5188d3f41a7f248ba622f51c8ab8fed0e05355cbe20a5d3b02bbc274e2c7b4"
|
|
end
|
|
|
|
def install
|
|
system "./autogen.sh"
|
|
|
|
system "./configure", "--disable-dependency-tracking",
|
|
"--disable-silent-rules",
|
|
"--prefix=#{prefix}",
|
|
"--disable-ipcs", # does not build on macOS
|
|
"--disable-ipcrm", # does not build on macOS
|
|
"--disable-libmount", # does not build on macOS
|
|
"--disable-wall", # already comes with macOS
|
|
"--enable-libuuid" # conflicts with ossp-uuid
|
|
|
|
system "make", "install"
|
|
|
|
# Remove binaries already shipped by macOS
|
|
system_bins.each do |prog|
|
|
rm_f bin/prog
|
|
rm_f sbin/prog
|
|
rm_f man1/"#{prog}.1"
|
|
rm_f man8/"#{prog}.8"
|
|
rm_f share/"bash-completion/completions/#{prog}"
|
|
end
|
|
|
|
# install completions only for installed programs
|
|
Pathname.glob("bash-completion/*") do |prog|
|
|
bash_completion.install prog if (bin/prog.basename).exist? || (sbin/prog.basename).exist?
|
|
end
|
|
end
|
|
|
|
def caveats
|
|
linux_only_bins = %w[
|
|
addpart agetty
|
|
blkdiscard blkzone blockdev
|
|
chcpu chmem choom chrt ctrlaltdel
|
|
delpart dmesg
|
|
eject
|
|
fallocate fdformat fincore findmnt fsck fsfreeze fstrim
|
|
hwclock
|
|
ionice ipcrm ipcs
|
|
kill
|
|
last ldattach losetup lsblk lscpu lsipc lslocks lslogins lsmem lsns
|
|
mount mountpoint
|
|
nsenter
|
|
partx pivot_root prlimit
|
|
raw readprofile resizepart rfkill rtcwake
|
|
script scriptlive setarch setterm sulogin swapoff swapon switch_root
|
|
taskset
|
|
umount unshare utmpdump uuidd
|
|
wall wdctl
|
|
zramctl
|
|
]
|
|
on_macos do
|
|
<<~EOS
|
|
The following tools are not supported for macOS, and are therefore not included:
|
|
#{Formatter.columns(linux_only_bins)}
|
|
The following tools are shipped by macOS, and are therefore not included:
|
|
#{Formatter.columns(system_bins)}
|
|
EOS
|
|
end
|
|
end
|
|
|
|
test do
|
|
stat = File.stat "/usr"
|
|
owner = Etc.getpwuid(stat.uid).name
|
|
group = Etc.getgrgid(stat.gid).name
|
|
|
|
flags = ["x", "w", "r"] * 3
|
|
perms = flags.each_with_index.reduce("") do |sum, (flag, index)|
|
|
sum.insert 0, ((stat.mode & (2 ** index)).zero? ? "-" : flag)
|
|
end
|
|
|
|
out = shell_output("#{bin}/namei -lx /usr").split("\n").last.split
|
|
assert_equal ["d#{perms}", owner, group, "usr"], out
|
|
end
|
|
end
|