-
-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Expand file tree
/
Copy pathutil-linux.rb
More file actions
143 lines (125 loc) · 5.03 KB
/
util-linux.rb
File metadata and controls
143 lines (125 loc) · 5.03 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class UtilLinux < Formula
desc "Collection of Linux utilities"
homepage "https://github.com/util-linux/util-linux"
url "https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.42/util-linux-2.42.tar.xz"
sha256 "3452b260bbaa775d6e749ac3bb22111785003fc1f444970025c8da26dfa758e9"
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,
]
compatibility_version 1
# The directory listing where the `stable` archive is found uses major/minor
# version directories, where it's necessary to check inside a directory to
# find the full version. The newest directory can contain unstable versions,
# so it could require more than two requests to identify the newest stable
# version. With this in mind, we simply check the Git tags as a best effort.
livecheck do
url :homepage
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
bottle do
sha256 arm64_tahoe: "22c68cf329077a00f5c2eb9ea3030c305be6837e1a1dd8fc87da1329d57cef26"
sha256 arm64_sequoia: "a4100e6dc75510d4820b3fcbecf3f224a37a97299aafb2380a9bb29948b976ab"
sha256 arm64_sonoma: "7145241dd73fc2d948dafdae4e4b8da48954dff12bca3bd277c33d64377897b9"
sha256 sonoma: "9488d859b2612179a1085086d8df291f307c9c4473fec0a20718da8aa8f237b6"
sha256 arm64_linux: "9237db9b3c08580b2e6d13c386b7fa282d80a4038861dab51276a993f196a5dd"
sha256 x86_64_linux: "e97b24d7baa64ffc4a3a61aedd8daf41d3a3559be823910a9ca218dc24d62497"
end
keg_only :shadowed_by_macos, "macOS provides the uuid.h header"
depends_on "pkgconf" => :build
uses_from_macos "libxcrypt"
uses_from_macos "ncurses"
uses_from_macos "sqlite"
on_macos do
depends_on "gettext" # for libintl
end
on_linux do
depends_on "readline"
depends_on "zlib-ng-compat"
conflicts_with "bash-completion", because: "both install `mount`, `rfkill`, and `rtcwake` completions"
conflicts_with "flock", because: "both install `flock` binaries"
conflicts_with "ossp-uuid", because: "both install `uuid.3` file"
conflicts_with "rename", because: "both install `rename` binaries"
end
# Fix macOS builds
# https://github.com/util-linux/util-linux/pull/4173
patch do
url "https://github.com/util-linux/util-linux/commit/d22edc2f100eb8dd83d3515758565cb73b0d2eed.patch?full_index=1"
sha256 "2fb01154faa3fd8b0fce27eb88049ed9c8f839e706e412399c19c087f7f3b5e1"
end
def install
args = %W[--disable-silent-rules --disable-asciidoc --with-bashcompletiondir=#{bash_completion}]
if OS.mac?
# Support very old ncurses used on macOS 13 and earlier
# https://github.com/util-linux/util-linux/issues/2389
ENV.append_to_cflags "-D_XOPEN_SOURCE_EXTENDED" if MacOS.version <= :ventura
args << "--disable-bits" # 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-liblastlog2" # does not build on 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 << "--without-systemd" # Do not install systemd files
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, *std_configure_args
install_args = []
install_args << "LDFLAGS=-lm" if OS.linux?
system "make", "install", *install_args
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)}
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.nobits?(2 ** index) ? "-" : flag)
end
out = shell_output("#{bin}/namei -lx /usr").split("\n").last.split
assert_equal ["d#{perms}", owner, group, "usr"], out
end
end