|
| 1 | +##### |
| 2 | +# Component release information: |
| 3 | +# https://github.com/openssl/openssl/releases |
| 4 | +# 3.5 isn't latest openssl, but latest LTS: https://openssl-library.org/policies/releasestrat/index.html |
| 5 | +##### |
| 6 | +component 'openssl' do |pkg, settings, platform| |
| 7 | + pkg.version '3.5.5' |
| 8 | + pkg.sha256sum 'b28c91532a8b65a1f983b4c28b7488174e4a01008e29ce8e69bd789f28bc2a89' |
| 9 | + pkg.url "https://github.com/openssl/openssl/releases/download/openssl-#{pkg.get_version}/openssl-#{pkg.get_version}.tar.gz" |
| 10 | + pkg.mirror "#{settings[:buildsources_url]}/openssl-#{pkg.get_version}.tar.gz" |
| 11 | + |
| 12 | + ############################# |
| 13 | + # ENVIRONMENT, FLAGS, TARGETS |
| 14 | + ############################# |
| 15 | + |
| 16 | + if platform.name =~ /^(amazon-|el-|redhat-|redhatfips-|fedora-)/ |
| 17 | + pkg.build_requires 'perl-core' |
| 18 | + elsif platform.is_solaris? |
| 19 | + # perl is installed in platform definition |
| 20 | + else |
| 21 | + pkg.build_requires 'perl' |
| 22 | + end |
| 23 | + |
| 24 | + target = sslflags = '' |
| 25 | + cflags = settings[:cflags] |
| 26 | + ldflags = settings[:ldflags] |
| 27 | + |
| 28 | + if platform.is_windows? |
| 29 | + pkg.environment 'PATH', "$(shell cygpath -u #{settings[:gcc_bindir]}):$(PATH)" |
| 30 | + pkg.environment 'CYGWIN', settings[:cygwin] |
| 31 | + pkg.environment 'MAKE', platform[:make] |
| 32 | + |
| 33 | + target = platform.architecture == 'x64' ? 'mingw64' : 'mingw' |
| 34 | + elsif platform.is_aix? |
| 35 | + # REMIND: why not PATH? |
| 36 | + pkg.environment 'CC', '/opt/freeware/bin/gcc' |
| 37 | + |
| 38 | + cflags = "#{settings[:cflags]} -static-libgcc" |
| 39 | + # see https://github.com/openssl/openssl/issues/18007 about -latomic |
| 40 | + # see https://www.ibm.com/docs/en/aix/7.2?topic=l-ld-command about -R<path>, which is equivalent to -rpath |
| 41 | + ldflags = "#{settings[:ldflags]} -Wl,-R#{settings[:libdir]} -latomic -lm" |
| 42 | + target = 'aix-gcc' |
| 43 | + elsif platform.is_solaris? |
| 44 | + pkg.environment 'PATH', '/opt/csw/bin:$(PATH):/usr/local/bin:/usr/ccs/bin:/usr/sfw/bin' |
| 45 | + if !platform.is_cross_compiled? && platform.architecture == 'sparc' |
| 46 | + pkg.environment 'CC', '/opt/pl-build-tools/bin/gcc' |
| 47 | + gcc_lib = "/opt/pl-build-tools/#{settings[:platform_triple]}/lib" |
| 48 | + else |
| 49 | + pkg.environment 'CC', '/opt/csw/bin/gcc' |
| 50 | + gcc_lib = "/opt/csw/#{settings[:platform_triple]}/lib" |
| 51 | + end |
| 52 | + cflags = "#{settings[:cflags]} -fPIC" |
| 53 | + ldflags = "-R#{gcc_lib} -Wl,-rpath=#{settings[:libdir]} -L#{gcc_lib}" |
| 54 | + target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc' |
| 55 | + elsif platform.is_macos? |
| 56 | + pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin:/usr/local/bin' |
| 57 | + pkg.environment 'CFLAGS', settings[:cflags] |
| 58 | + pkg.environment 'CC', settings[:cc] |
| 59 | + pkg.environment 'MACOSX_DEPLOYMENT_TARGET', settings[:deployment_target] |
| 60 | + |
| 61 | + target = if platform.architecture == 'arm64' |
| 62 | + 'darwin64-arm64' |
| 63 | + else |
| 64 | + 'darwin64-x86_64' |
| 65 | + end |
| 66 | + elsif platform.is_linux? |
| 67 | + pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin' |
| 68 | + |
| 69 | + ldflags = "#{settings[:ldflags]} -Wl,-z,relro" |
| 70 | + case platform.architecture |
| 71 | + when /86$/ |
| 72 | + target = 'linux-elf' |
| 73 | + sslflags = '386' |
| 74 | + when /aarch64$/ |
| 75 | + target = 'linux-aarch64' |
| 76 | + when /ppc64le|ppc64el/ # Little-endian |
| 77 | + target = 'linux-ppc64le' |
| 78 | + when /64$/ |
| 79 | + target = 'linux-x86_64' |
| 80 | + when 'armhf' |
| 81 | + target = 'linux-armv4' |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + #################### |
| 86 | + # BUILD REQUIREMENTS |
| 87 | + #################### |
| 88 | + |
| 89 | + pkg.build_requires "runtime-#{settings[:runtime_project]}" |
| 90 | + |
| 91 | + ########### |
| 92 | + # CONFIGURE |
| 93 | + ########### |
| 94 | + |
| 95 | + # Defining --libdir ensures that we avoid the multilib (lib/ vs. lib64/) problem, |
| 96 | + # since configure uses the existence of a lib64 directory to determine |
| 97 | + # if it should install its own libs into a multilib dir. Yay OpenSSL! |
| 98 | + configure_flags = [ |
| 99 | + "--prefix=#{settings[:prefix]}", |
| 100 | + '--libdir=lib', |
| 101 | + "--openssldir=#{settings[:prefix]}/ssl", |
| 102 | + 'shared', |
| 103 | + 'no-gost', |
| 104 | + target, |
| 105 | + sslflags, |
| 106 | + 'no-camellia', |
| 107 | + 'no-md2', |
| 108 | + 'no-ssl3', |
| 109 | + 'no-ssl3-method', |
| 110 | + 'no-dtls1-method', |
| 111 | + 'no-dtls1_2-method', |
| 112 | + 'no-aria', |
| 113 | + # 'no-bf', pgcrypto is requires this cipher in postgres for puppetdb |
| 114 | + # 'no-cast', pgcrypto is requires this cipher in postgres for puppetdb |
| 115 | + # 'no-des', pgcrypto is requires this cipher in postgres for puppetdb, |
| 116 | + # should pgcrypto cease needing it, it will also be needed by ntlm |
| 117 | + # and should only be enabled if "use_legacy_openssl_algos" is true. |
| 118 | + 'no-rc5', |
| 119 | + 'no-mdc2', |
| 120 | + # 'no-rmd160', this is causing failures with pxp, remove once pxp-agent does not need it |
| 121 | + 'no-whirlpool' |
| 122 | + ] |
| 123 | + |
| 124 | + if settings[:use_legacy_openssl_algos] |
| 125 | + pkg.apply_patch 'resources/patches/openssl/openssl-3-activate-legacy-algos.patch' |
| 126 | + else |
| 127 | + configure_flags << 'no-legacy' << 'no-md4' |
| 128 | + end |
| 129 | + |
| 130 | + # Individual projects may provide their own openssl configure flags: |
| 131 | + project_flags = settings[:openssl_extra_configure_flags] || [] |
| 132 | + perl_exec = '' |
| 133 | + perl_exec = '/opt/freeware/bin/perl' if platform.is_aix? |
| 134 | + configure_flags << project_flags |
| 135 | + |
| 136 | + pkg.environment 'CFLAGS', cflags |
| 137 | + pkg.environment 'LDFLAGS', ldflags |
| 138 | + pkg.configure do |
| 139 | + ["#{perl_exec} ./Configure #{configure_flags.join(' ')}"] |
| 140 | + end |
| 141 | + |
| 142 | + ####### |
| 143 | + # BUILD |
| 144 | + ####### |
| 145 | + |
| 146 | + build_commands = [] |
| 147 | + |
| 148 | + if platform.is_windows? && platform.architecture == 'x86' |
| 149 | + # mingw-w32 5.2.0 has a bug in include/winnt.h that declares GetCurrentFiber |
| 150 | + # with __CRT_INLINE, which results in the function not being inlined and |
| 151 | + # generates a linker error: undefined reference to `GetCurrentFiber'. |
| 152 | + # This only affects 32-bit builds |
| 153 | + # See https://github.com/openssl/openssl/issues/513 |
| 154 | + # See https://github.com/mingw-w64/mingw-w64/commit/8da1aae7a7ff5bf996878dc8fe30a0e01e210e5a |
| 155 | + pkg.add_source('file://resources/patches/windows/FORCEINLINE-i686-w64-mingw32-winnt.h') |
| 156 | + build_commands << "#{platform.patch} --dir #{settings[:gcc_root]}/#{settings[:platform_triple]} --strip=2 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../FORCEINLINE-i686-w64-mingw32-winnt.h" |
| 157 | + end |
| 158 | + |
| 159 | + build_commands << "#{platform[:make]} depend" |
| 160 | + build_commands << platform[:make] |
| 161 | + |
| 162 | + pkg.build do |
| 163 | + build_commands |
| 164 | + end |
| 165 | + |
| 166 | + ######### |
| 167 | + # INSTALL |
| 168 | + ######### |
| 169 | + |
| 170 | + install_prefix = platform.is_windows? ? '' : 'INSTALL_PREFIX=/' |
| 171 | + install_commands = [] |
| 172 | + |
| 173 | + if platform.is_aix? |
| 174 | + # "Removes any currently unused modules in kernel and library memory." |
| 175 | + install_commands << 'slibclean' |
| 176 | + end |
| 177 | + |
| 178 | + # Skip man and html docs |
| 179 | + install_commands << "#{platform[:make]} #{install_prefix} install_sw install_ssldirs" |
| 180 | + install_commands << "rm -f #{settings[:prefix]}/bin/c_rehash" |
| 181 | + |
| 182 | + pkg.install do |
| 183 | + install_commands |
| 184 | + end |
| 185 | + |
| 186 | + pkg.install_file 'LICENSE.txt', "#{settings[:prefix]}/share/doc/openssl-#{pkg.get_version}/LICENSE" |
| 187 | +end |
0 commit comments