Gentoo Archives: gentoo-commits

From: Joonas Niilola <juippis@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/nss/
Date: Sat, 25 Jun 2022 09:32:49
Message-Id: 1656149562.c30fc7d7ea39cb59ef460a98b2620c07d55c99df.juippis@gentoo
1 commit: c30fc7d7ea39cb59ef460a98b2620c07d55c99df
2 Author: Joonas Niilola <juippis <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jun 25 09:19:19 2022 +0000
4 Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org>
5 CommitDate: Sat Jun 25 09:32:42 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c30fc7d7
7
8 dev-libs/nss: add 3.80
9
10 - default '+utils' on, as it's not obvious where pkcs11 support
11 comes from.
12
13 Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>
14
15 dev-libs/nss/Manifest | 1 +
16 dev-libs/nss/nss-3.80.ebuild | 389 +++++++++++++++++++++++++++++++++++++++++++
17 2 files changed, 390 insertions(+)
18
19 diff --git a/dev-libs/nss/Manifest b/dev-libs/nss/Manifest
20 index e889d96a707f..3e43feb94e2e 100644
21 --- a/dev-libs/nss/Manifest
22 +++ b/dev-libs/nss/Manifest
23 @@ -1,3 +1,4 @@
24 DIST nss-3.68.4.tar.gz 82409303 BLAKE2B a3cf572e82ce29dbc77e9356e0db425170f7294f1468755843746539663fe486089660e1c1b379d0184003d9ccf57db6cf0b2c161d7038301c1cb5028175b16d SHA512 f97b63a9f8218f8fbd7b5d48c084b8166366d02cd50aac69a22d56324d2fea01c49d074e51430bd128f510c733085f3f43c9739ce4073a07a5666675e0ef3b15
25 DIST nss-3.79.tar.gz 84830113 BLAKE2B f558592bf0983d3c44f11e079512865d310b4f4c225bcc8e2058cb6a4a721d471c575965a1c2b5d0a130dcf27840da3d7b0ee8aa27fc63791414e22ef7804fa8 SHA512 d3311da3bd0e6907760390221c1307a63d84dd8ad9b85dbfdbf59fe4678341c9856b6f93235731999a1236c98dc0ac66d2dc023eb439cb696f73509dae70c41d
26 +DIST nss-3.80.tar.gz 84841312 BLAKE2B 6244193849a9277bc68c5225b4f836309bdf07bc415b23793d14c5343f5236b27bb7552fa7fb9975f410ea4732e9fc37185fee7bb950bf5d15b478f8bdec3ba7 SHA512 db05df17fea12bf3ec83882bf761663f8f10f3a8ce9a33519c7985d6003945068adb658250cf05d8b598c34ecb4ba7ea5cdc468d9cc7bc786aedb72d7be65923
27 DIST nss-cacert-class1-class3-r2.patch 21925 BLAKE2B 7627ff9a09f084c19d72d0490676865e3cab3ca7c920ae1ce4bea2db664f37fd0aa84fcda919809a516891ab2a62e2e7a43a9d6ada4c231adfe4c216525fac7d SHA512 1ce6ff9ab310aaca9005eafb461338b291df8523cc7044e096cd75774ce746c26eed19ec6bb2643c6c67f94650f2f309463492d80a90568f38ce2557f8ada2f4
28
29 diff --git a/dev-libs/nss/nss-3.80.ebuild b/dev-libs/nss/nss-3.80.ebuild
30 new file mode 100644
31 index 000000000000..b273c86582a8
32 --- /dev/null
33 +++ b/dev-libs/nss/nss-3.80.ebuild
34 @@ -0,0 +1,389 @@
35 +# Copyright 1999-2022 Gentoo Authors
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +EAPI=8
39 +
40 +inherit flag-o-matic multilib toolchain-funcs multilib-minimal
41 +
42 +NSPR_VER="4.34"
43 +RTM_NAME="NSS_${PV//./_}_RTM"
44 +
45 +DESCRIPTION="Mozilla's Network Security Services library that implements PKI support"
46 +HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS"
47 +SRC_URI="https://archive.mozilla.org/pub/security/nss/releases/${RTM_NAME}/src/${P}.tar.gz
48 + cacert? ( https://dev.gentoo.org/~whissi/dist/ca-certificates/nss-cacert-class1-class3-r2.patch )"
49 +
50 +LICENSE="|| ( MPL-2.0 GPL-2 LGPL-2.1 )"
51 +SLOT="0"
52 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-solaris ~x86-solaris"
53 +IUSE="cacert test +utils cpu_flags_ppc_altivec cpu_flags_ppc_vsx"
54 +RESTRICT="!test? ( test )"
55 +# pkg-config called by nss-config -> virtual/pkgconfig in RDEPEND
56 +RDEPEND="
57 + >=dev-libs/nspr-${NSPR_VER}[${MULTILIB_USEDEP}]
58 + >=dev-db/sqlite-3.8.2[${MULTILIB_USEDEP}]
59 + >=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}]
60 + virtual/pkgconfig
61 +"
62 +DEPEND="${RDEPEND}"
63 +BDEPEND="dev-lang/perl"
64 +
65 +S="${WORKDIR}/${P}/${PN}"
66 +
67 +MULTILIB_CHOST_TOOLS=(
68 + /usr/bin/nss-config
69 +)
70 +
71 +PATCHES=(
72 + # Custom changes for gentoo
73 + "${FILESDIR}/${PN}-3.53-gentoo-fixups.patch"
74 + "${FILESDIR}/${PN}-3.21-gentoo-fixup-warnings.patch"
75 + "${FILESDIR}/${PN}-3.23-hppa-byte_order.patch"
76 + "${FILESDIR}/${PN}-3.79-gcc-13.patch"
77 +)
78 +
79 +src_prepare() {
80 + default
81 +
82 + if use cacert ; then
83 + eapply -p2 "${DISTDIR}"/nss-cacert-class1-class3-r2.patch
84 + fi
85 +
86 + pushd coreconf >/dev/null || die
87 + # hack nspr paths
88 + echo 'INCLUDES += -I$(DIST)/include/dbm' \
89 + >> headers.mk || die "failed to append include"
90 +
91 + # modify install path
92 + sed -e '/CORE_DEPTH/s:SOURCE_PREFIX.*$:SOURCE_PREFIX = $(CORE_DEPTH)/dist:' \
93 + -i source.mk || die
94 +
95 + # Respect LDFLAGS
96 + sed -i -e 's/\$(MKSHLIB) -o/\$(MKSHLIB) \$(LDFLAGS) -o/g' rules.mk
97 +
98 + popd >/dev/null || die
99 +
100 + # Fix pkgconfig file for Prefix
101 + sed -i -e "/^PREFIX =/s:= /usr:= ${EPREFIX}/usr:" \
102 + config/Makefile || die
103 +
104 + # use host shlibsign if need be #436216
105 + if tc-is-cross-compiler ; then
106 + sed -i \
107 + -e 's:"${2}"/shlibsign:shlibsign:' \
108 + cmd/shlibsign/sign.sh || die
109 + fi
110 +
111 + # dirty hack
112 + sed -i -e "/CRYPTOLIB/s:\$(SOFTOKEN_LIB_DIR):../freebl/\$(OBJDIR):" \
113 + lib/ssl/config.mk || die
114 + sed -i -e "/CRYPTOLIB/s:\$(SOFTOKEN_LIB_DIR):../../lib/freebl/\$(OBJDIR):" \
115 + cmd/platlibs.mk || die
116 +
117 + multilib_copy_sources
118 +
119 + strip-flags
120 +}
121 +
122 +multilib_src_configure() {
123 + # Ensure we stay multilib aware
124 + sed -i -e "/@libdir@/ s:lib64:$(get_libdir):" config/Makefile || die
125 +}
126 +
127 +nssarch() {
128 + # Most of the arches are the same as $ARCH
129 + local t=${1:-${CHOST}}
130 + case ${t} in
131 + *86*-pc-solaris2*) echo "i86pc" ;;
132 + aarch64*) echo "aarch64" ;;
133 + hppa*) echo "parisc" ;;
134 + i?86*) echo "i686" ;;
135 + x86_64*) echo "x86_64" ;;
136 + *) tc-arch ${t} ;;
137 + esac
138 +}
139 +
140 +nssbits() {
141 + local cc cppflags="${1}CPPFLAGS" cflags="${1}CFLAGS"
142 + if [[ ${1} == BUILD_ ]]; then
143 + cc=$(tc-getBUILD_CC)
144 + else
145 + cc=$(tc-getCC)
146 + fi
147 + echo > "${T}"/test.c || die
148 + ${cc} ${!cppflags} ${!cflags} -c "${T}"/test.c -o "${T}/${1}test.o" || die
149 + case $(file "${T}/${1}test.o") in
150 + *32-bit*x86-64*) echo USE_X32=1;;
151 + *64-bit*|*ppc64*|*x86_64*) echo USE_64=1;;
152 + *32-bit*|*ppc*|*i386*) ;;
153 + *) die "Failed to detect whether ${cc} builds 64bits or 32bits, disable distcc if you're using it, please";;
154 + esac
155 +}
156 +
157 +multilib_src_compile() {
158 + # use ABI to determine bit'ness, or fallback if unset
159 + local buildbits mybits
160 + case "${ABI}" in
161 + n32) mybits="USE_N32=1";;
162 + x32) mybits="USE_X32=1";;
163 + s390x|*64) mybits="USE_64=1";;
164 + ${DEFAULT_ABI})
165 + einfo "Running compilation test to determine bit'ness"
166 + mybits=$(nssbits)
167 + ;;
168 + esac
169 + # bitness of host may differ from target
170 + if tc-is-cross-compiler; then
171 + buildbits=$(nssbits BUILD_)
172 + fi
173 +
174 + local makeargs=(
175 + CC="$(tc-getCC)"
176 + CCC="$(tc-getCXX)"
177 + AR="$(tc-getAR) rc \$@"
178 + RANLIB="$(tc-getRANLIB)"
179 + OPTIMIZER=
180 + ${mybits}
181 + )
182 +
183 + # Take care of nspr settings #436216
184 + local myCPPFLAGS="${CPPFLAGS} $($(tc-getPKG_CONFIG) nspr --cflags)"
185 + unset NSPR_INCLUDE_DIR
186 +
187 + export NSS_ALLOW_SSLKEYLOGFILE=1
188 + export NSS_ENABLE_WERROR=0 #567158
189 + export BUILD_OPT=1
190 + export NSS_USE_SYSTEM_SQLITE=1
191 + export NSDISTMODE=copy
192 + export FREEBL_NO_DEPEND=1
193 + export FREEBL_LOWHASH=1
194 + export NSS_SEED_ONLY_DEV_URANDOM=1
195 + export USE_SYSTEM_ZLIB=1
196 + export ZLIB_LIBS=-lz
197 + export ASFLAGS=""
198 + # Fix build failure on arm64
199 + export NS_USE_GCC=1
200 + # Detect compiler type and set proper environment value
201 + if tc-is-gcc; then
202 + export CC_IS_GCC=1
203 + elif tc-is-clang; then
204 + export CC_IS_CLANG=1
205 + fi
206 +
207 + export NSS_DISABLE_GTESTS=$(usex !test 1 0)
208 +
209 + # explicitly disable altivec/vsx if not requested
210 + # https://bugs.gentoo.org/789114
211 + case ${ARCH} in
212 + ppc*)
213 + use cpu_flags_ppc_altivec || export NSS_DISABLE_ALTIVEC=1
214 + use cpu_flags_ppc_vsx || export NSS_DISABLE_CRYPTO_VSX=1
215 + ;;
216 + esac
217 +
218 + local d
219 +
220 + # Build the host tools first.
221 + LDFLAGS="${BUILD_LDFLAGS}" \
222 + XCFLAGS="${BUILD_CFLAGS}" \
223 + NSPR_LIB_DIR="${T}/fakedir" \
224 + emake -C coreconf \
225 + CC="$(tc-getBUILD_CC)" \
226 + ${buildbits-${mybits}}
227 + makeargs+=( NSINSTALL="${PWD}/$(find -type f -name nsinstall)" )
228 +
229 + # Then build the target tools.
230 + for d in . lib/dbm ; do
231 + CPPFLAGS="${myCPPFLAGS}" \
232 + XCFLAGS="${CFLAGS} ${CPPFLAGS}" \
233 + NSPR_LIB_DIR="${T}/fakedir" \
234 + emake "${makeargs[@]}" -C ${d} OS_TEST="$(nssarch)"
235 + done
236 +}
237 +
238 +multilib_src_test() {
239 + einfo "Tests can take a *long* time, especially on a multilib system."
240 + einfo "30-45+ minutes per lib configuration. Bug #852755"
241 +
242 + # https://www.linuxfromscratch.org/blfs/view/svn/postlfs/nss.html
243 + # https://firefox-source-docs.mozilla.org/security/nss/legacy/nss_sources_building_testing/index.html#running_the_nss_test_suite
244 + # https://www-archive.mozilla.org/projects/security/pki/nss/testnss_32.html (older)
245 + export BUILD_OPT=1
246 + export HOST="localhost"
247 + export DOMSUF="localdomain"
248 + export USE_IP=TRUE
249 + export IP_ADDRESS="127.0.0.1"
250 +
251 + NSINSTALL="${PWD}/$(find -type f -name nsinstall)"
252 +
253 + cd "${BUILD_DIR}"/tests || die
254 + # Hack to get current objdir (prefixed dir where built binaries are)
255 + # Without this, at least multilib tests go wrong when building the amd64 variant
256 + # after x86.
257 + local objdir=$(find "${BUILD_DIR}"/dist -maxdepth 1 -iname Linux* | rev | cut -d/ -f1 | rev)
258 +
259 + # Can tweak to a subset of tests in future if we need to, but would prefer not
260 + OBJDIR="${objdir}" DIST="${BUILD_DIR}/dist" MOZILLA_ROOT="${BUILD_DIR}" ./all.sh || die
261 +}
262 +
263 +# Altering these 3 libraries breaks the CHK verification.
264 +# All of the following cause it to break:
265 +# - stripping
266 +# - prelink
267 +# - ELF signing
268 +# http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn6.html
269 +# Either we have to NOT strip them, or we have to forcibly resign after
270 +# stripping.
271 +#local_libdir="$(get_libdir)"
272 +#export STRIP_MASK="
273 +# */${local_libdir}/libfreebl3.so*
274 +# */${local_libdir}/libnssdbm3.so*
275 +# */${local_libdir}/libsoftokn3.so*"
276 +
277 +export NSS_CHK_SIGN_LIBS="freebl3 nssdbm3 softokn3"
278 +
279 +generate_chk() {
280 + local shlibsign="$1"
281 + local libdir="$2"
282 + einfo "Resigning core NSS libraries for FIPS validation"
283 + shift 2
284 + local i
285 + for i in ${NSS_CHK_SIGN_LIBS} ; do
286 + local libname=lib${i}.so
287 + local chkname=lib${i}.chk
288 + "${shlibsign}" \
289 + -i "${libdir}"/${libname} \
290 + -o "${libdir}"/${chkname}.tmp \
291 + && mv -f \
292 + "${libdir}"/${chkname}.tmp \
293 + "${libdir}"/${chkname} \
294 + || die "Failed to sign ${libname}"
295 + done
296 +}
297 +
298 +cleanup_chk() {
299 + local libdir="$1"
300 + shift 1
301 + local i
302 + for i in ${NSS_CHK_SIGN_LIBS} ; do
303 + local libfname="${libdir}/lib${i}.so"
304 + # If the major version has changed, then we have old chk files.
305 + [ ! -f "${libfname}" -a -f "${libfname}.chk" ] \
306 + && rm -f "${libfname}.chk"
307 + done
308 +}
309 +
310 +multilib_src_install() {
311 + pushd dist >/dev/null || die
312 +
313 + dodir /usr/$(get_libdir)
314 + cp -L */lib/*$(get_libname) "${ED}"/usr/$(get_libdir) || die "copying shared libs failed"
315 + local i
316 + for i in crmf freebl nssb nssckfw ; do
317 + cp -L */lib/lib${i}.a "${ED}"/usr/$(get_libdir) || die "copying libs failed"
318 + done
319 +
320 + # Install nss-config and pkgconfig file
321 + dodir /usr/bin
322 + cp -L */bin/nss-config "${ED}"/usr/bin || die
323 + dodir /usr/$(get_libdir)/pkgconfig
324 + cp -L */lib/pkgconfig/nss.pc "${ED}"/usr/$(get_libdir)/pkgconfig || die
325 +
326 + # create an nss-softokn.pc from nss.pc for libfreebl and some private headers
327 + # bug 517266
328 + sed -e 's#Libs:#Libs: -lfreebl#' \
329 + -e 's#Cflags:#Cflags: -I${includedir}/private#' \
330 + */lib/pkgconfig/nss.pc >"${ED}"/usr/$(get_libdir)/pkgconfig/nss-softokn.pc \
331 + || die "could not create nss-softokn.pc"
332 +
333 + # all the include files
334 + insinto /usr/include/nss
335 + doins public/nss/*.{h,api}
336 + insinto /usr/include/nss/private
337 + doins private/nss/{blapi,alghmac,cmac}.h
338 +
339 + popd >/dev/null || die
340 +
341 + local f nssutils
342 + # Always enabled because we need it for chk generation.
343 + nssutils=( shlibsign )
344 +
345 + if multilib_is_native_abi ; then
346 + if use utils; then
347 + # The tests we do not need to install.
348 + #nssutils_test="bltest crmftest dbtest dertimetest
349 + #fipstest remtest sdrtest"
350 + # checkcert utils has been removed in nss-3.22:
351 + # https://bugzilla.mozilla.org/show_bug.cgi?id=1187545
352 + # https://hg.mozilla.org/projects/nss/rev/df1729d37870
353 + # certcgi has been removed in nss-3.36:
354 + # https://bugzilla.mozilla.org/show_bug.cgi?id=1426602
355 + nssutils+=(
356 + addbuiltin
357 + atob
358 + baddbdir
359 + btoa
360 + certutil
361 + cmsutil
362 + conflict
363 + crlutil
364 + derdump
365 + digest
366 + makepqg
367 + mangle
368 + modutil
369 + multinit
370 + nonspr10
371 + ocspclnt
372 + oidcalc
373 + p7content
374 + p7env
375 + p7sign
376 + p7verify
377 + pk11mode
378 + pk12util
379 + pp
380 + rsaperf
381 + selfserv
382 + signtool
383 + signver
384 + ssltap
385 + strsclnt
386 + symkeyutil
387 + tstclnt
388 + vfychain
389 + vfyserv
390 + )
391 + # install man-pages for utils (bug #516810)
392 + doman doc/nroff/*.1
393 + fi
394 + pushd dist/*/bin >/dev/null || die
395 + for f in ${nssutils[@]}; do
396 + dobin ${f}
397 + done
398 + popd >/dev/null || die
399 + fi
400 +}
401 +
402 +pkg_postinst() {
403 + multilib_pkg_postinst() {
404 + # We must re-sign the libraries AFTER they are stripped.
405 + local shlibsign="${EROOT}/usr/bin/shlibsign"
406 + # See if we can execute it (cross-compiling & such). #436216
407 + "${shlibsign}" -h >&/dev/null
408 + if [[ $? -gt 1 ]] ; then
409 + shlibsign="shlibsign"
410 + fi
411 + generate_chk "${shlibsign}" "${EROOT}"/usr/$(get_libdir)
412 + }
413 +
414 + multilib_foreach_abi multilib_pkg_postinst
415 +}
416 +
417 +pkg_postrm() {
418 + multilib_pkg_postrm() {
419 + cleanup_chk "${EROOT}"/usr/$(get_libdir)
420 + }
421 +
422 + multilib_foreach_abi multilib_pkg_postrm
423 +}