From 56588761f96b156c236df6bb9dfb441ab5a90fc2 Mon Sep 17 00:00:00 2001 From: Adrian Ho Date: Wed, 4 Sep 2024 17:24:57 +0800 Subject: [PATCH] openssl@1.1: update 1.1.1w bottle. --- Formula/o/openssl@1.1.rb | 141 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 Formula/o/openssl@1.1.rb diff --git a/Formula/o/openssl@1.1.rb b/Formula/o/openssl@1.1.rb new file mode 100644 index 00000000000..215eaeaadb0 --- /dev/null +++ b/Formula/o/openssl@1.1.rb @@ -0,0 +1,141 @@ +class OpensslAT11 < Formula + desc "Cryptography and SSL/TLS Toolkit" + homepage "https://openssl.org/" + url "https://www.openssl.org/source/openssl-1.1.1w.tar.gz" + mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1.1.1w.tar.gz" + mirror "http://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1.1.1w.tar.gz" + mirror "https://www.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz" + mirror "https://www.mirrorservice.org/sites/ftp.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz" + mirror "http://www.mirrorservice.org/sites/ftp.openssl.org/source/old/1.1.1/openssl-1.1.1w.tar.gz" + sha256 "cf3098950cb4d853ad95c0841f1f9c6d3dc102dccfcacd521d93925208b76ac8" + license "OpenSSL" + version_scheme 1 + + bottle do + root_url "https://github.com/gromgit/homebrew-core-aarch64_linux/releases/download/openssl@1.1-1.1.1w" + sha256 cellar: :any_skip_relocation, aarch64_linux: "cebceeba43796d38e73d1cd6f1e6b9e230bb0f50da0b5a88a8428b02b07e053c" + end + + keg_only :versioned_formula + + # See: https://www.openssl.org/policies/releasestrat.html + deprecate! date: "2023-10-24", because: :unsupported + + depends_on "ca-certificates" + + on_linux do + resource "Test::Harness" do + url "https://cpan.metacpan.org/authors/id/L/LE/LEONT/Test-Harness-3.44.tar.gz" + mirror "http://cpan.metacpan.org/authors/id/L/LE/LEONT/Test-Harness-3.44.tar.gz" + sha256 "7eb591ea6b499ece6745ff3e80e60cee669f0037f9ccbc4e4511425f593e5297" + end + + resource "Test::More" do + url "https://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.302195.tar.gz" + mirror "http://cpan.metacpan.org/authors/id/E/EX/EXODIST/Test-Simple-1.302195.tar.gz" + sha256 "b390bb23592e0b946c95adbb3c30b11bc634a286b2847be611ad929c57e39a6c" + end + + resource "ExtUtils::MakeMaker" do + url "https://cpan.metacpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.70.tar.gz" + mirror "http://cpan.metacpan.org/authors/id/B/BI/BINGOS/ExtUtils-MakeMaker-7.70.tar.gz" + sha256 "f108bd46420d2f00d242825f865b0f68851084924924f92261d684c49e3e7a74" + end + end + + # SSLv2 died with 1.1.0, so no-ssl2 no longer required. + # SSLv3 & zlib are off by default with 1.1.0 but this may not + # be obvious to everyone, so explicitly state it for now to + # help debug inevitable breakage. + def configure_args + args = %W[ + --prefix=#{prefix} + --openssldir=#{openssldir} + no-ssl3 + no-ssl3-method + no-zlib + ] + on_linux do + args += (ENV.cflags || "").split + args += (ENV.cppflags || "").split + args += (ENV.ldflags || "").split + args << "enable-md2" + end + args + end + + def install + if OS.linux? + ENV.prepend_create_path "PERL5LIB", buildpath/"lib/perl5" + ENV.prepend_path "PATH", buildpath/"bin" + + %w[ExtUtils::MakeMaker Test::Harness Test::More].each do |r| + resource(r).stage do + system "perl", "Makefile.PL", "INSTALL_BASE=#{buildpath}" + system "make", "PERL5LIB=#{ENV["PERL5LIB"]}", "CC=#{ENV.cc}" + system "make", "install" + end + end + end + + # This could interfere with how we expect OpenSSL to build. + ENV.delete("OPENSSL_LOCAL_CONFIG_DIR") + + # This ensures where Homebrew's Perl is needed the Cellar path isn't + # hardcoded into OpenSSL's scripts, causing them to break every Perl update. + # Whilst our env points to opt_bin, by default OpenSSL resolves the symlink. + ENV["PERL"] = Formula["perl"].opt_bin/"perl" if which("perl") == Formula["perl"].opt_bin/"perl" + + arch_args = [] + if OS.mac? + arch_args += %W[darwin64-#{Hardware::CPU.arch}-cc enable-ec_nistp_64_gcc_128] + elsif Hardware::CPU.intel? + arch_args << (Hardware::CPU.is_64_bit? ? "linux-x86_64" : "linux-elf") + elsif Hardware::CPU.arm? + arch_args << (Hardware::CPU.is_64_bit? ? "linux-aarch64" : "linux-armv4") + end + + system "perl", "./Configure", *(configure_args + arch_args) + system "make" + system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl" + system "make", "test" + + # Prevent `brew` from pruning the `certs` and `private` directories. + touch %w[certs private].map { |subdir| openssldir/subdir/".keepme" } + end + + def openssldir + etc/"openssl@1.1" + end + + def post_install + rm(openssldir/"cert.pem") if (openssldir/"cert.pem").exist? + openssldir.install_symlink Formula["ca-certificates"].pkgetc/"cert.pem" + end + + def caveats + <<~EOS + A CA file has been bootstrapped using certificates from the system + keychain. To add additional certificates, place .pem files in + #{openssldir}/certs + + and run + #{opt_bin}/c_rehash + EOS + end + + test do + # Make sure the necessary .cnf file exists, otherwise OpenSSL gets moody. + assert_predicate pkgetc/"openssl.cnf", :exist?, + "OpenSSL requires the .cnf file for some functionality" + + # Check OpenSSL itself functions as expected. + (testpath/"testfile.txt").write("This is a test file") + expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249" + system bin/"openssl", "dgst", "-sha256", "-out", "checksum.txt", "testfile.txt" + open("checksum.txt") do |f| + checksum = f.read(100).split("=").last.strip + assert_equal checksum, expected_checksum + end + end +end