Skip to content

Commit d7345fe

Browse files
committed
openssl@3: update 3.3.1 bottle.
1 parent 5658876 commit d7345fe

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

Formula/o/[email protected]

+144
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
class OpensslAT3 < Formula
2+
desc "Cryptography and SSL/TLS Toolkit"
3+
homepage "https://openssl-library.org"
4+
url "https://github.com/openssl/openssl/releases/download/openssl-3.3.1/openssl-3.3.1.tar.gz"
5+
mirror "http://fresh-center.net/linux/misc/openssl-3.3.1.tar.gz"
6+
sha256 "777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e"
7+
license "Apache-2.0"
8+
9+
livecheck do
10+
url "https://openssl-library.org/source/"
11+
regex(/href=.*?openssl[._-]v?(3(?:\.\d+)+)\.t/i)
12+
end
13+
14+
bottle do
15+
root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/[email protected]"
16+
sha256 cellar: :any_skip_relocation, aarch64_linux: "00d531aee0e9b827916bb651185f3ce1ec76c4d0803cb6ad002986ab2412e076"
17+
end
18+
19+
depends_on "ca-certificates"
20+
21+
on_linux do
22+
resource "Test::Harness" do
23+
url "https://cpan.metacpan.org/authors/id/L/LE/LEONT/Test-Harness-3.48.tar.gz"
24+
mirror "http://cpan.metacpan.org/authors/id/L/LE/LEONT/Test-Harness-3.48.tar.gz"
25+
sha256 "e73ff89c81c1a53f6baeef6816841b89d3384403ad97422a7da9d1eeb20ef9c5"
26+
end
27+
28+
resource "Test::More" do
29+
url "https://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.302198.tar.gz"
30+
mirror "http://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.302198.tar.gz"
31+
sha256 "1dc07bcffd23e49983433c948de3e3f377e6e849ad7fe3432c717fa782024faa"
32+
end
33+
34+
resource "ExtUtils::MakeMaker" do
35+
url "https://cpan.metacpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.70.tar.gz"
36+
mirror "http://cpan.metacpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.70.tar.gz"
37+
sha256 "f108bd46420d2f00d242825f865b0f68851084924924f92261d684c49e3e7a74"
38+
end
39+
end
40+
41+
link_overwrite "bin/c_rehash", "bin/openssl", "include/openssl/*"
42+
link_overwrite "lib/libcrypto*", "lib/libssl*"
43+
link_overwrite "lib/pkgconfig/libcrypto.pc", "lib/pkgconfig/libssl.pc", "lib/pkgconfig/openssl.pc"
44+
link_overwrite "share/doc/openssl/*", "share/man/man*/*ssl"
45+
46+
# SSLv2 died with 1.1.0, so no-ssl2 no longer required.
47+
# SSLv3 & zlib are off by default with 1.1.0 but this may not
48+
# be obvious to everyone, so explicitly state it for now to
49+
# help debug inevitable breakage.
50+
def configure_args
51+
args = %W[
52+
--prefix=#{prefix}
53+
--openssldir=#{openssldir}
54+
--libdir=lib
55+
no-ssl3
56+
no-ssl3-method
57+
no-zlib
58+
]
59+
on_linux do
60+
args += (ENV.cflags || "").split
61+
args += (ENV.cppflags || "").split
62+
args += (ENV.ldflags || "").split
63+
end
64+
args
65+
end
66+
67+
def install
68+
if OS.linux?
69+
ENV.prepend_create_path "PERL5LIB", buildpath/"lib/perl5"
70+
ENV.prepend_path "PATH", buildpath/"bin"
71+
72+
%w[ExtUtils::MakeMaker Test::Harness Test::More].each do |r|
73+
resource(r).stage do
74+
system "perl", "Makefile.PL", "INSTALL_BASE=#{buildpath}"
75+
system "make", "PERL5LIB=#{ENV["PERL5LIB"]}", "CC=#{ENV.cc}"
76+
system "make", "install"
77+
end
78+
end
79+
end
80+
81+
# This could interfere with how we expect OpenSSL to build.
82+
ENV.delete("OPENSSL_LOCAL_CONFIG_DIR")
83+
84+
# This ensures where Homebrew's Perl is needed the Cellar path isn't
85+
# hardcoded into OpenSSL's scripts, causing them to break every Perl update.
86+
# Whilst our env points to opt_bin, by default OpenSSL resolves the symlink.
87+
ENV["PERL"] = Formula["perl"].opt_bin/"perl" if which("perl") == Formula["perl"].opt_bin/"perl"
88+
89+
arch_args = []
90+
if OS.mac?
91+
arch_args += %W[darwin64-#{Hardware::CPU.arch}-cc enable-ec_nistp_64_gcc_128]
92+
elsif Hardware::CPU.intel?
93+
arch_args << (Hardware::CPU.is_64_bit? ? "linux-x86_64" : "linux-elf")
94+
elsif Hardware::CPU.arm?
95+
arch_args << (Hardware::CPU.is_64_bit? ? "linux-aarch64" : "linux-armv4")
96+
end
97+
98+
openssldir.mkpath
99+
system "perl", "./Configure", *(configure_args + arch_args)
100+
system "make"
101+
system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl"
102+
# AF_ALG support isn't always enabled (e.g. some containers), which breaks the tests.
103+
# AF_ALG is a kernel feature and failures are unlikely to be issues with the formula.
104+
system "make", "test", "TESTS=-test_afalg"
105+
106+
# Prevent `brew` from pruning the `certs` and `private` directories.
107+
touch %w[certs private].map { |subdir| openssldir/subdir/".keepme" }
108+
end
109+
110+
def openssldir
111+
etc/"openssl@3"
112+
end
113+
114+
def post_install
115+
rm(openssldir/"cert.pem") if (openssldir/"cert.pem").exist?
116+
openssldir.install_symlink Formula["ca-certificates"].pkgetc/"cert.pem"
117+
end
118+
119+
def caveats
120+
<<~EOS
121+
A CA file has been bootstrapped using certificates from the system
122+
keychain. To add additional certificates, place .pem files in
123+
#{openssldir}/certs
124+
125+
and run
126+
#{opt_bin}/c_rehash
127+
EOS
128+
end
129+
130+
test do
131+
# Make sure the necessary .cnf file exists, otherwise OpenSSL gets moody.
132+
assert_predicate pkgetc/"openssl.cnf", :exist?,
133+
"OpenSSL requires the .cnf file for some functionality"
134+
135+
# Check OpenSSL itself functions as expected.
136+
(testpath/"testfile.txt").write("This is a test file")
137+
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249"
138+
system bin/"openssl", "dgst", "-sha256", "-out", "checksum.txt", "testfile.txt"
139+
open("checksum.txt") do |f|
140+
checksum = f.read(100).split("=").last.strip
141+
assert_equal checksum, expected_checksum
142+
end
143+
end
144+
end

0 commit comments

Comments
 (0)