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