130 lines
3.7 KiB
Ruby
130 lines
3.7 KiB
Ruby
require 'formula'
|
|
|
|
class Openssl < Formula
|
|
homepage 'http://openssl.org'
|
|
url 'https://www.openssl.org/source/openssl-1.0.1i.tar.gz'
|
|
mirror 'http://www.mirrorservice.org/sites/ftp.openssl.org/source/openssl-1.0.1i.tar.gz'
|
|
sha256 '3c179f46ca77069a6a0bac70212a9b3b838b2f66129cb52d568837fc79d8fcc7'
|
|
|
|
bottle do
|
|
sha1 "601d7e8ec3c031bc74f577be840a31030000999e" => :mavericks
|
|
sha1 "6d387d9ca1d3ca3a3e1e8ff070b695ef38c9fee6" => :mountain_lion
|
|
sha1 "250bbc9ec053ca94e7fd83d9e21b6ae9d2b75f68" => :lion
|
|
end
|
|
|
|
option :universal
|
|
option "without-check", "Skip build-time tests (not recommended)"
|
|
|
|
depends_on "makedepend" => :build
|
|
|
|
keg_only :provided_by_osx,
|
|
"The OpenSSL provided by OS X is too old for some software."
|
|
|
|
def arch_args
|
|
{
|
|
:x86_64 => %w[darwin64-x86_64-cc enable-ec_nistp_64_gcc_128],
|
|
:i386 => %w[darwin-i386-cc],
|
|
}
|
|
end
|
|
|
|
def configure_args; %W[
|
|
--prefix=#{prefix}
|
|
--openssldir=#{openssldir}
|
|
zlib-dynamic
|
|
shared
|
|
enable-cms
|
|
]
|
|
end
|
|
|
|
def install
|
|
if build.universal?
|
|
ENV.permit_arch_flags
|
|
archs = Hardware::CPU.universal_archs
|
|
elsif MacOS.prefer_64_bit?
|
|
archs = [Hardware::CPU.arch_64_bit]
|
|
else
|
|
archs = [Hardware::CPU.arch_32_bit]
|
|
end
|
|
|
|
dirs = []
|
|
|
|
archs.each do |arch|
|
|
if build.universal?
|
|
dir = "build-#{arch}"
|
|
dirs << dir
|
|
mkdir dir
|
|
mkdir "#{dir}/engines"
|
|
system "make", "clean"
|
|
end
|
|
|
|
ENV.deparallelize
|
|
system "perl", "./Configure", *(configure_args + arch_args[arch])
|
|
system "make", "depend"
|
|
system "make"
|
|
system "make", "test" if build.with? "check"
|
|
|
|
if build.universal?
|
|
cp Dir["*.?.?.?.dylib", "*.a", "apps/openssl"], dir
|
|
cp Dir["engines/**/*.dylib"], "#{dir}/engines"
|
|
end
|
|
end
|
|
|
|
system "make", "install", "MANDIR=#{man}", "MANSUFFIX=ssl"
|
|
|
|
if build.universal?
|
|
%w[libcrypto libssl].each do |libname|
|
|
system "lipo", "-create", "#{dirs.first}/#{libname}.1.0.0.dylib",
|
|
"#{dirs.last}/#{libname}.1.0.0.dylib",
|
|
"-output", "#{lib}/#{libname}.1.0.0.dylib"
|
|
system "lipo", "-create", "#{dirs.first}/#{libname}.a",
|
|
"#{dirs.last}/#{libname}.a",
|
|
"-output", "#{lib}/#{libname}.a"
|
|
end
|
|
|
|
Dir.glob("#{dirs.first}/engines/*.dylib") do |engine|
|
|
libname = File.basename(engine)
|
|
system "lipo", "-create", "#{dirs.first}/engines/#{libname}",
|
|
"#{dirs.last}/engines/#{libname}",
|
|
"-output", "#{lib}/engines/#{libname}"
|
|
end
|
|
|
|
system "lipo", "-create", "#{dirs.first}/openssl",
|
|
"#{dirs.last}/openssl",
|
|
"-output", "#{bin}/openssl"
|
|
end
|
|
end
|
|
|
|
def openssldir
|
|
etc/"openssl"
|
|
end
|
|
|
|
def post_install
|
|
keychains = %w[
|
|
/Library/Keychains/System.keychain
|
|
/System/Library/Keychains/SystemRootCertificates.keychain
|
|
]
|
|
|
|
openssldir.mkpath
|
|
(openssldir/"cert.pem").atomic_write `security find-certificate -a -p #{keychains.join(" ")}`
|
|
end
|
|
|
|
def caveats; <<-EOS.undent
|
|
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
|
|
(testpath/'testfile.txt').write("This is a test file")
|
|
expected_checksum = "91b7b0b1e27bfbf7bc646946f35fa972c47c2d32"
|
|
system "#{bin}/openssl", 'dgst', '-sha1', '-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
|