blob: 54af100f90d1e1fae420ac667060a6594f1eb670 [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 | SSLeay" dual license
8LICENSE = "openssl"
9LIC_FILES_CHKSUM = "file://LICENSE;md5=f475368924827d06d4b416111c8bdb77"
10
11DEPENDS = "hostperl-runtime-native"
12DEPENDS_append_class-target = " openssl-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://configure-targets.patch \
18 file://shared-libs.patch \
19 file://oe-ldflags.patch \
20 file://engines-install-in-libdir-ssl.patch \
21 file://debian1.0.2/block_diginotar.patch \
22 file://debian1.0.2/block_digicert_malaysia.patch \
23 file://debian/c_rehash-compat.patch \
24 file://debian/debian-targets.patch \
25 file://debian/man-dir.patch \
26 file://debian/man-section.patch \
27 file://debian/no-rpath.patch \
28 file://debian/no-symbolic.patch \
29 file://debian/pic.patch \
30 file://debian1.0.2/version-script.patch \
31 file://debian1.0.2/soname.patch \
32 file://openssl_fix_for_x32.patch \
33 file://openssl-fix-des.pod-error.patch \
34 file://Makefiles-ptest.patch \
35 file://ptest-deps.patch \
36 file://ptest_makefile_deps.patch \
37 file://configure-musl-target.patch \
38 file://parallel.patch \
39 file://Use-SHA256-not-MD5-as-default-digest.patch \
40 file://0001-Fix-build-with-clang-using-external-assembler.patch \
41 file://0001-openssl-force-soft-link-to-avoid-rare-race.patch \
42 file://0001-allow-manpages-to-be-disabled.patch \
Andrew Geissler99467da2019-02-25 18:54:23 -060043 file://0001-Fix-BN_LLONG-breakage.patch \
Andrew Geissleref7893b2019-03-06 19:05:14 -060044 file://0001-Fix-DES_LONG-breakage.patch \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080045 "
46
47SRC_URI_append_class-target = " \
48 file://reproducible-cflags.patch \
49 file://reproducible-mkbuildinf.patch \
50 "
51
52SRC_URI_append_class-nativesdk = " \
53 file://environment.d-openssl.sh \
54 "
55
Andrew Geissler99467da2019-02-25 18:54:23 -060056SRC_URI[md5sum] = "7563e1ce046cb21948eeb6ba1a0eb71c"
57SRC_URI[sha256sum] = "5744cfcbcec2b1b48629f7354203bc1e5e9b5466998bbccc5b5fcde3b18eb684"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080058
59S = "${WORKDIR}/openssl-${PV}"
60
61UPSTREAM_CHECK_REGEX = "openssl-(?P<pver>1\.0.+)\.tar"
62
63inherit pkgconfig siteinfo multilib_header ptest manpages
64
65PACKAGECONFIG ?= "cryptodev-linux"
66PACKAGECONFIG_class-native = ""
67PACKAGECONFIG_class-nativesdk = ""
68
69PACKAGECONFIG[cryptodev-linux] = "-DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS,,cryptodev-linux"
70PACKAGECONFIG[manpages] = ",,,"
71PACKAGECONFIG[perl] = ",,,"
72
73# Remove this to enable SSLv3. SSLv3 is defaulted to disabled due to the POODLE
74# vulnerability
75EXTRA_OECONF = "no-ssl3"
76
77EXTRA_OEMAKE = "${@bb.utils.contains('PACKAGECONFIG', 'manpages', '', 'OE_DISABLE_MANPAGES=1', d)}"
78
79export OE_LDFLAGS = "${LDFLAGS}"
80
81# openssl fails with ccache: https://bugzilla.yoctoproject.org/show_bug.cgi?id=12810
82CCACHE = ""
83
84TERMIO ?= "-DTERMIO"
85TERMIO_libc-musl = "-DTERMIOS"
Andrew Geissler99467da2019-02-25 18:54:23 -060086EXTRA_OECONF_append_libc-musl_powerpc64 = " no-asm"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080087
88CFLAG = "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', '-DL_ENDIAN', '-DB_ENDIAN', d)} \
89 ${TERMIO} ${CFLAGS} -Wall"
90
91# Avoid binaries being marked as requiring an executable stack since they don't
92# (and it causes issues with SELinux)
93CFLAG += "-Wa,--noexecstack"
94
95CFLAG_append_class-native = " -fPIC"
96
97do_configure () {
98 # The crypto_use_bigint patch means that perl's bignum module needs to be
99 # installed, but some distributions (for example Fedora 23) don't ship it by
100 # default. As the resulting error is very misleading check for bignum before
101 # building.
102 if ! perl -Mbigint -e true; then
103 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."
104 fi
105
106 ln -sf apps/openssl.pod crypto/crypto.pod ssl/ssl.pod doc/
107
108 os=${HOST_OS}
109 case $os in
110 linux-gnueabi |\
111 linux-gnuspe |\
112 linux-musleabi |\
113 linux-muslspe |\
114 linux-musl )
115 os=linux
116 ;;
117 *)
118 ;;
119 esac
120 target="$os-${HOST_ARCH}"
121 case $target in
122 linux-arm)
123 target=linux-armv4
124 ;;
125 linux-armeb)
126 target=linux-elf-armeb
127 ;;
128 linux-aarch64*)
129 target=linux-aarch64
130 ;;
131 linux-sh3)
132 target=debian-sh3
133 ;;
134 linux-sh4)
135 target=debian-sh4
136 ;;
137 linux-i486)
138 target=debian-i386-i486
139 ;;
140 linux-i586 | linux-viac3)
141 target=debian-i386-i586
142 ;;
143 linux-i686)
144 target=debian-i386-i686/cmov
145 ;;
146 linux-gnux32-x86_64 | linux-muslx32-x86_64 )
147 target=linux-x32
148 ;;
149 linux-gnu64-x86_64)
150 target=linux-x86_64
151 ;;
152 linux-gnun32-mips*el)
153 target=debian-mipsn32el
154 ;;
155 linux-gnun32-mips*)
156 target=debian-mipsn32
157 ;;
158 linux-mips*64*el)
159 target=debian-mips64el
160 ;;
161 linux-mips*64*)
162 target=debian-mips64
163 ;;
164 linux-mips*el)
165 target=debian-mipsel
166 ;;
167 linux-mips*)
168 target=debian-mips
169 ;;
170 linux-microblaze* | linux-nios2* | linux-gnu*ilp32** | linux-arc*)
171 target=linux-generic32
172 ;;
173 linux-powerpc)
174 target=linux-ppc
175 ;;
176 linux-powerpc64)
177 target=linux-ppc64
178 ;;
179 linux-riscv32)
180 target=linux-generic32
181 ;;
182 linux-riscv64)
183 target=linux-generic64
184 ;;
185 linux-sparc | linux-supersparc)
186 target=linux-sparcv8
187 ;;
188 esac
189
190 # inject machine-specific flags
191 sed -i -e "s|^\(\"$target\",\s*\"[^:]\+\):\([^:]\+\)|\1:${CFLAG}|g" Configure
192
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
199}
200
201do_compile () {
202 oe_runmake depend
203 oe_runmake
204}
205
206do_compile_class-target () {
207 sed -i 's/\((OPENSSL=\)".*"/\1"openssl"/' Makefile
208 oe_runmake depend
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
213do_compile_ptest () {
214 oe_runmake buildtest
215}
216
217do_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 oe_multilib_header openssl/opensslconf.h
230
231 install -Dm 0755 ${WORKDIR}/openssl-c_rehash.sh ${D}${bindir}/c_rehash
232 sed -i -e 's,/etc/openssl,${sysconfdir}/ssl,g' ${D}${bindir}/c_rehash
233
234 if [ "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}" ]; then
235 sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/CA.pl
236 sed -i -e '1s,.*,#!${bindir}/env perl,' ${D}${libdir}/ssl/misc/tsget
237 else
238 rm -f ${D}${libdir}/ssl/misc/CA.pl ${D}${libdir}/ssl/misc/tsget
239 fi
240
241 # Create SSL structure for packages such as ca-certificates which
242 # contain hard-coded paths to /etc/ssl. Debian does the same.
243 install -d ${D}${sysconfdir}/ssl
244 mv ${D}${libdir}/ssl/certs \
245 ${D}${libdir}/ssl/private \
246 ${D}${libdir}/ssl/openssl.cnf \
247 ${D}${sysconfdir}/ssl/
248
249 # Although absolute symlinks would be OK for the target, they become
250 # invalid if native or nativesdk are relocated from sstate.
251 ln -sf ${@oe.path.relative('${libdir}/ssl', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl/certs
252 ln -sf ${@oe.path.relative('${libdir}/ssl', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl/private
253 ln -sf ${@oe.path.relative('${libdir}/ssl', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl/openssl.cnf
254
255 # Rename man pages to prefix openssl10-*
256 for f in `find ${D}${mandir} -type f`; do
257 mv $f $(dirname $f)/openssl10-$(basename $f)
258 done
259 for f in `find ${D}${mandir} -type l`; do
260 ln_f=`readlink $f`
261 rm -f $f
262 ln -s openssl10-$ln_f $(dirname $f)/openssl10-$(basename $f)
263 done
264}
265
266do_install_append_class-native () {
267 create_wrapper ${D}${bindir}/openssl \
268 OPENSSL_CONF=${libdir}/ssl/openssl.cnf \
269 SSL_CERT_DIR=${libdir}/ssl/certs \
270 SSL_CERT_FILE=${libdir}/ssl/cert.pem \
271 OPENSSL_ENGINES=${libdir}/ssl/engines
272}
273
274do_install_append_class-nativesdk () {
275 mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
276 install -m 644 ${WORKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
277}
278
279do_install_ptest () {
280 cp -r -L Makefile.org Makefile test ${D}${PTEST_PATH}
281
282 # Replace the path to native perl with the path to target perl
283 sed -i 's,^PERL=.*,PERL=${bindir}/perl,' ${D}${PTEST_PATH}/Makefile
284
285 cp Configure config e_os.h ${D}${PTEST_PATH}
286 cp -r -L include ${D}${PTEST_PATH}
287 ln -sf ${libdir}/libcrypto.a ${D}${PTEST_PATH}
288 ln -sf ${libdir}/libssl.a ${D}${PTEST_PATH}
289 mkdir -p ${D}${PTEST_PATH}/crypto
290 cp crypto/constant_time_locl.h ${D}${PTEST_PATH}/crypto
291 cp -r certs ${D}${PTEST_PATH}
292 mkdir -p ${D}${PTEST_PATH}/apps
293 ln -sf ${libdir}/ssl/misc/CA.sh ${D}${PTEST_PATH}/apps
294 ln -sf ${sysconfdir}/ssl/openssl.cnf ${D}${PTEST_PATH}/apps
295 ln -sf ${bindir}/openssl ${D}${PTEST_PATH}/apps
296 cp apps/server.pem ${D}${PTEST_PATH}/apps
297 cp apps/server2.pem ${D}${PTEST_PATH}/apps
298 mkdir -p ${D}${PTEST_PATH}/util
299 install util/opensslwrap.sh ${D}${PTEST_PATH}/util
300 install util/shlib_wrap.sh ${D}${PTEST_PATH}/util
301 # Time stamps are relevant for "make alltests", otherwise
302 # make may try to recompile binaries. Not only must the
303 # binary files be newer than the sources, they also must
304 # be more recent than the header files in /usr/include.
305 #
306 # Using "cp -a" is not sufficient, because do_install
307 # does not preserve the original time stamps.
308 #
309 # So instead of using the original file stamps, we set
310 # the current time for all files. Binaries will get
311 # modified again later when stripping them, but that's okay.
312 touch ${D}${PTEST_PATH}
313 find ${D}${PTEST_PATH} -type f -print0 | xargs --verbose -0 touch -r ${D}${PTEST_PATH}
314
315 # exclude binary files or the package won't install
316 for d in ssltest_old v3ext x509aux; do
317 rm -rf ${D}${libdir}/${BPN}/ptest/test/$d
318 done
319
320 # Remove build host references
321 sed -i \
322 -e 's,--sysroot=${STAGING_DIR_TARGET},,g' \
323 -e 's|${DEBUG_PREFIX_MAP}||g' \
324 ${D}${PTEST_PATH}/Makefile ${D}${PTEST_PATH}/Configure
325}
326
327# Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
328# package RRECOMMENDS on this package. This will enable the configuration
329# file to be installed for both the base openssl package and the libcrypto
330# package since the base openssl package depends on the libcrypto package.
331
332PACKAGES =+ "libcrypto10 libssl10 openssl10-conf ${PN}-engines ${PN}-misc"
333
334FILES_libcrypto10 = "${libdir}/libcrypto${SOLIBS}"
335FILES_libssl10 = "${libdir}/libssl${SOLIBS}"
336FILES_openssl10-conf = "${sysconfdir}/ssl/openssl.cnf"
337FILES_${PN}-engines = "${libdir}/ssl/engines/*.so ${libdir}/engines"
338FILES_${PN}-misc = "${libdir}/ssl/misc"
339FILES_${PN} =+ "${libdir}/ssl/*"
340FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
341
342CONFFILES_openssl10-conf = "${sysconfdir}/ssl/openssl.cnf"
343
344RRECOMMENDS_libcrypto10 += "openssl10-conf"
345RDEPENDS_${PN}-misc = "${@bb.utils.filter('PACKAGECONFIG', 'perl', d)}"
346RDEPENDS_${PN}-ptest += "${PN}-misc make perl perl-module-filehandle bc"
347
348BBCLASSEXTEND = "native nativesdk"
349PACKAGE_PREPROCESS_FUNCS += "openssl_package_preprocess"
350
351# openssl 1.0 development files and executable binaries clash with openssl 1.1
352# files when installed into target rootfs. So we don't put them into
353# packages, but they continue to be provided via target sysroot for
354# cross-compilation on the host, if some software still depends on openssl 1.0.
355openssl_package_preprocess () {
356 for file in `find ${PKGD} -name *.h -o -name *.pc -o -name *.so`; do
357 rm $file
358 done
Brad Bishopa5c52ff2018-11-23 10:55:50 +1300359 rm ${PKGD}${bindir}/openssl
360 rm ${PKGD}${bindir}/c_rehash
361 rmdir ${PKGD}${bindir}
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800362
363}