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" |
| 9 | LIC_FILES_CHKSUM = "file://LICENSE;md5=f9a8f968107345e0b75aa8c2ecaa7ec8" |
| 10 | |
| 11 | DEPENDS = "makedepend-native hostperl-runtime-native" |
| 12 | DEPENDS_append_class-target = " openssl-native" |
| 13 | |
| 14 | PROVIDES += "openssl10" |
| 15 | |
| 16 | SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \ |
| 17 | " |
| 18 | S = "${WORKDIR}/openssl-${PV}" |
| 19 | |
| 20 | PACKAGECONFIG ?= "cryptodev-linux" |
| 21 | PACKAGECONFIG[perl] = ",,," |
| 22 | PACKAGECONFIG[cryptodev-linux] = "-DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS,,cryptodev-linux" |
| 23 | |
| 24 | TERMIO_libc-musl = "-DTERMIOS" |
| 25 | TERMIO ?= "-DTERMIO" |
| 26 | # Avoid binaries being marked as requiring an executable stack since it |
| 27 | # doesn't(which causes and this causes issues with SELinux |
| 28 | CFLAG = "${@base_conditional('SITEINFO_ENDIANNESS', 'le', '-DL_ENDIAN', '-DB_ENDIAN', d)} \ |
| 29 | ${TERMIO} ${CFLAGS} -Wall -Wa,--noexecstack" |
| 30 | |
| 31 | export DIRS = "crypto ssl apps" |
| 32 | export EX_LIBS = "-lgcc -ldl" |
| 33 | export AS = "${CC} -c" |
| 34 | |
| 35 | inherit pkgconfig siteinfo multilib_header ptest relative_symlinks |
| 36 | |
| 37 | PACKAGES =+ "libcrypto libssl ${PN}-misc openssl-conf" |
| 38 | FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}" |
| 39 | FILES_libssl = "${libdir}/libssl${SOLIBS}" |
| 40 | FILES_${PN} =+ " ${libdir}/ssl/*" |
| 41 | FILES_${PN}-misc = "${libdir}/ssl/misc" |
| 42 | RDEPENDS_${PN}-misc = "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" |
| 43 | |
| 44 | # Add the openssl.cnf file to the openssl-conf package. Make the libcrypto |
| 45 | # package RRECOMMENDS on this package. This will enable the configuration |
| 46 | # file to be installed for both the base openssl package and the libcrypto |
| 47 | # package since the base openssl package depends on the libcrypto package. |
| 48 | FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 49 | CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf" |
| 50 | RRECOMMENDS_libcrypto += "openssl-conf" |
| 51 | RDEPENDS_${PN}-ptest += "${PN}-misc make perl perl-module-filehandle bc" |
| 52 | |
| 53 | # Remove this to enable SSLv3. SSLv3 is defaulted to disabled due to the POODLE |
| 54 | # vulnerability |
| 55 | EXTRA_OECONF = " -no-ssl3" |
| 56 | |
| 57 | do_configure_prepend_darwin () { |
| 58 | sed -i -e '/version-script=openssl\.ld/d' Configure |
| 59 | } |
| 60 | |
| 61 | do_configure () { |
| 62 | cd util |
| 63 | perl perlpath.pl ${STAGING_BINDIR_NATIVE} |
| 64 | cd .. |
| 65 | ln -sf apps/openssl.pod crypto/crypto.pod ssl/ssl.pod doc/ |
| 66 | |
| 67 | os=${HOST_OS} |
| 68 | case $os in |
| 69 | linux-gnueabi |\ |
| 70 | linux-gnuspe |\ |
| 71 | linux-musleabi |\ |
| 72 | linux-muslspe |\ |
| 73 | linux-musl ) |
| 74 | os=linux |
| 75 | ;; |
| 76 | *) |
| 77 | ;; |
| 78 | esac |
| 79 | target="$os-${HOST_ARCH}" |
| 80 | case $target in |
| 81 | linux-arm) |
| 82 | target=linux-armv4 |
| 83 | ;; |
| 84 | linux-armeb) |
| 85 | target=linux-elf-armeb |
| 86 | ;; |
| 87 | linux-aarch64*) |
| 88 | target=linux-aarch64 |
| 89 | ;; |
| 90 | linux-sh3) |
| 91 | target=debian-sh3 |
| 92 | ;; |
| 93 | linux-sh4) |
| 94 | target=debian-sh4 |
| 95 | ;; |
| 96 | linux-i486) |
| 97 | target=debian-i386-i486 |
| 98 | ;; |
| 99 | linux-i586 | linux-viac3) |
| 100 | target=debian-i386-i586 |
| 101 | ;; |
| 102 | linux-i686) |
| 103 | target=debian-i386-i686/cmov |
| 104 | ;; |
| 105 | linux-gnux32-x86_64 | linux-muslx32-x86_64 ) |
| 106 | target=linux-x32 |
| 107 | ;; |
| 108 | linux-gnu64-x86_64) |
| 109 | target=linux-x86_64 |
| 110 | ;; |
| 111 | linux-gnun32-mips*el) |
| 112 | target=debian-mipsn32el |
| 113 | ;; |
| 114 | linux-gnun32-mips*) |
| 115 | target=debian-mipsn32 |
| 116 | ;; |
| 117 | linux-mips*64*el) |
| 118 | target=debian-mips64el |
| 119 | ;; |
| 120 | linux-mips*64*) |
| 121 | target=debian-mips64 |
| 122 | ;; |
| 123 | linux-mips*el) |
| 124 | target=debian-mipsel |
| 125 | ;; |
| 126 | linux-mips*) |
| 127 | target=debian-mips |
| 128 | ;; |
| 129 | linux-microblaze*|linux-nios2*|linux-gnu*ilp32**) |
| 130 | target=linux-generic32 |
| 131 | ;; |
| 132 | linux-powerpc) |
| 133 | target=linux-ppc |
| 134 | ;; |
| 135 | linux-powerpc64) |
| 136 | target=linux-ppc64 |
| 137 | ;; |
| 138 | linux-supersparc) |
| 139 | target=linux-sparcv8 |
| 140 | ;; |
| 141 | linux-sparc) |
| 142 | target=linux-sparcv8 |
| 143 | ;; |
| 144 | darwin-i386) |
| 145 | target=darwin-i386-cc |
| 146 | ;; |
| 147 | esac |
| 148 | # inject machine-specific flags |
| 149 | sed -i -e "s|^\(\"$target\",\s*\"[^:]\+\):\([^:]\+\)|\1:${CFLAG}|g" Configure |
| 150 | useprefix=${prefix} |
| 151 | if [ "x$useprefix" = "x" ]; then |
| 152 | useprefix=/ |
| 153 | fi |
| 154 | perl ./Configure ${EXTRA_OECONF} shared --prefix=$useprefix --openssldir=${libdir}/ssl --libdir=`basename ${libdir}` $target |
| 155 | } |
| 156 | |
| 157 | do_compile_prepend_class-target () { |
| 158 | sed -i 's/\((OPENSSL=\)".*"/\1"openssl"/' Makefile |
Brad Bishop | 0011132 | 2018-04-01 22:23:53 -0400 | [diff] [blame] | 159 | oe_runmake depend |
| 160 | cc_sanitized=`echo "${CC} ${CFLAG}" | sed -e 's,--sysroot=${STAGING_DIR_TARGET},,g' -e 's|${DEBUG_PREFIX_MAP}||g'` |
| 161 | oe_runmake CC_INFO="${cc_sanitized}" |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | do_compile () { |
| 165 | oe_runmake depend |
| 166 | oe_runmake |
| 167 | } |
| 168 | |
| 169 | do_compile_ptest () { |
| 170 | # build dependencies for test directory too |
| 171 | export DIRS="$DIRS test" |
| 172 | oe_runmake depend |
| 173 | oe_runmake buildtest |
| 174 | } |
| 175 | |
| 176 | do_install () { |
| 177 | # Create ${D}/${prefix} to fix parallel issues |
| 178 | mkdir -p ${D}/${prefix}/ |
| 179 | |
| 180 | oe_runmake INSTALL_PREFIX="${D}" MANDIR="${mandir}" install |
| 181 | |
| 182 | oe_libinstall -so libcrypto ${D}${libdir} |
| 183 | oe_libinstall -so libssl ${D}${libdir} |
| 184 | |
| 185 | install -d ${D}${includedir} |
| 186 | cp --dereference -R include/openssl ${D}${includedir} |
| 187 | |
| 188 | install -Dm 0755 ${WORKDIR}/openssl-c_rehash.sh ${D}${bindir}/c_rehash |
| 189 | sed -i -e 's,/etc/openssl,${sysconfdir}/ssl,g' ${D}${bindir}/c_rehash |
| 190 | |
| 191 | oe_multilib_header openssl/opensslconf.h |
| 192 | if [ "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" ]; then |
| 193 | sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/CA.pl |
| 194 | sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/tsget |
| 195 | else |
| 196 | rm -f ${D}${libdir}/ssl/misc/CA.pl ${D}${libdir}/ssl/misc/tsget |
| 197 | fi |
| 198 | |
| 199 | # Create SSL structure |
| 200 | install -d ${D}${sysconfdir}/ssl/ |
| 201 | mv ${D}${libdir}/ssl/openssl.cnf \ |
| 202 | ${D}${libdir}/ssl/certs \ |
| 203 | ${D}${libdir}/ssl/private \ |
| 204 | \ |
| 205 | ${D}${sysconfdir}/ssl/ |
| 206 | ln -sf ${sysconfdir}/ssl/certs ${D}${libdir}/ssl/certs |
| 207 | ln -sf ${sysconfdir}/ssl/private ${D}${libdir}/ssl/private |
| 208 | ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${libdir}/ssl/openssl.cnf |
| 209 | |
| 210 | # Rename man pages to prefix openssl10-* |
| 211 | for f in `find ${D}${mandir} -type f`; do |
| 212 | mv $f $(dirname $f)/openssl10-$(basename $f) |
| 213 | done |
| 214 | for f in `find ${D}${mandir} -type l`; do |
| 215 | ln_f=`readlink $f` |
| 216 | rm -f $f |
| 217 | ln -s openssl10-$ln_f $(dirname $f)/openssl10-$(basename $f) |
| 218 | done |
| 219 | } |
| 220 | |
| 221 | do_install_ptest () { |
| 222 | cp -r -L Makefile.org Makefile test ${D}${PTEST_PATH} |
| 223 | |
| 224 | # Replace the path to native perl with the path to target perl |
| 225 | sed -i 's,^PERL=.*,PERL=${bindir}/perl,' ${D}${PTEST_PATH}/Makefile |
| 226 | |
| 227 | cp Configure config e_os.h ${D}${PTEST_PATH} |
| 228 | cp -r -L include ${D}${PTEST_PATH} |
| 229 | ln -sf ${libdir}/libcrypto.a ${D}${PTEST_PATH} |
| 230 | ln -sf ${libdir}/libssl.a ${D}${PTEST_PATH} |
| 231 | mkdir -p ${D}${PTEST_PATH}/crypto |
| 232 | cp crypto/constant_time_locl.h ${D}${PTEST_PATH}/crypto |
| 233 | cp -r certs ${D}${PTEST_PATH} |
| 234 | mkdir -p ${D}${PTEST_PATH}/apps |
| 235 | ln -sf ${libdir}/ssl/misc/CA.sh ${D}${PTEST_PATH}/apps |
| 236 | ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${PTEST_PATH}/apps |
| 237 | ln -sf ${bindir}/openssl ${D}${PTEST_PATH}/apps |
| 238 | cp apps/server.pem ${D}${PTEST_PATH}/apps |
| 239 | cp apps/server2.pem ${D}${PTEST_PATH}/apps |
| 240 | mkdir -p ${D}${PTEST_PATH}/util |
| 241 | install util/opensslwrap.sh ${D}${PTEST_PATH}/util |
| 242 | install util/shlib_wrap.sh ${D}${PTEST_PATH}/util |
| 243 | # Time stamps are relevant for "make alltests", otherwise |
| 244 | # make may try to recompile binaries. Not only must the |
| 245 | # binary files be newer than the sources, they also must |
| 246 | # be more recent than the header files in /usr/include. |
| 247 | # |
| 248 | # Using "cp -a" is not sufficient, because do_install |
| 249 | # does not preserve the original time stamps. |
| 250 | # |
| 251 | # So instead of using the original file stamps, we set |
| 252 | # the current time for all files. Binaries will get |
| 253 | # modified again later when stripping them, but that's okay. |
| 254 | touch ${D}${PTEST_PATH} |
| 255 | find ${D}${PTEST_PATH} -type f -print0 | xargs --verbose -0 touch -r ${D}${PTEST_PATH} |
| 256 | |
| 257 | # exclude binary files or the package won't install |
| 258 | for d in ssltest_old v3ext x509aux; do |
| 259 | rm -rf ${D}${libdir}/${BPN}/ptest/test/$d |
| 260 | done |
| 261 | |
| 262 | # Remove build host references |
| 263 | sed -i \ |
| 264 | -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \ |
| 265 | -e 's|${DEBUG_PREFIX_MAP}||g' \ |
| 266 | ${D}${PTEST_PATH}/Makefile ${D}${PTEST_PATH}/Configure |
| 267 | } |
| 268 | |
| 269 | do_install_append_class-native() { |
| 270 | create_wrapper ${D}${bindir}/openssl \ |
| 271 | OPENSSL_CONF=${libdir}/ssl/openssl.cnf \ |
| 272 | SSL_CERT_DIR=${libdir}/ssl/certs \ |
| 273 | SSL_CERT_FILE=${libdir}/ssl/cert.pem \ |
| 274 | OPENSSL_ENGINES=${libdir}/ssl/engines |
| 275 | } |
| 276 | |
| 277 | BBCLASSEXTEND = "native nativesdk" |
| 278 | |