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