Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 1 | SUMMARY = "Mozilla's SSL and TLS implementation" |
| 2 | DESCRIPTION = "Network Security Services (NSS) is a set of libraries \ |
| 3 | designed to support cross-platform development of \ |
| 4 | security-enabled client and server applications. \ |
| 5 | Applications built with NSS can support SSL v2 and v3, \ |
| 6 | TLS, PKCS 5, PKCS 7, PKCS 11, PKCS 12, S/MIME, X.509 \ |
| 7 | v3 certificates, and other security standards." |
| 8 | HOMEPAGE = "http://www.mozilla.org/projects/security/pki/nss/" |
| 9 | SECTION = "libs" |
| 10 | |
| 11 | DEPENDS = "sqlite3 nspr zlib nss-native" |
| 12 | DEPENDS_class-native = "sqlite3-native nspr-native zlib-native" |
| 13 | |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame] | 14 | LICENSE = "(MPL-2.0 & MIT) | (MPL-2.0 & GPL-2.0+ & MIT) | (MPL-2.0 & LGPL-2.1+ & MIT)" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 15 | |
| 16 | LIC_FILES_CHKSUM = "file://nss/COPYING;md5=3b1e88e1b9c0b5a4b2881d46cce06a18 \ |
| 17 | file://nss/lib/freebl/mpi/doc/LICENSE;md5=491f158d09d948466afce85d6f1fe18f \ |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame] | 18 | file://nss/lib/freebl/mpi/doc/LICENSE-MPL;md5=5d425c8f3157dbf212db2ec53d9e5132 \ |
| 19 | file://nss/lib/freebl/verified/Hacl_Poly1305_256.c;beginline=1;endline=22;md5=d4096c1e4421ee56e9e0f441a8161f78" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 20 | |
| 21 | VERSION_DIR = "${@d.getVar('BP').upper().replace('-', '_').replace('.', '_') + '_RTM'}" |
| 22 | |
| 23 | SRC_URI = "http://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${VERSION_DIR}/src/${BP}.tar.gz \ |
| 24 | file://nss.pc.in \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 25 | file://0001-nss-fix-support-cross-compiling.patch \ |
| 26 | file://nss-no-rpath-for-cross-compiling.patch \ |
| 27 | file://nss-fix-incorrect-shebang-of-perl.patch \ |
| 28 | file://disable-Wvarargs-with-clang.patch \ |
| 29 | file://pqg.c-ULL_addend.patch \ |
| 30 | file://blank-cert9.db \ |
| 31 | file://blank-key4.db \ |
| 32 | file://system-pkcs11.txt \ |
| 33 | file://nss-fix-nsinstall-build.patch \ |
| 34 | file://0001-freebl-add-a-configure-option-to-disable-ARM-HW-cryp.patch \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 35 | " |
Andrew Geissler | f103a7f | 2021-05-07 16:09:40 -0500 | [diff] [blame] | 36 | SRC_URI[sha256sum] = "d3175427172e9c3a6f1ebc74452cb791590f28191c6a1a443dbc0d87c9df1126" |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 37 | |
| 38 | UPSTREAM_CHECK_URI = "https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Releases" |
| 39 | UPSTREAM_CHECK_REGEX = "NSS_(?P<pver>.+)_release_notes" |
| 40 | |
| 41 | inherit siteinfo |
| 42 | |
| 43 | TD = "${S}/tentative-dist" |
| 44 | TDS = "${S}/tentative-dist-staging" |
| 45 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 46 | TARGET_CC_ARCH += "${LDFLAGS}" |
| 47 | |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 48 | CFLAGS_append_class-native = " -D_XOPEN_SOURCE " |
| 49 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 50 | do_configure_prepend_libc-musl () { |
| 51 | sed -i -e '/-DHAVE_SYS_CDEFS_H/d' ${S}/nss/lib/dbm/config/config.mk |
| 52 | } |
| 53 | |
Andrew Geissler | 97771a3 | 2021-03-05 15:23:11 -0600 | [diff] [blame] | 54 | do_configure_prepend_powerpc64le_toolchain-clang () { |
| 55 | sed -i -e 's/\-std=c99/\-std=gnu99/g' ${S}/nss/coreconf/command.mk |
| 56 | } |
| 57 | |
| 58 | do_configure_prepend_powerpc64_toolchain-clang () { |
| 59 | sed -i -e 's/\-std=c99/\-std=gnu99/g' ${S}/nss/coreconf/command.mk |
| 60 | } |
| 61 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 62 | do_compile_prepend_class-native() { |
| 63 | export NSPR_INCLUDE_DIR=${STAGING_INCDIR_NATIVE}/nspr |
| 64 | export NSPR_LIB_DIR=${STAGING_LIBDIR_NATIVE} |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | do_compile_prepend_class-nativesdk() { |
| 68 | export LDFLAGS="" |
| 69 | } |
| 70 | |
| 71 | do_compile_prepend_class-native() { |
| 72 | # Need to set RPATH so that chrpath will do its job correctly |
| 73 | RPATH="-Wl,-rpath-link,${STAGING_LIBDIR_NATIVE} -Wl,-rpath-link,${STAGING_BASE_LIBDIR_NATIVE} -Wl,-rpath,${STAGING_LIBDIR_NATIVE} -Wl,-rpath,${STAGING_BASE_LIBDIR_NATIVE}" |
| 74 | } |
| 75 | |
| 76 | do_compile() { |
| 77 | export NSPR_INCLUDE_DIR=${STAGING_INCDIR}/nspr |
| 78 | |
| 79 | export CROSS_COMPILE=1 |
| 80 | export NATIVE_CC="${BUILD_CC}" |
| 81 | # Additional defines needed on Centos 7 |
| 82 | export NATIVE_FLAGS="${BUILD_CFLAGS} -DLINUX -Dlinux" |
| 83 | export BUILD_OPT=1 |
| 84 | |
Andrew Geissler | 97771a3 | 2021-03-05 15:23:11 -0600 | [diff] [blame] | 85 | # POSIX.1-2001 states that the behaviour of getcwd() when passing a null |
| 86 | # pointer as the buf argument, is unspecified. |
| 87 | export NATIVE_FLAGS="${NATIVE_FLAGS} -DGETCWD_CANT_MALLOC" |
| 88 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 89 | export FREEBL_NO_DEPEND=1 |
| 90 | export FREEBL_LOWHASH=1 |
| 91 | |
| 92 | export LIBDIR=${libdir} |
| 93 | export MOZILLA_CLIENT=1 |
| 94 | export NS_USE_GCC=1 |
| 95 | export NSS_USE_SYSTEM_SQLITE=1 |
| 96 | export NSS_ENABLE_ECC=1 |
William A. Kennington III | b95905d | 2021-06-02 12:40:56 -0700 | [diff] [blame] | 97 | export NSS_ENABLE_WERROR=0 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 98 | |
| 99 | ${@bb.utils.contains("TUNE_FEATURES", "crypto", "export NSS_USE_ARM_HW_CRYPTO=1", "", d)} |
| 100 | |
| 101 | export OS_RELEASE=3.4 |
| 102 | export OS_TARGET=Linux |
| 103 | export OS_ARCH=Linux |
| 104 | |
| 105 | if [ "${TARGET_ARCH}" = "powerpc" ]; then |
| 106 | OS_TEST=ppc |
Andrew Geissler | 97771a3 | 2021-03-05 15:23:11 -0600 | [diff] [blame] | 107 | elif [ "${TARGET_ARCH}" = "powerpc64" -o "${TARGET_ARCH}" = "powerpc64le" ]; then |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 108 | OS_TEST=ppc64 |
| 109 | elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then |
| 110 | OS_TEST=mips |
| 111 | elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then |
| 112 | OS_TEST="aarch64" |
| 113 | else |
| 114 | OS_TEST="${TARGET_ARCH}" |
| 115 | fi |
| 116 | |
| 117 | if [ "${SITEINFO_BITS}" = "64" ]; then |
| 118 | export USE_64=1 |
| 119 | elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then |
| 120 | export USE_X32=1 |
| 121 | fi |
| 122 | |
| 123 | export NSS_DISABLE_GTESTS=1 |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 124 | # We can modify CC in the environment, but if we set it via an |
| 125 | # argument to make, nsinstall, a host program, will also build with it! |
| 126 | # |
| 127 | # nss pretty much does its own thing with CFLAGS, so we put them into CC. |
| 128 | # Optimization will get clobbered, but most of the stuff will survive. |
| 129 | # The motivation for this is to point to the correct place for debug |
| 130 | # source files and CFLAGS does that. Nothing uses CCC. |
| 131 | # |
| 132 | export CC="${CC} ${CFLAGS}" |
| 133 | make -C ./nss CCC="${CXX} -g" \ |
| 134 | OS_TEST=${OS_TEST} \ |
Andrew Geissler | 748a483 | 2020-07-24 16:24:21 -0500 | [diff] [blame] | 135 | RPATH="${RPATH}" \ |
| 136 | autobuild |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | do_compile[vardepsexclude] += "SITEINFO_BITS" |
| 140 | |
| 141 | do_install_prepend_class-nativesdk() { |
| 142 | export LDFLAGS="" |
| 143 | } |
| 144 | |
| 145 | do_install() { |
| 146 | export CROSS_COMPILE=1 |
| 147 | export NATIVE_CC="${BUILD_CC}" |
| 148 | export BUILD_OPT=1 |
| 149 | |
| 150 | export FREEBL_NO_DEPEND=1 |
| 151 | |
| 152 | export LIBDIR=${libdir} |
| 153 | export MOZILLA_CLIENT=1 |
| 154 | export NS_USE_GCC=1 |
| 155 | export NSS_USE_SYSTEM_SQLITE=1 |
| 156 | export NSS_ENABLE_ECC=1 |
| 157 | |
| 158 | export OS_RELEASE=3.4 |
| 159 | export OS_TARGET=Linux |
| 160 | export OS_ARCH=Linux |
| 161 | |
| 162 | if [ "${TARGET_ARCH}" = "powerpc" ]; then |
| 163 | OS_TEST=ppc |
Andrew Geissler | 97771a3 | 2021-03-05 15:23:11 -0600 | [diff] [blame] | 164 | elif [ "${TARGET_ARCH}" = "powerpc64" -o "${TARGET_ARCH}" = "powerpc64le" ]; then |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 165 | OS_TEST=ppc64 |
| 166 | elif [ "${TARGET_ARCH}" = "mips" -o "${TARGET_ARCH}" = "mipsel" -o "${TARGET_ARCH}" = "mips64" -o "${TARGET_ARCH}" = "mips64el" ]; then |
| 167 | OS_TEST=mips |
| 168 | elif [ "${TARGET_ARCH}" = "aarch64_be" ]; then |
| 169 | CPU_ARCH=aarch64 |
| 170 | OS_TEST="aarch64" |
| 171 | else |
| 172 | OS_TEST="${TARGET_ARCH}" |
| 173 | fi |
| 174 | if [ "${SITEINFO_BITS}" = "64" ]; then |
| 175 | export USE_64=1 |
| 176 | elif [ "${TARGET_ARCH}" = "x86_64" -a "${SITEINFO_BITS}" = "32" ]; then |
| 177 | export USE_X32=1 |
| 178 | fi |
| 179 | |
| 180 | export NSS_DISABLE_GTESTS=1 |
| 181 | |
| 182 | make -C ./nss \ |
| 183 | CCC="${CXX}" \ |
| 184 | OS_TEST=${OS_TEST} \ |
| 185 | SOURCE_LIB_DIR="${TD}/${libdir}" \ |
| 186 | SOURCE_BIN_DIR="${TD}/${bindir}" \ |
| 187 | install |
| 188 | |
| 189 | install -d ${D}/${libdir}/ |
| 190 | for file in ${S}/dist/*.OBJ/lib/*.so; do |
| 191 | echo "Installing `basename $file`..." |
| 192 | cp $file ${D}/${libdir}/ |
| 193 | done |
| 194 | |
| 195 | for shared_lib in ${TD}/${libdir}/*.so.*; do |
| 196 | if [ -f $shared_lib ]; then |
| 197 | cp $shared_lib ${D}/${libdir} |
| 198 | ln -sf $(basename $shared_lib) ${D}/${libdir}/$(basename $shared_lib .1oe) |
| 199 | fi |
| 200 | done |
| 201 | for shared_lib in ${TD}/${libdir}/*.so; do |
| 202 | if [ -f $shared_lib -a ! -e ${D}/${libdir}/$shared_lib ]; then |
| 203 | cp $shared_lib ${D}/${libdir} |
| 204 | fi |
| 205 | done |
| 206 | |
| 207 | install -d ${D}/${includedir}/nss3 |
| 208 | install -m 644 -t ${D}/${includedir}/nss3 dist/public/nss/* |
| 209 | |
| 210 | install -d ${D}/${bindir} |
| 211 | for binary in ${TD}/${bindir}/*; do |
| 212 | install -m 755 -t ${D}/${bindir} $binary |
| 213 | done |
| 214 | } |
| 215 | |
| 216 | do_install[vardepsexclude] += "SITEINFO_BITS" |
| 217 | |
| 218 | do_install_append() { |
| 219 | # Create empty .chk files for the NSS libraries at build time. They could |
| 220 | # be regenerated at target's boot time. |
| 221 | for file in libsoftokn3.chk libfreebl3.chk libnssdbm3.chk; do |
| 222 | touch ${D}/${libdir}/$file |
| 223 | chmod 755 ${D}/${libdir}/$file |
| 224 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 225 | |
| 226 | install -d ${D}${libdir}/pkgconfig/ |
| 227 | sed 's/%NSS_VERSION%/${PV}/' ${WORKDIR}/nss.pc.in | sed 's/%NSPR_VERSION%/4.9.2/' > ${D}${libdir}/pkgconfig/nss.pc |
| 228 | sed -i s:OEPREFIX:${prefix}:g ${D}${libdir}/pkgconfig/nss.pc |
| 229 | sed -i s:OEEXECPREFIX:${exec_prefix}:g ${D}${libdir}/pkgconfig/nss.pc |
| 230 | sed -i s:OELIBDIR:${libdir}:g ${D}${libdir}/pkgconfig/nss.pc |
| 231 | sed -i s:OEINCDIR:${includedir}/nss3:g ${D}${libdir}/pkgconfig/nss.pc |
| 232 | } |
| 233 | |
| 234 | do_install_append_class-target() { |
| 235 | # It used to call certutil to create a blank certificate with empty password at |
| 236 | # build time, but the checksum of key4.db changes every time when certutil is called. |
| 237 | # It causes non-determinism issue, so provide databases with a blank certificate |
| 238 | # which are originally from output of nss in qemux86-64 build. You can get these |
| 239 | # databases by: |
| 240 | # certutil -N -d sql:/database/path/ --empty-password |
| 241 | install -d ${D}${sysconfdir}/pki/nssdb/ |
| 242 | install -m 0644 ${WORKDIR}/blank-cert9.db ${D}${sysconfdir}/pki/nssdb/cert9.db |
| 243 | install -m 0644 ${WORKDIR}/blank-key4.db ${D}${sysconfdir}/pki/nssdb/key4.db |
| 244 | install -m 0644 ${WORKDIR}/system-pkcs11.txt ${D}${sysconfdir}/pki/nssdb/pkcs11.txt |
| 245 | } |
| 246 | |
| 247 | PACKAGE_WRITE_DEPS += "nss-native" |
Andrew Geissler | d688a01 | 2020-09-18 13:36:00 -0500 | [diff] [blame] | 248 | |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 249 | pkg_postinst_${PN} () { |
Andrew Geissler | d688a01 | 2020-09-18 13:36:00 -0500 | [diff] [blame] | 250 | for I in $D${libdir}/lib*.chk; do |
| 251 | DN=`dirname $I` |
| 252 | BN=`basename $I .chk` |
| 253 | FN=$DN/$BN.so |
| 254 | shlibsign -i $FN |
| 255 | if [ $? -ne 0 ]; then |
| 256 | echo "shlibsign -i $FN failed" |
| 257 | fi |
| 258 | done |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | PACKAGES =+ "${PN}-smime" |
| 262 | FILES_${PN}-smime = "\ |
| 263 | ${bindir}/smime \ |
| 264 | " |
| 265 | |
| 266 | FILES_${PN} = "\ |
| 267 | ${sysconfdir} \ |
| 268 | ${bindir} \ |
| 269 | ${libdir}/lib*.chk \ |
| 270 | ${libdir}/lib*.so \ |
| 271 | " |
| 272 | |
| 273 | FILES_${PN}-dev = "\ |
| 274 | ${libdir}/nss \ |
| 275 | ${libdir}/pkgconfig/* \ |
| 276 | ${includedir}/* \ |
| 277 | " |
| 278 | |
| 279 | RDEPENDS_${PN}-smime = "perl" |
| 280 | |
| 281 | BBCLASSEXTEND = "native nativesdk" |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 282 | |
| 283 | # CVE-2006-5201 affects only Sun Solaris |
| 284 | CVE_CHECK_WHITELIST += "CVE-2006-5201" |