blob: 1234b64b8641a89a21dd6107cd6480b5e04178c5 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001SUMMARY = "Secure Socket Layer"
2DESCRIPTION = "Secure Socket Layer (SSL) binary and related cryptographic tools."
3HOMEPAGE = "http://www.openssl.org/"
4BUGTRACKER = "http://www.openssl.org/news/vulnerabilities.html"
5SECTION = "libs/network"
6
7# "openssl" here actually means both OpenSSL and SSLeay licenses apply
8# (see meta/files/common-licenses/OpenSSL to which "openssl" is SPDXLICENSEMAPped)
9LICENSE = "openssl"
10LIC_FILES_CHKSUM = "file://LICENSE;md5=d57d511030c9d66ef5f5966bee5a7eff"
11
12DEPENDS = "hostperl-runtime-native"
13
14SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
15 file://run-ptest \
16 file://openssl-c_rehash.sh \
17 file://0001-skip-test_symbol_presence.patch \
18 file://0002-fix-CVE-2018-0734.patch \
19 file://0003-fix-CVE-2018-0735.patch \
20 file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
21 "
22
23SRC_URI_append_class-nativesdk = " \
24 file://environment.d-openssl.sh \
25 "
26
27SRC_URI[md5sum] = "7079eb017429e0ffb9efb42bf80ccb21"
28SRC_URI[sha256sum] = "2836875a0f89c03d0fdf483941512613a50cfb421d6fd94b9f41d7279d586a3d"
29
30inherit lib_package multilib_header ptest
31
32B = "${WORKDIR}/build"
33do_configure[cleandirs] = "${B}"
34
35#| ./libcrypto.so: undefined reference to `getcontext'
36#| ./libcrypto.so: undefined reference to `setcontext'
37#| ./libcrypto.so: undefined reference to `makecontext'
38EXTRA_OECONF_append_libc-musl = " no-async"
39
40# This prevents openssl from using getrandom() which is not available on older glibc versions
41# (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
42EXTRA_OECONF_class-native = "--with-rand-seed=devrandom"
43EXTRA_OECONF_class-nativesdk = "--with-rand-seed=devrandom"
44
45# Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
46CFLAGS_append_class-native = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
47CFLAGS_append_class-nativesdk = " -DOPENSSLDIR=/not/builtin -DENGINESDIR=/not/builtin"
48
49do_configure () {
50 os=${HOST_OS}
51 case $os in
52 linux-gnueabi |\
53 linux-gnuspe |\
54 linux-musleabi |\
55 linux-muslspe |\
56 linux-musl )
57 os=linux
58 ;;
59 *)
60 ;;
61 esac
62 target="$os-${HOST_ARCH}"
63 case $target in
64 linux-arm*)
65 target=linux-armv4
66 ;;
67 linux-aarch64*)
68 target=linux-aarch64
69 ;;
70 linux-i?86 | linux-viac3)
71 target=linux-x86
72 ;;
73 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
74 target=linux-x32
75 ;;
76 linux-gnu64-x86_64)
77 target=linux-x86_64
78 ;;
79 linux-mips | linux-mipsel)
80 # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
81 target="linux-mips32 ${TARGET_CC_ARCH}"
82 ;;
83 linux-gnun32-mips*)
84 target=linux-mips64
85 ;;
86 linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
87 target=linux64-mips64
88 ;;
89 linux-microblaze* | linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
90 target=linux-generic32
91 ;;
92 linux-powerpc)
93 target=linux-ppc
94 ;;
95 linux-powerpc64)
96 target=linux-ppc64
97 ;;
98 linux-riscv32)
99 target=linux-generic32
100 ;;
101 linux-riscv64)
102 target=linux-generic64
103 ;;
104 linux-sparc | linux-supersparc)
105 target=linux-sparcv9
106 ;;
107 esac
108
109 useprefix=${prefix}
110 if [ "x$useprefix" = "x" ]; then
111 useprefix=/
112 fi
113 # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
114 # environment variables set by bitbake. Adjust the environment variables instead.
115 PERL5LIB="${S}/external/perl/Text-Template-1.46/lib/" \
116 perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} --prefix=$useprefix --openssldir=${libdir}/ssl-1.1 --libdir=${libdir} $target
117}
118
119do_install () {
120 oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install
121
122 oe_multilib_header openssl/opensslconf.h
123
124 # Create SSL structure for packages such as ca-certificates which
125 # contain hard-coded paths to /etc/ssl. Debian does the same.
126 install -d ${D}${sysconfdir}/ssl
127 mv ${D}${libdir}/ssl-1.1/certs \
128 ${D}${libdir}/ssl-1.1/private \
129 ${D}${libdir}/ssl-1.1/openssl.cnf \
130 ${D}${sysconfdir}/ssl/
131
132 # Although absolute symlinks would be OK for the target, they become
133 # invalid if native or nativesdk are relocated from sstate.
134 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-1.1/certs
135 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-1.1/private
136 ln -sf ${@oe.path.relative('${libdir}/ssl-1.1', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-1.1/openssl.cnf
137}
138
139do_install_append_class-native () {
140 create_wrapper ${D}${bindir}/openssl \
141 OPENSSL_CONF=${libdir}/ssl-1.1/openssl.cnf \
142 SSL_CERT_DIR=${libdir}/ssl-1.1/certs \
143 SSL_CERT_FILE=${libdir}/ssl-1.1/cert.pem \
144 OPENSSL_ENGINES=${libdir}/ssl-1.1/engines
145
146 # Install a custom version of c_rehash that can handle sysroots properly.
147 # This version is used for example when installing ca-certificates during
148 # image creation.
149 install -Dm 0755 ${WORKDIR}/openssl-c_rehash.sh ${D}${bindir}/c_rehash
150 sed -i -e 's,/etc/openssl,${sysconfdir}/ssl,g' ${D}${bindir}/c_rehash
151}
152
153do_install_append_class-nativesdk () {
154 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
155 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
156 sed 's|/usr/lib/ssl/|/usr/lib/ssl-1.1/|g' -i ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
157}
158
159do_install_ptest () {
160 # Prune the build tree
161 rm -f ${B}/fuzz/*.* ${B}/test/*.*
162
163 cp ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
164 cp -r ${S}/external ${B}/test ${S}/test ${B}/fuzz ${S}/util ${B}/util ${D}${PTEST_PATH}
165
166 # For test_shlibload
167 ln -s ${libdir}/libcrypto.so.1.1 ${D}${PTEST_PATH}/libcrypto.so
168 ln -s ${libdir}/libssl.so.1.1 ${D}${PTEST_PATH}/libssl.so
169
170 install -d ${D}${PTEST_PATH}/apps
171 ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
172 install -m644 ${S}/apps/*.pem ${S}/apps/*.srl ${S}/apps/openssl.cnf ${D}${PTEST_PATH}/apps
173 install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps
174
175 install -d ${D}${PTEST_PATH}/engines
176 install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines
177}
178
179# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
180# package RRECOMMENDS on this package. This will enable the configuration
181# file to be installed for both the openssl-bin package and the libcrypto
182# package since the openssl-bin package depends on the libcrypto package.
183
184PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc"
185
186FILES_libcrypto = "${libdir}/libcrypto${SOLIBS}"
187FILES_libssl = "${libdir}/libssl${SOLIBS}"
188FILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
189FILES_${PN}-engines = "${libdir}/engines-1.1"
190FILES_${PN}-misc = "${libdir}/ssl-1.1/misc"
191FILES_${PN} =+ "${libdir}/ssl-1.1/*"
192FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
193
194CONFFILES_openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
195
196RRECOMMENDS_libcrypto += "openssl-conf"
197RDEPENDS_${PN}-bin = "perl"
198RDEPENDS_${PN}-misc = "perl"
199RDEPENDS_${PN}-ptest += "openssl-bin perl perl-modules bash python"
200
201RPROVIDES_openssl-conf = "openssl10-conf"
202RREPLACES_openssl-conf = "openssl10-conf"
203RCONFLICTS_openssl-conf = "openssl10-conf"
204
205BBCLASSEXTEND = "native nativesdk"