-
Notifications
You must be signed in to change notification settings - Fork 41
/
curl.rb
121 lines (105 loc) · 3.66 KB
/
curl.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
#
# Homebrew Formula for curl + quiche
# Based on https://github.com/Homebrew/homebrew-core/blob/master/Formula/c/curl.rb
#
# brew install -s <url of curl.rb>
#
# You can add --HEAD if you want to build curl from git master.
#
# If you don't want to be auto-upgraded by `brew upgrade`, run
# `brew pin curl`.
#
class Curl < Formula
desc "Get a file from an HTTP, HTTPS or FTP server with HTTP/3 support using quiche"
homepage "https://curl.se"
# Don't forget to update both instances of the version in the GitHub mirror URL.
url "https://curl.se/download/curl-8.11.1.tar.bz2"
mirror "https://github.com/curl/curl/releases/download/curl-8_11_1/curl-8.11.1.tar.bz2"
mirror "http://fresh-center.net/linux/www/curl-8.11.1.tar.bz2"
mirror "http://fresh-center.net/linux/www/legacy/curl-8.11.1.tar.bz2"
sha256 "e9773ad1dfa21aedbfe8e1ef24c9478fa780b1b3d4f763c98dd04629b5e43485"
license "curl"
livecheck do
url "https://curl.se/download/"
regex(/href=.*?curl[._-]v?(.*?)\.t/i)
end
head do
url "https://github.com/curl/curl.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
keg_only :provided_by_macos
depends_on "cmake" => :build
depends_on "pkg-config" => :build
depends_on "rust" => :build
depends_on "brotli"
depends_on "libidn2"
depends_on "libnghttp2"
depends_on "libssh2"
depends_on "openldap"
depends_on "rtmpdump"
depends_on "zstd"
uses_from_macos "krb5"
uses_from_macos "zlib"
resource "quiche" do
url "https://github.com/cloudflare/quiche.git", branch: "master"
end
def install
tag_name = "curl-#{version.to_s.tr(".", "_")}"
if build.stable? && stable.mirrors.grep(/github\.com/).first.exclude?(tag_name)
odie "Tag name #{tag_name} is not found in the GitHub mirror URL! " \
"Please make sure the URL is correct."
end
# Build with quiche:
# https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version
quiche = buildpath/"quiche/quiche"
resource("quiche").stage quiche.parent
cd "quiche" do
# Build static libs only
inreplace "quiche/Cargo.toml", /^crate-type = .*/, "crate-type = [\"staticlib\"]"
system "cargo", "build",
"--release",
"--package=quiche",
"--features=ffi,pkg-config-meta,qlog"
(quiche/"deps/boringssl/src/lib").install Pathname.glob("target/release/build/*/out/build/lib{crypto,ssl}.a")
end
system "./buildconf" if build.head?
args = %W[
--disable-debug
--disable-dependency-tracking
--disable-silent-rules
--prefix=#{prefix}
--with-ssl=#{quiche}/deps/boringssl/src
--without-ca-bundle
--without-ca-path
--with-ca-fallback
--with-default-ssl-backend=openssl
--with-libidn2
--with-librtmp
--with-libssh2
--without-libpsl
--with-quiche=#{quiche.parent}/target/release
--enable-alt-svc
]
args << if OS.mac?
"--with-gssapi"
else
"--with-gssapi=#{Formula["krb5"].opt_prefix}"
end
system "./configure", *args
system "make", "install"
system "make", "install", "-C", "scripts"
libexec.install "scripts/mk-ca-bundle.pl"
end
test do
# Fetch the curl tarball and see that the checksum matches.
# This requires a network connection, but so does Homebrew in general.
filename = (testpath/"test.tar.gz")
system "#{bin}/curl", "-L", stable.url, "-o", filename
filename.verify_checksum stable.checksum
system libexec/"mk-ca-bundle.pl", "test.pem"
assert_predicate testpath/"test.pem", :exist?
assert_predicate testpath/"certdata.txt", :exist?
end
end