-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
nss.rb
121 lines (104 loc) 路 4.06 KB
/
nss.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
class Nss < Formula
desc "Libraries for security-enabled client and server applications"
homepage "https://firefox-source-docs.mozilla.org/security/nss/index.html"
url "https://ftp.mozilla.org/pub/security/nss/releases/NSS_3_100_RTM/src/nss-3.100.tar.gz"
sha256 "1e35373ce9cb5b776f678bb341b0625c437520d09ebd91d1abd622e072e38d88"
license "MPL-2.0"
livecheck do
url "https://ftp.mozilla.org/pub/security/nss/releases/"
regex(%r{href=.*?NSS[._-]v?(\d+(?:[._]\d+)+)[._-]RTM/?["' >]}i)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| match.first.tr("_", ".") }
end
end
bottle do
sha256 cellar: :any, arm64_sonoma: "f4bebb70a8e49ac3ce43404b6bbb948b600b2f2819fd5e21faa983422a210e12"
sha256 cellar: :any, arm64_ventura: "e2a738111b6dc4412caf7e43dba40a73cb7c0211d6b22564e933a56dda567bfb"
sha256 cellar: :any, arm64_monterey: "ca7c782399623b3765580641858895ffa62efaef7131a6e4b73f6b6679e8695b"
sha256 cellar: :any, sonoma: "a367e39e4e531241240e51fd7cd4600802aa6a2142559d2b0941b24284bda44e"
sha256 cellar: :any, ventura: "c5e3ac9263befe0cbefb102c01ecd1e8683a59af4dcff9b14300e5ba5e13a27b"
sha256 cellar: :any, monterey: "2c13e6bd11883477b7f9ff20aeadaab4ba860fd7a0471ef28e1603f37db2f465"
sha256 cellar: :any_skip_relocation, x86_64_linux: "a42e5651005afcbb67eecd6a08d1c1b534d8a7131fd066a22ea44077b4c37b15"
end
depends_on "nspr"
uses_from_macos "sqlite"
uses_from_macos "zlib"
conflicts_with "arabica", because: "both install `mangle` binaries"
conflicts_with "resty", because: "both install `pp` binaries"
def install
ENV.deparallelize
cd "nss"
args = %W[
BUILD_OPT=1
NSS_ALLOW_SSLKEYLOGFILE=1
NSS_DISABLE_GTESTS=1
NSS_USE_SYSTEM_SQLITE=1
NSPR_INCLUDE_DIR=#{Formula["nspr"].opt_include}/nspr
NSPR_LIB_DIR=#{Formula["nspr"].opt_lib}
USE_64=1
]
# Remove the broken (for anyone but Firefox) install_name
inreplace "coreconf/Darwin.mk", "-install_name @executable_path", "-install_name #{lib}"
inreplace "lib/freebl/config.mk", "@executable_path", lib
system "make", "all", *args
# We need to use cp here because all files get cross-linked into the dist
# hierarchy, and Homebrew's Pathname.install moves the symlink into the keg
# rather than copying the referenced file.
cd "../dist"
bin.mkpath
os = OS.kernel_name
Dir.glob("#{os}*/bin/*") do |file|
cp file, bin unless file.include? ".dylib"
end
include_target = include + "nss"
include_target.mkpath
Dir.glob("public/{dbm,nss}/*") { |file| cp file, include_target }
lib.mkpath
libexec.mkpath
Dir.glob("#{os}*/lib/*") do |file|
if file.include? ".chk"
cp file, libexec
else
cp file, lib
end
end
# resolves conflict with openssl, see legacy-homebrew#28258
rm lib/"libssl.a"
(bin/"nss-config").write config_file
(lib/"pkgconfig/nss.pc").write pc_file
end
test do
# See: https://developer.mozilla.org/docs/Mozilla/Projects/NSS/tools/NSS_Tools_certutil
(testpath/"passwd").write("It's a secret to everyone.")
system "#{bin}/certutil", "-N", "-d", pwd, "-f", "passwd"
system "#{bin}/certutil", "-L", "-d", pwd
end
# A very minimal nss-config for configuring firefox etc. with this nss,
# see https://bugzil.la/530672 for the progress of upstream inclusion.
def config_file
<<~EOS
#!/bin/sh
for opt; do :; done
case "$opt" in
--version) opt="--modversion";;
--cflags|--libs) ;;
*) exit 1;;
esac
pkg-config "$opt" nss
EOS
end
def pc_file
<<~EOS
prefix=#{prefix}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/nss
Name: NSS
Description: Mozilla Network Security Services
Version: #{version}
Requires: nspr >= 4.12
Libs: -L${libdir} -lnss3 -lnssutil3 -lsmime3 -lssl3
Cflags: -I${includedir}
EOS
end
end