Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | SUMMARY = "Secure Socket Layer" |
| 2 | DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools." |
| 3 | HOMEPAGE = "http://www.openssl.org/" |
| 4 | BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html" |
| 5 | SECTION = "libs/network" |
| 6 | |
| 7 | # "openssl | SSLeay" dual license |
| 8 | LICENSE = "openssl" |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 9 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f475368924827d06d4b416111c8bdb77" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 10 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 11 | DEPENDS = "hostperl-runtime-native" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 12 | DEPENDS_append_class-target = " openssl-native" |
| 13 | |
| 14 | PROVIDES += "openssl10" |
| 15 | |
| 16 | SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 17 | file://run-ptest \ |
| 18 | file://openssl-c_rehash.sh \ |
| 19 | file://configure-targets.patch \ |
| 20 | file://shared-libs.patch \ |
| 21 | file://oe-ldflags.patch \ |
| 22 | file://engines-install-in-libdir-ssl.patch \ |
| 23 | file://debian1.0.2/block_diginotar.patch \ |
| 24 | file://debian1.0.2/block_digicert_malaysia.patch \ |
| 25 | file://debian/c_rehash-compat.patch \ |
| 26 | file://debian/debian-targets.patch \ |
| 27 | file://debian/man-dir.patch \ |
| 28 | file://debian/man-section.patch \ |
| 29 | file://debian/no-rpath.patch \ |
| 30 | file://debian/no-symbolic.patch \ |
| 31 | file://debian/pic.patch \ |
| 32 | file://debian1.0.2/version-script.patch \ |
| 33 | file://debian1.0.2/soname.patch \ |
| 34 | file://openssl_fix_for_x32.patch \ |
| 35 | file://openssl-fix-des.pod-error.patch \ |
| 36 | file://Makefiles-ptest.patch \ |
| 37 | file://ptest-deps.patch \ |
| 38 | file://ptest_makefile_deps.patch \ |
| 39 | file://configure-musl-target.patch \ |
| 40 | file://parallel.patch \ |
| 41 | file://Use-SHA256-not-MD5-as-default-digest.patch \ |
| 42 | file://0001-Fix-build-with-clang-using-external-assembler.patch \ |
| 43 | file://0001-openssl-force-soft-link-to-avoid-rare-race.patch \ |
| 44 | file://0001-allow-manpages-to-be-disabled.patch \ |
| 45 | " |
| 46 | |
| 47 | SRC_URI_append_class-target = " \ |
| 48 | file://reproducible-cflags.patch \ |
| 49 | file://reproducible-mkbuildinf.patch \ |
| 50 | " |
| 51 | |
| 52 | SRC_URI_append_class-nativesdk = " \ |
| 53 | file://environment.d-openssl.sh \ |
| 54 | " |
| 55 | |
| 56 | SRC_URI[md5sum] = "ac5eb30bf5798aa14b1ae6d0e7da58df" |
| 57 | SRC_URI[sha256sum] = "50a98e07b1a89eb8f6a99477f262df71c6fa7bef77df4dc83025a2845c827d00" |
| 58 | |
| 59 | UPSTREAM_CHECK_REGEX = "openssl-(?P<pver>1\.0.+)\.tar" |
| 60 | |
| 61 | inherit pkgconfig siteinfo multilib_header ptest relative_symlinks manpages |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 62 | |
| 63 | PACKAGECONFIG ?= "cryptodev-linux" |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 64 | PACKAGECONFIG_class-native = "" |
| 65 | PACKAGECONFIG_class-nativesdk = "" |
| 66 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 67 | PACKAGECONFIG[cryptodev-linux] = "-DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS,,cryptodev-linux" |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 68 | PACKAGECONFIG[manpages] = ",,," |
| 69 | PACKAGECONFIG[perl] = ",,," |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 70 | |
| 71 | # Remove this to enable SSLv3. SSLv3 is defaulted to disabled due to the POODLE |
| 72 | # vulnerability |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 73 | EXTRA_OECONF = "no-ssl3" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 74 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 75 | EXTRA_OEMAKE = "${@bb.utils.contains('PACKAGECONFIG', 'manpages', '', 'OE_DISABLE_MANPAGES=1', d)}" |
| 76 | |
| 77 | export OE_LDFLAGS = "${LDFLAGS}" |
| 78 | |
| 79 | # openssl fails with ccache: https://bugzilla.yoctoproject.org/show_bug.cgi?id=12810 |
| 80 | CCACHE = "" |
| 81 | |
| 82 | TERMIO ?= "-DTERMIO" |
| 83 | TERMIO_libc-musl = "-DTERMIOS" |
| 84 | |
| 85 | CFLAG = "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', '-DL_ENDIAN', '-DB_ENDIAN', d)} \ |
| 86 | ${TERMIO} ${CFLAGS} -Wall" |
| 87 | |
| 88 | # Avoid binaries being marked as requiring an executable stack since they don't |
| 89 | # (and it causes issues with SELinux) |
| 90 | CFLAG += "-Wa,--noexecstack" |
| 91 | |
| 92 | CFLAG_append_class-native = " -fPIC" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 93 | |
| 94 | do_configure () { |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 95 | # The crypto_use_bigint patch means that perl's bignum module needs to be |
| 96 | # installed, but some distributions (for example Fedora 23) don't ship it by |
| 97 | # default. As the resulting error is very misleading check for bignum before |
| 98 | # building. |
| 99 | if ! perl -Mbigint -e true; then |
| 100 | bbfatal "The perl module 'bignum' was not found but this is required to build openssl. Please install this module (often packaged as perl-bignum) and re-run bitbake." |
| 101 | fi |
| 102 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 103 | ln -sf apps/openssl.pod crypto/crypto.pod ssl/ssl.pod doc/ |
| 104 | |
| 105 | os=${HOST_OS} |
| 106 | case $os in |
| 107 | linux-gnueabi |\ |
| 108 | linux-gnuspe |\ |
| 109 | linux-musleabi |\ |
| 110 | linux-muslspe |\ |
| 111 | linux-musl ) |
| 112 | os=linux |
| 113 | ;; |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 114 | *) |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 115 | ;; |
| 116 | esac |
| 117 | target="$os-${HOST_ARCH}" |
| 118 | case $target in |
| 119 | linux-arm) |
| 120 | target=linux-armv4 |
| 121 | ;; |
| 122 | linux-armeb) |
| 123 | target=linux-elf-armeb |
| 124 | ;; |
| 125 | linux-aarch64*) |
| 126 | target=linux-aarch64 |
| 127 | ;; |
| 128 | linux-sh3) |
| 129 | target=debian-sh3 |
| 130 | ;; |
| 131 | linux-sh4) |
| 132 | target=debian-sh4 |
| 133 | ;; |
| 134 | linux-i486) |
| 135 | target=debian-i386-i486 |
| 136 | ;; |
| 137 | linux-i586 | linux-viac3) |
| 138 | target=debian-i386-i586 |
| 139 | ;; |
| 140 | linux-i686) |
| 141 | target=debian-i386-i686/cmov |
| 142 | ;; |
| 143 | linux-gnux32-x86_64 | linux-muslx32-x86_64 ) |
| 144 | target=linux-x32 |
| 145 | ;; |
| 146 | linux-gnu64-x86_64) |
| 147 | target=linux-x86_64 |
| 148 | ;; |
| 149 | linux-gnun32-mips*el) |
| 150 | target=debian-mipsn32el |
| 151 | ;; |
| 152 | linux-gnun32-mips*) |
| 153 | target=debian-mipsn32 |
| 154 | ;; |
| 155 | linux-mips*64*el) |
| 156 | target=debian-mips64el |
| 157 | ;; |
| 158 | linux-mips*64*) |
| 159 | target=debian-mips64 |
| 160 | ;; |
| 161 | linux-mips*el) |
| 162 | target=debian-mipsel |
| 163 | ;; |
| 164 | linux-mips*) |
| 165 | target=debian-mips |
| 166 | ;; |
| 167 | linux-microblaze*|linux-nios2*|linux-gnu*ilp32**) |
| 168 | target=linux-generic32 |
| 169 | ;; |
| 170 | linux-powerpc) |
| 171 | target=linux-ppc |
| 172 | ;; |
| 173 | linux-powerpc64) |
| 174 | target=linux-ppc64 |
| 175 | ;; |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 176 | linux-riscv32) |
| 177 | target=linux-generic32 |
| 178 | ;; |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 179 | linux-riscv64) |
| 180 | target=linux-generic64 |
| 181 | ;; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 182 | linux-supersparc) |
| 183 | target=linux-sparcv8 |
| 184 | ;; |
| 185 | linux-sparc) |
| 186 | target=linux-sparcv8 |
| 187 | ;; |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 188 | esac |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 189 | |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 190 | # inject machine-specific flags |
| 191 | sed -i -e "s|^\(\"$target\",\s*\"[^:]\+\):\([^:]\+\)|\1:${CFLAG}|g" Configure |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 192 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 193 | useprefix=${prefix} |
| 194 | if [ "x$useprefix" = "x" ]; then |
| 195 | useprefix=/ |
| 196 | fi |
| 197 | libdirleaf="$(echo ${libdir} | sed s:$useprefix::)" |
| 198 | perl ./Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} shared --prefix=$useprefix --openssldir=${libdir}/ssl --libdir=$libdirleaf $target |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | do_compile () { |
| 202 | oe_runmake depend |
| 203 | oe_runmake |
| 204 | } |
| 205 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 206 | do_compile_class-target () { |
| 207 | sed -i 's/\((OPENSSL=\)".*"/\1"openssl"/' Makefile |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 208 | oe_runmake depend |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 209 | cc_sanitized=$(echo "${CC} ${CFLAG}" | sed -e 's,--sysroot=${STAGING_DIR_TARGET},,g' -e 's|${DEBUG_PREFIX_MAP}||g' -e 's/[ \t]\+/ /g') |
| 210 | oe_runmake CC_INFO="$cc_sanitized" |
| 211 | } |
| 212 | |
| 213 | do_compile_ptest () { |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 214 | oe_runmake buildtest |
| 215 | } |
| 216 | |
| 217 | do_install () { |
| 218 | # Create ${D}/${prefix} to fix parallel issues |
| 219 | mkdir -p ${D}/${prefix}/ |
| 220 | |
| 221 | oe_runmake INSTALL_PREFIX="${D}" MANDIR="${mandir}" install |
| 222 | |
| 223 | oe_libinstall -so libcrypto ${D}${libdir} |
| 224 | oe_libinstall -so libssl ${D}${libdir} |
| 225 | |
| 226 | install -d ${D}${includedir} |
| 227 | cp --dereference -R include/openssl ${D}${includedir} |
| 228 | |
| 229 | install -Dm 0755 ${WORKDIR}/openssl-c_rehash.sh ${D}${bindir}/c_rehash |
| 230 | sed -i -e 's,/etc/openssl,${sysconfdir}/ssl,g' ${D}${bindir}/c_rehash |
| 231 | |
| 232 | oe_multilib_header openssl/opensslconf.h |
| 233 | if [ "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" ]; then |
| 234 | sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/CA.pl |
| 235 | sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/tsget |
| 236 | else |
| 237 | rm -f ${D}${libdir}/ssl/misc/CA.pl ${D}${libdir}/ssl/misc/tsget |
| 238 | fi |
| 239 | |
| 240 | # Create SSL structure |
| 241 | install -d ${D}${sysconfdir}/ssl/ |
| 242 | mv ${D}${libdir}/ssl/openssl.cnf \ |
| 243 | ${D}${libdir}/ssl/certs \ |
| 244 | ${D}${libdir}/ssl/private \ |
| 245 | \ |
| 246 | ${D}${sysconfdir}/ssl/ |
| 247 | ln -sf ${sysconfdir}/ssl/certs ${D}${libdir}/ssl/certs |
| 248 | ln -sf ${sysconfdir}/ssl/private ${D}${libdir}/ssl/private |
| 249 | ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${libdir}/ssl/openssl.cnf |
| 250 | |
| 251 | # Rename man pages to prefix openssl10-* |
| 252 | for f in `find ${D}${mandir} -type f`; do |
| 253 | mv $f $(dirname $f)/openssl10-$(basename $f) |
| 254 | done |
| 255 | for f in `find ${D}${mandir} -type l`; do |
| 256 | ln_f=`readlink $f` |
| 257 | rm -f $f |
| 258 | ln -s openssl10-$ln_f $(dirname $f)/openssl10-$(basename $f) |
| 259 | done |
| 260 | } |
| 261 | |
| 262 | do_install_ptest () { |
| 263 | cp -r -L Makefile.org Makefile test ${D}${PTEST_PATH} |
| 264 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 265 | # Replace the path to native perl with the path to target perl |
| 266 | sed -i 's,^PERL=.*,PERL=${bindir}/perl,' ${D}${PTEST_PATH}/Makefile |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 267 | |
| 268 | cp Configure config e_os.h ${D}${PTEST_PATH} |
| 269 | cp -r -L include ${D}${PTEST_PATH} |
| 270 | ln -sf ${libdir}/libcrypto.a ${D}${PTEST_PATH} |
| 271 | ln -sf ${libdir}/libssl.a ${D}${PTEST_PATH} |
| 272 | mkdir -p ${D}${PTEST_PATH}/crypto |
| 273 | cp crypto/constant_time_locl.h ${D}${PTEST_PATH}/crypto |
| 274 | cp -r certs ${D}${PTEST_PATH} |
| 275 | mkdir -p ${D}${PTEST_PATH}/apps |
| 276 | ln -sf ${libdir}/ssl/misc/CA.sh ${D}${PTEST_PATH}/apps |
| 277 | ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${PTEST_PATH}/apps |
| 278 | ln -sf ${bindir}/openssl ${D}${PTEST_PATH}/apps |
| 279 | cp apps/server.pem ${D}${PTEST_PATH}/apps |
| 280 | cp apps/server2.pem ${D}${PTEST_PATH}/apps |
| 281 | mkdir -p ${D}${PTEST_PATH}/util |
| 282 | install util/opensslwrap.sh ${D}${PTEST_PATH}/util |
| 283 | install util/shlib_wrap.sh ${D}${PTEST_PATH}/util |
| 284 | # Time stamps are relevant for "make alltests", otherwise |
| 285 | # make may try to recompile binaries. Not only must the |
| 286 | # binary files be newer than the sources, they also must |
| 287 | # be more recent than the header files in /usr/include. |
| 288 | # |
| 289 | # Using "cp -a" is not sufficient, because do_install |
| 290 | # does not preserve the original time stamps. |
| 291 | # |
| 292 | # So instead of using the original file stamps, we set |
| 293 | # the current time for all files. Binaries will get |
| 294 | # modified again later when stripping them, but that's okay. |
| 295 | touch ${D}${PTEST_PATH} |
| 296 | find ${D}${PTEST_PATH} -type f -print0 | xargs --verbose -0 touch -r ${D}${PTEST_PATH} |
| 297 | |
| 298 | # exclude binary files or the package won't install |
| 299 | for d in ssltest_old v3ext x509aux; do |
| 300 | rm -rf ${D}${libdir}/${BPN}/ptest/test/$d |
| 301 | done |
| 302 | |
| 303 | # Remove build host references |
| 304 | sed -i \ |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 305 | -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \ |
| 306 | -e 's|${DEBUG_PREFIX_MAP}||g' \ |
| 307 | ${D}${PTEST_PATH}/Makefile ${D}${PTEST_PATH}/Configure |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | do_install_append_class-native() { |
| 311 | create_wrapper ${D}${bindir}/openssl \ |
| 312 | OPENSSL_CONF=${libdir}/ssl/openssl.cnf \ |
| 313 | SSL_CERT_DIR=${libdir}/ssl/certs \ |
| 314 | SSL_CERT_FILE=${libdir}/ssl/cert.pem \ |
| 315 | OPENSSL_ENGINES=${libdir}/ssl/engines |
| 316 | } |
| 317 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 318 | do_install_append_class-nativesdk() { |
| 319 | mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d |
| 320 | install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh |
| 321 | } |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 322 | |
Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 323 | # Add the openssl.cnf file to the openssl-conf package. Make the libcrypto |
| 324 | # package RRECOMMENDS on this package. This will enable the configuration |
| 325 | # file to be installed for both the base openssl package and the libcrypto |
| 326 | # package since the base openssl package depends on the libcrypto package. |
| 327 | |
| 328 | PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc" |
| 329 | |
| 330 | FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}" |
| 331 | FILES_libssl = "${libdir}/libssl${SOLIBS}" |
| 332 | FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 333 | FILES_${PN}-engines = "${libdir}/ssl/engines/*.so ${libdir}/engines" |
| 334 | FILES_${PN}-misc = "${libdir}/ssl/misc" |
| 335 | FILES_${PN} =+ "${libdir}/ssl/*" |
| 336 | FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh" |
| 337 | |
| 338 | CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 339 | |
| 340 | RRECOMMENDS_libcrypto += "openssl-conf" |
| 341 | RDEPENDS_${PN}-misc = "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" |
| 342 | RDEPENDS_${PN}-ptest += "${PN}-misc make perl perl-module-filehandle bc" |
| 343 | |
| 344 | BBCLASSEXTEND = "native nativesdk" |