openssl_3.5.4.bb 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. LICENSE = "Apache-2.0"
  7. LIC_FILES_CHKSUM = "file://LICENSE.txt;md5=c75985e733726beaba57bc5253e96d04"
  8. SRC_URI = "http://www.openssl.org/source/openssl-${PV}.tar.gz \
  9. file://run-ptest \
  10. file://0001-buildinfo-strip-sysroot-and-debug-prefix-map-from-co.patch \
  11. file://0001-Configure-do-not-tweak-mips-cflags.patch \
  12. file://0001-Added-handshake-history-reporting-when-test-fails.patch \
  13. "
  14. SRC_URI:append:class-nativesdk = " \
  15. file://environment.d-openssl.sh \
  16. "
  17. SRC_URI[sha256sum] = "967311f84955316969bdb1d8d4b983718ef42338639c621ec4c34fddef355e99"
  18. inherit lib_package multilib_header multilib_script ptest perlnative manpages
  19. MULTILIB_SCRIPTS = "${PN}-bin:${bindir}/c_rehash"
  20. PACKAGECONFIG ?= ""
  21. PACKAGECONFIG:class-native = ""
  22. PACKAGECONFIG:class-nativesdk = ""
  23. PACKAGECONFIG[cryptodev-linux] = "enable-devcryptoeng,disable-devcryptoeng,cryptodev-linux,,cryptodev-module"
  24. PACKAGECONFIG[no-tls1] = "no-tls1"
  25. PACKAGECONFIG[no-tls1_1] = "no-tls1_1"
  26. PACKAGECONFIG[manpages] = ""
  27. PACKAGECONFIG[fips] = "enable-fips"
  28. B = "${WORKDIR}/build"
  29. do_configure[cleandirs] = "${B}"
  30. EXTRA_OECONF = "${@bb.utils.contains('PTEST_ENABLED', '1', '', 'no-tests', d)}"
  31. #| ./libcrypto.so: undefined reference to `getcontext'
  32. #| ./libcrypto.so: undefined reference to `setcontext'
  33. #| ./libcrypto.so: undefined reference to `makecontext'
  34. EXTRA_OECONF:append:libc-musl = " no-async"
  35. EXTRA_OECONF:append:libc-musl:powerpc64 = " no-asm"
  36. # adding devrandom prevents openssl from using getrandom() which is not available on older glibc versions
  37. # (native versions can be built with newer glibc, but then relocated onto a system with older glibc)
  38. EXTRA_OECONF:append:class-native = " --with-rand-seed=os,devrandom"
  39. EXTRA_OECONF:append:class-nativesdk = " --with-rand-seed=os,devrandom"
  40. # Relying on hardcoded built-in paths causes openssl-native to not be relocateable from sstate.
  41. EXTRA_OEMAKE:append:task-compile:class-native = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
  42. EXTRA_OEMAKE:append:task-compile:class-nativesdk = ' OPENSSLDIR="/not/builtin" ENGINESDIR="/not/builtin" MODULESDIR="/not/builtin"'
  43. #| threads_pthread.c:(.text+0x372): undefined reference to `__atomic_is_lock_free'
  44. EXTRA_OECONF:append:toolchain-clang:x86 = " -latomic"
  45. # This allows disabling deprecated or undesirable crypto algorithms.
  46. # The default is to trust upstream choices.
  47. DEPRECATED_CRYPTO_FLAGS ?= ""
  48. do_configure () {
  49. # When we upgrade glibc but not uninative we see obtuse failures in openssl. Make
  50. # the issue really clear that perl isn't functional due to symbol mismatch issues.
  51. cat <<- EOF > ${WORKDIR}/perltest
  52. #!/usr/bin/env perl
  53. use POSIX;
  54. EOF
  55. chmod a+x ${WORKDIR}/perltest
  56. ${WORKDIR}/perltest
  57. os=${HOST_OS}
  58. case $os in
  59. linux-gnueabi |\
  60. linux-gnuspe |\
  61. linux-musleabi |\
  62. linux-muslspe |\
  63. linux-musl )
  64. os=linux
  65. ;;
  66. *)
  67. ;;
  68. esac
  69. target="$os-${HOST_ARCH}"
  70. case $target in
  71. linux-arc | linux-microblaze*)
  72. target=linux-latomic
  73. ;;
  74. linux-arm*)
  75. target=linux-armv4
  76. ;;
  77. linux-aarch64*)
  78. target=linux-aarch64
  79. ;;
  80. linux-i?86 | linux-viac3)
  81. target=linux-x86
  82. ;;
  83. linux-gnux32-x86_64 | linux-muslx32-x86_64 )
  84. target=linux-x32
  85. ;;
  86. linux-gnu64-x86_64)
  87. target=linux-x86_64
  88. ;;
  89. linux-loongarch64)
  90. target=linux64-loongarch64
  91. ;;
  92. linux-mips | linux-mipsel)
  93. # specifying TARGET_CC_ARCH prevents openssl from (incorrectly) adding target architecture flags
  94. target="linux-mips32 ${TARGET_CC_ARCH}"
  95. ;;
  96. linux-gnun32-mips*)
  97. target=linux-mips64
  98. ;;
  99. linux-*-mips64 | linux-mips64 | linux-*-mips64el | linux-mips64el)
  100. target=linux64-mips64
  101. ;;
  102. linux-nios2* | linux-sh3 | linux-sh4 | linux-arc*)
  103. target=linux-generic32
  104. ;;
  105. linux-powerpc)
  106. target=linux-ppc
  107. ;;
  108. linux-powerpc64)
  109. target=linux-ppc64
  110. ;;
  111. linux-powerpc64le)
  112. target=linux-ppc64le
  113. ;;
  114. linux-riscv32)
  115. target=linux32-riscv32
  116. ;;
  117. linux-riscv64)
  118. target=linux64-riscv64
  119. ;;
  120. linux-sparc | linux-supersparc)
  121. target=linux-sparcv9
  122. ;;
  123. mingw32-x86_64)
  124. target=mingw64
  125. ;;
  126. esac
  127. # WARNING: do not set compiler/linker flags (-I/-D etc.) in EXTRA_OECONF, as they will fully replace the
  128. # environment variables set by bitbake. Adjust the environment variables instead.
  129. PERLEXTERNAL="$(realpath ${S}/external/perl/Text-Template-*/lib)"
  130. test -d "$PERLEXTERNAL" || bberror "PERLEXTERNAL '$PERLEXTERNAL' not found!"
  131. HASHBANGPERL="/usr/bin/env perl" PERL=perl PERL5LIB="$PERLEXTERNAL" \
  132. perl ${S}/Configure ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} ${DEPRECATED_CRYPTO_FLAGS} --prefix=${prefix} --openssldir=${libdir}/ssl-3 --libdir=${baselib} $target
  133. perl ${B}/configdata.pm --dump
  134. }
  135. do_compile:append () {
  136. # The test suite binaries are large and we don't need the debugging in them
  137. if test -d ${B}/test; then
  138. find ${B}/test -type f -executable -exec ${STRIP} {} \;
  139. fi
  140. }
  141. do_install () {
  142. oe_runmake DESTDIR="${D}" MANDIR="${mandir}" MANSUFFIX=ssl install_sw install_ssldirs \
  143. ${@bb.utils.contains('PACKAGECONFIG', 'manpages', 'install_docs', '', d)} \
  144. ${@bb.utils.contains('PACKAGECONFIG', 'fips', 'install_fips', '', d)}
  145. oe_multilib_header openssl/opensslconf.h
  146. oe_multilib_header openssl/configuration.h
  147. # Create SSL structure for packages such as ca-certificates which
  148. # contain hard-coded paths to /etc/ssl. Debian does the same.
  149. install -d ${D}${sysconfdir}/ssl
  150. mv ${D}${libdir}/ssl-3/certs \
  151. ${D}${libdir}/ssl-3/private \
  152. ${D}${libdir}/ssl-3/openssl.cnf \
  153. ${D}${sysconfdir}/ssl/
  154. # Although absolute symlinks would be OK for the target, they become
  155. # invalid if native or nativesdk are relocated from sstate.
  156. ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/certs')} ${D}${libdir}/ssl-3/certs
  157. ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/private')} ${D}${libdir}/ssl-3/private
  158. ln -sf ${@oe.path.relative('${libdir}/ssl-3', '${sysconfdir}/ssl/openssl.cnf')} ${D}${libdir}/ssl-3/openssl.cnf
  159. # Generate fipsmodule.cnf in pkg_postinst_ontarget
  160. if ${@bb.utils.contains('PACKAGECONFIG', 'fips', 'true', 'false', d)}; then
  161. rm -f ${D}${libdir}/ssl-3/fipsmodule.cnf
  162. fi
  163. }
  164. do_install:append:class-native () {
  165. create_wrapper ${D}${bindir}/openssl \
  166. OPENSSL_CONF=\${OPENSSL_CONF:-${libdir}/ssl-3/openssl.cnf} \
  167. SSL_CERT_DIR=\${SSL_CERT_DIR:-${libdir}/ssl-3/certs} \
  168. SSL_CERT_FILE=\${SSL_CERT_FILE:-${libdir}/ssl-3/cert.pem} \
  169. OPENSSL_ENGINES=\${OPENSSL_ENGINES:-${libdir}/engines-3} \
  170. OPENSSL_MODULES=\${OPENSSL_MODULES:-${libdir}/ossl-modules}
  171. # Setting ENGINESDIR and MODULESDIR to invalid paths prevents host contamination,
  172. # but also breaks the generated libcrypto.pc file. Post-Fix it manually here.
  173. sed -i 's|^enginesdir=\($.libdir.\)/.*|enginesdir=\1/engines-3|' ${D}${libdir}/pkgconfig/libcrypto.pc
  174. sed -i 's|^modulesdir=\($.libdir.\)/.*|modulesdir=\1/ossl-modules|' ${D}${libdir}/pkgconfig/libcrypto.pc
  175. }
  176. do_install:append:class-nativesdk () {
  177. mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
  178. install -m 644 ${UNPACKDIR}/environment.d-openssl.sh ${D}${SDKPATHNATIVE}/environment-setup.d/openssl.sh
  179. }
  180. PTEST_BUILD_HOST_FILES += "configdata.pm"
  181. PTEST_BUILD_HOST_PATTERN = "perl_version ="
  182. do_install_ptest() {
  183. install -m644 ${S}/Configure ${B}/configdata.pm ${D}${PTEST_PATH}
  184. cp -rf ${S}/Configurations ${S}/external ${D}${PTEST_PATH}/
  185. install -d ${D}${PTEST_PATH}/apps
  186. ln -s ${bindir}/openssl ${D}${PTEST_PATH}/apps
  187. cd ${S}
  188. find test/certs test/ct test/d2i-tests test/recipes test/ocsp-tests test/ssl-tests test/smime-certs -type f -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  189. find apps test -name \*.cnf -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  190. find apps test -name \*.der -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  191. find apps test -name \*.pem -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  192. find util -name \*.p[lm] -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  193. cd ${B}
  194. # Everything but .? (.o and .d)
  195. find test -type f -name \*[^.]? -exec install -m755 -D {} ${D}${PTEST_PATH}/{} \;
  196. find apps test -name \*.cnf -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  197. find apps test -name \*.pem -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  198. find apps test -name \*.srl -exec install -m644 -D {} ${D}${PTEST_PATH}/{} \;
  199. install -m755 ${B}/util/*wrap.* ${D}${PTEST_PATH}/util/
  200. install -m755 ${B}/apps/CA.pl ${D}${PTEST_PATH}/apps/
  201. install -m755 ${S}/test/*.pl ${D}${PTEST_PATH}/test/
  202. install -m755 ${S}/test/shibboleth.pfx ${D}${PTEST_PATH}/test/
  203. install -m755 ${S}/test/*.bin ${D}${PTEST_PATH}/test/
  204. install -m755 ${S}/test/dane*.in ${D}${PTEST_PATH}/test/
  205. install -m755 ${S}/test/smcont*.txt ${D}${PTEST_PATH}/test/
  206. install -m755 ${S}/test/ssl_test.tmpl ${D}${PTEST_PATH}/test/
  207. sed 's|${S}|${PTEST_PATH}|g' -i ${D}${PTEST_PATH}/configdata.pm ${D}${PTEST_PATH}/util/wrap.pl
  208. install -d ${D}${PTEST_PATH}/engines
  209. install -m755 ${B}/engines/dasync.so ${D}${PTEST_PATH}/engines/
  210. install -m755 ${B}/engines/ossltest.so ${D}${PTEST_PATH}/engines/
  211. ln -s ${libdir}/engines-3/loader_attic.so ${D}${PTEST_PATH}/engines/
  212. ln -s ${libdir}/ossl-modules/ ${D}${PTEST_PATH}/providers
  213. }
  214. pkg_postinst_ontarget:${PN}-ossl-module-fips () {
  215. if test -f ${libdir}/ossl-modules/fips.so; then
  216. ${bindir}/openssl fipsinstall -out ${libdir}/ssl-3/fipsmodule.cnf -module ${libdir}/ossl-modules/fips.so
  217. fi
  218. }
  219. # Add the openssl.cnf file to the openssl-conf package. Make the libcrypto
  220. # package RRECOMMENDS on this package. This will enable the configuration
  221. # file to be installed for both the openssl-bin package and the libcrypto
  222. # package since the openssl-bin package depends on the libcrypto package.
  223. PACKAGES =+ "libcrypto libssl openssl-conf ${PN}-engines ${PN}-misc ${PN}-ossl-module-legacy ${PN}-ossl-module-fips"
  224. FILES:libcrypto = "${libdir}/libcrypto${SOLIBS}"
  225. FILES:libssl = "${libdir}/libssl${SOLIBS}"
  226. FILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf \
  227. ${libdir}/ssl-3/openssl.cnf* \
  228. "
  229. FILES:${PN}-engines = "${libdir}/engines-3"
  230. # ${prefix} comes from what we pass into --prefix at configure time (which is used for INSTALLTOP)
  231. FILES:${PN}-engines:append:mingw32:class-nativesdk = " ${prefix}${libdir}/engines-3"
  232. FILES:${PN}-misc = "${libdir}/ssl-3/misc ${bindir}/c_rehash"
  233. FILES:${PN}-ossl-module-legacy = "${libdir}/ossl-modules/legacy.so"
  234. FILES:${PN}-ossl-module-fips = "${libdir}/ossl-modules/fips.so"
  235. FILES:${PN} =+ "${libdir}/ssl-3/* ${libdir}/ossl-modules/"
  236. FILES:${PN}:append:class-nativesdk = " ${SDKPATHNATIVE}/environment-setup.d/openssl.sh"
  237. CONFFILES:openssl-conf = "${sysconfdir}/ssl/openssl.cnf"
  238. RRECOMMENDS:libcrypto += "openssl-conf ${PN}-ossl-module-legacy"
  239. RDEPENDS:${PN}-misc = "perl"
  240. RDEPENDS:${PN}-ptest += "openssl-bin perl perl-modules bash sed openssl-engines openssl-ossl-module-legacy"
  241. RDEPENDS:${PN}-bin += "openssl-conf"
  242. # The test suite is installed stripped
  243. INSANE_SKIP:${PN} = "already-stripped"
  244. BBCLASSEXTEND = "native nativesdk"
  245. CVE_PRODUCT = "openssl:openssl"