117 lines
3.9 KiB
Ruby
117 lines
3.9 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.37/util-linux-2.37.tar.xz"
|
|
sha256 "bd07b7e98839e0359842110525a3032fdb8eaf3a90bedde3dd1652d32d15cce5"
|
|
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: "922d09f5174a8987fdd7de56103eb6415a561c7490ab149e86bd8959c5832044"
|
|
sha256 big_sur: "cfca1e4ceeccb7b27f043b6e63d29cd5a2d64908d995530b37f270d751baa208"
|
|
sha256 catalina: "8edf1edb90bab5bfd76c11dacfd8f8e9a212d154284113d56089ac225944f05d"
|
|
sha256 mojave: "4d7d5e3771db846dd2f1c6b74c867ad1119983a5fb96ac503d40860cf2fc37f4"
|
|
sha256 x86_64_linux: "e06a8924c46aae6e7c62ad4a61dcb1771db5222aaa94582c67d162682e4ddd77"
|
|
end
|
|
|
|
keg_only :shadowed_by_macos, "macOS provides the uuid.h header"
|
|
|
|
depends_on "asciidoctor" => :build
|
|
depends_on "gettext"
|
|
|
|
uses_from_macos "ncurses"
|
|
uses_from_macos "zlib"
|
|
|
|
on_linux do
|
|
conflicts_with "bash-completion", because: "both install `mount`, `rfkill`, and `rtcwake` completions"
|
|
conflicts_with "rename", because: "both install `rename` binaries"
|
|
end
|
|
|
|
def install
|
|
args = std_configure_args + %w[
|
|
--disable-silent-rules
|
|
]
|
|
|
|
if OS.mac?
|
|
args << "--disable-hardlink" # does not build on macOS
|
|
args << "--disable-ipcs" # does not build on macOS
|
|
args << "--disable-ipcrm" # does not build on macOS
|
|
args << "--disable-wall" # already comes with macOS
|
|
args << "--disable-libmount" # does not build on macOS
|
|
args << "--enable-libuuid" # conflicts with ossp-uuid
|
|
else
|
|
args << "--disable-use-tty-group" # Fix chgrp: changing group of 'wall': Operation not permitted
|
|
args << "--disable-kill" # Conflicts with coreutils.
|
|
args << "--disable-cal" # Conflicts with bsdmainutils
|
|
args << "--without-systemd" # Do not install systemd files
|
|
args << "--with-bashcompletiondir=#{bash_completion}"
|
|
args << "--disable-chfn-chsh"
|
|
args << "--disable-login"
|
|
args << "--disable-su"
|
|
args << "--disable-runuser"
|
|
args << "--disable-makeinstall-chown"
|
|
args << "--disable-makeinstall-setuid"
|
|
args << "--without-python"
|
|
end
|
|
|
|
system "./configure", *args
|
|
system "make", "install"
|
|
|
|
# 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
|
|
hardlink 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)}
|
|
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
|