Line 0
Link Here
|
|
|
1 |
# Copyright 1999-2015 Gentoo Foundation |
2 |
# Distributed under the terms of the GNU General Public License v2 |
3 |
# $Header: /var/cvsroot/gentoo-x86/dev-libs/nss/nss-3.17.4.ebuild,v 1.3 2015/03/26 11:36:48 ago Exp $ |
4 |
|
5 |
EAPI=5 |
6 |
inherit eutils flag-o-matic multilib toolchain-funcs multilib-minimal |
7 |
|
8 |
NSPR_VER="4.10.6-r1" |
9 |
RTM_NAME="NSS_${PV//./_}_RTM" |
10 |
# Rev of https://git.fedorahosted.org/cgit/nss-pem.git |
11 |
PEM_GIT_REV="015ae754dd9f6fbcd7e52030ec9732eb27fc06a8" |
12 |
PEM_P="${PN}-pem-${PEM_GIT_REV}" |
13 |
|
14 |
DESCRIPTION="Mozilla's Network Security Services library that implements PKI support" |
15 |
HOMEPAGE="http://www.mozilla.org/projects/security/pki/nss/" |
16 |
SRC_URI="ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${RTM_NAME}/src/${P}.tar.gz |
17 |
cacert? ( http://dev.gentoo.org/~anarchy/patches/${PN}-3.14.1-add_spi+cacerts_ca_certs.patch ) |
18 |
nss-pem? ( https://git.fedorahosted.org/cgit/nss-pem.git/snapshot/${PEM_P}.tar.bz2 )" |
19 |
|
20 |
LICENSE="|| ( MPL-2.0 GPL-2 LGPL-2.1 )" |
21 |
SLOT="0" |
22 |
KEYWORDS="amd64 arm ~mips ppc x86" |
23 |
IUSE="+cacert +nss-pem utils" |
24 |
|
25 |
DEPEND=">=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}] |
26 |
>=dev-libs/nspr-${NSPR_VER}[${MULTILIB_USEDEP}]" |
27 |
RDEPEND=">=dev-libs/nspr-${NSPR_VER}[${MULTILIB_USEDEP}] |
28 |
>=dev-db/sqlite-3.8.2[${MULTILIB_USEDEP}] |
29 |
>=sys-libs/zlib-1.2.8-r1[${MULTILIB_USEDEP}] |
30 |
abi_x86_32? ( |
31 |
!<=app-emulation/emul-linux-x86-baselibs-20140508-r12 |
32 |
!app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] |
33 |
)" |
34 |
|
35 |
RESTRICT="test" |
36 |
|
37 |
S="${WORKDIR}/${P}/${PN}" |
38 |
|
39 |
MULTILIB_CHOST_TOOLS=( |
40 |
/usr/bin/nss-config |
41 |
) |
42 |
|
43 |
src_unpack() { |
44 |
unpack ${A} |
45 |
if use nss-pem ; then |
46 |
mv "${PEM_P}"/nss/lib/ckfw/pem/ "${S}"/lib/ckfw/ || die |
47 |
fi |
48 |
} |
49 |
|
50 |
src_prepare() { |
51 |
# Custom changes for gentoo |
52 |
epatch "${FILESDIR}/${PN}-3.17.1-gentoo-fixups.patch" |
53 |
epatch "${FILESDIR}/${PN}-3.15-gentoo-fixup-warnings.patch" |
54 |
use cacert && epatch "${DISTDIR}/${PN}-3.14.1-add_spi+cacerts_ca_certs.patch" |
55 |
use nss-pem && epatch "${FILESDIR}/${PN}-3.15.4-enable-pem.patch" |
56 |
epatch "${FILESDIR}/nss-3.14.2-solaris-gcc.patch" |
57 |
epatch "${FILESDIR}/nss-3.16-musl.patch" |
58 |
|
59 |
pushd coreconf >/dev/null || die |
60 |
# hack nspr paths |
61 |
echo 'INCLUDES += -I$(DIST)/include/dbm' \ |
62 |
>> headers.mk || die "failed to append include" |
63 |
|
64 |
# modify install path |
65 |
sed -e '/CORE_DEPTH/s:SOURCE_PREFIX.*$:SOURCE_PREFIX = $(CORE_DEPTH)/dist:' \ |
66 |
-i source.mk || die |
67 |
|
68 |
# Respect LDFLAGS |
69 |
sed -i -e 's/\$(MKSHLIB) -o/\$(MKSHLIB) \$(LDFLAGS) -o/g' rules.mk |
70 |
popd >/dev/null || die |
71 |
|
72 |
# Fix pkgconfig file for Prefix |
73 |
sed -i -e "/^PREFIX =/s:= /usr:= ${EPREFIX}/usr:" \ |
74 |
config/Makefile || die |
75 |
|
76 |
# use host shlibsign if need be #436216 |
77 |
if tc-is-cross-compiler ; then |
78 |
sed -i \ |
79 |
-e 's:"${2}"/shlibsign:shlibsign:' \ |
80 |
cmd/shlibsign/sign.sh || die |
81 |
fi |
82 |
|
83 |
# dirty hack |
84 |
sed -i -e "/CRYPTOLIB/s:\$(SOFTOKEN_LIB_DIR):../freebl/\$(OBJDIR):" \ |
85 |
lib/ssl/config.mk || die |
86 |
sed -i -e "/CRYPTOLIB/s:\$(SOFTOKEN_LIB_DIR):../../lib/freebl/\$(OBJDIR):" \ |
87 |
cmd/platlibs.mk || die |
88 |
|
89 |
multilib_copy_sources |
90 |
|
91 |
strip-flags |
92 |
} |
93 |
|
94 |
multilib_src_configure() { |
95 |
# Ensure we stay multilib aware |
96 |
sed -i -e "/@libdir@/ s:lib64:$(get_libdir):" config/Makefile || die |
97 |
} |
98 |
|
99 |
nssarch() { |
100 |
# Most of the arches are the same as $ARCH |
101 |
local t=${1:-${CHOST}} |
102 |
case ${t} in |
103 |
aarch64*)echo "aarch64";; |
104 |
hppa*) echo "parisc";; |
105 |
i?86*) echo "i686";; |
106 |
x86_64*) echo "x86_64";; |
107 |
*) tc-arch ${t};; |
108 |
esac |
109 |
} |
110 |
|
111 |
nssbits() { |
112 |
local cc cppflags="${1}CPPFLAGS" cflags="${1}CFLAGS" |
113 |
if [[ ${1} == BUILD_ ]]; then |
114 |
cc=$(tc-getBUILD_CC) |
115 |
else |
116 |
cc=$(tc-getCC) |
117 |
fi |
118 |
echo > "${T}"/test.c || die |
119 |
${cc} ${!cppflags} ${!cflags} -c "${T}"/test.c -o "${T}/${1}test.o" || die |
120 |
case $(file "${T}/${1}test.o") in |
121 |
*32-bit*x86-64*) echo USE_X32=1;; |
122 |
*64-bit*|*ppc64*|*x86_64*) echo USE_64=1;; |
123 |
*32-bit*|*ppc*|*i386*) ;; |
124 |
*) die "Failed to detect whether ${cc} builds 64bits or 32bits, disable distcc if you're using it, please";; |
125 |
esac |
126 |
} |
127 |
|
128 |
multilib_src_compile() { |
129 |
# use ABI to determine bit'ness, or fallback if unset |
130 |
local buildbits mybits |
131 |
case "${ABI}" in |
132 |
n32) mybits="USE_N32=1";; |
133 |
x32) mybits="USE_X32=1";; |
134 |
s390x|*64) mybits="USE_64=1";; |
135 |
${DEFAULT_ABI}) |
136 |
einfo "Running compilation test to determine bit'ness" |
137 |
mybits=$(nssbits) |
138 |
;; |
139 |
esac |
140 |
# bitness of host may differ from target |
141 |
if tc-is-cross-compiler; then |
142 |
buildbits=$(nssbits BUILD_) |
143 |
fi |
144 |
|
145 |
local makeargs=( |
146 |
CC="$(tc-getCC)" |
147 |
AR="$(tc-getAR) rc \$@" |
148 |
RANLIB="$(tc-getRANLIB)" |
149 |
OPTIMIZER= |
150 |
${mybits} |
151 |
) |
152 |
|
153 |
# Take care of nspr settings #436216 |
154 |
local myCPPFLAGS="${CPPFLAGS} $($(tc-getPKG_CONFIG) nspr --cflags)" |
155 |
unset NSPR_INCLUDE_DIR |
156 |
|
157 |
# Do not let `uname` be used. |
158 |
if use kernel_linux ; then |
159 |
makeargs+=( |
160 |
OS_TARGET=Linux |
161 |
OS_RELEASE=2.6 |
162 |
OS_TEST="$(nssarch)" |
163 |
) |
164 |
fi |
165 |
|
166 |
export BUILD_OPT=1 |
167 |
export NSS_USE_SYSTEM_SQLITE=1 |
168 |
export NSDISTMODE=copy |
169 |
export NSS_ENABLE_ECC=1 |
170 |
export FREEBL_NO_DEPEND=1 |
171 |
export ASFLAGS="" |
172 |
|
173 |
local d |
174 |
|
175 |
# Build the host tools first. |
176 |
LDFLAGS="${BUILD_LDFLAGS}" \ |
177 |
XCFLAGS="${BUILD_CFLAGS}" \ |
178 |
NSPR_LIB_DIR="${T}/fakedir" \ |
179 |
emake -j1 -C coreconf \ |
180 |
CC="$(tc-getBUILD_CC)" \ |
181 |
${buildbits:-${mybits}} |
182 |
makeargs+=( NSINSTALL="${PWD}/$(find -type f -name nsinstall)" ) |
183 |
|
184 |
# Then build the target tools. |
185 |
for d in . lib/dbm ; do |
186 |
CPPFLAGS="${myCPPFLAGS}" \ |
187 |
XCFLAGS="${CFLAGS} ${CPPFLAGS}" \ |
188 |
NSPR_LIB_DIR="${T}/fakedir" \ |
189 |
emake -j1 "${makeargs[@]}" -C ${d} |
190 |
done |
191 |
} |
192 |
|
193 |
# Altering these 3 libraries breaks the CHK verification. |
194 |
# All of the following cause it to break: |
195 |
# - stripping |
196 |
# - prelink |
197 |
# - ELF signing |
198 |
# http://www.mozilla.org/projects/security/pki/nss/tech-notes/tn6.html |
199 |
# Either we have to NOT strip them, or we have to forcibly resign after |
200 |
# stripping. |
201 |
#local_libdir="$(get_libdir)" |
202 |
#export STRIP_MASK=" |
203 |
# */${local_libdir}/libfreebl3.so* |
204 |
# */${local_libdir}/libnssdbm3.so* |
205 |
# */${local_libdir}/libsoftokn3.so*" |
206 |
|
207 |
export NSS_CHK_SIGN_LIBS="freebl3 nssdbm3 softokn3" |
208 |
|
209 |
generate_chk() { |
210 |
local shlibsign="$1" |
211 |
local libdir="$2" |
212 |
einfo "Resigning core NSS libraries for FIPS validation" |
213 |
shift 2 |
214 |
local i |
215 |
for i in ${NSS_CHK_SIGN_LIBS} ; do |
216 |
local libname=lib${i}.so |
217 |
local chkname=lib${i}.chk |
218 |
"${shlibsign}" \ |
219 |
-i "${libdir}"/${libname} \ |
220 |
-o "${libdir}"/${chkname}.tmp \ |
221 |
&& mv -f \ |
222 |
"${libdir}"/${chkname}.tmp \ |
223 |
"${libdir}"/${chkname} \ |
224 |
|| die "Failed to sign ${libname}" |
225 |
done |
226 |
} |
227 |
|
228 |
cleanup_chk() { |
229 |
local libdir="$1" |
230 |
shift 1 |
231 |
local i |
232 |
for i in ${NSS_CHK_SIGN_LIBS} ; do |
233 |
local libfname="${libdir}/lib${i}.so" |
234 |
# If the major version has changed, then we have old chk files. |
235 |
[ ! -f "${libfname}" -a -f "${libfname}.chk" ] \ |
236 |
&& rm -f "${libfname}.chk" |
237 |
done |
238 |
} |
239 |
|
240 |
multilib_src_install() { |
241 |
pushd dist >/dev/null || die |
242 |
|
243 |
dodir /usr/$(get_libdir) |
244 |
cp -L */lib/*$(get_libname) "${ED}"/usr/$(get_libdir) || die "copying shared libs failed" |
245 |
cp -L -t "${ED}"/usr/$(get_libdir) */lib/{libcrmf,libfreebl}.a || die "copying libs failed" |
246 |
|
247 |
# Install nss-config and pkgconfig file |
248 |
dodir /usr/bin |
249 |
cp -L */bin/nss-config "${ED}"/usr/bin || die |
250 |
dodir /usr/$(get_libdir)/pkgconfig |
251 |
cp -L */lib/pkgconfig/nss.pc "${ED}"/usr/$(get_libdir)/pkgconfig || die |
252 |
|
253 |
# create an nss-softokn.pc from nss.pc for libfreebl and some private headers |
254 |
# bug 517266 |
255 |
sed -e 's#Libs:#Libs: -lfreebl#' \ |
256 |
-e 's#Cflags:#Cflags: -I${includedir}/private#' \ |
257 |
*/lib/pkgconfig/nss.pc >"${ED}"/usr/$(get_libdir)/pkgconfig/nss-softokn.pc \ |
258 |
|| die "could not create nss-softokn.pc" |
259 |
|
260 |
# all the include files |
261 |
insinto /usr/include/nss |
262 |
doins public/nss/*.h |
263 |
insinto /usr/include/nss/private |
264 |
doins private/nss/{blapi,alghmac}.h |
265 |
|
266 |
popd >/dev/null || die |
267 |
|
268 |
local f nssutils |
269 |
# Always enabled because we need it for chk generation. |
270 |
nssutils="shlibsign" |
271 |
|
272 |
if multilib_is_native_abi ; then |
273 |
if use utils; then |
274 |
# The tests we do not need to install. |
275 |
#nssutils_test="bltest crmftest dbtest dertimetest |
276 |
#fipstest remtest sdrtest" |
277 |
nssutils="addbuiltin atob baddbdir btoa certcgi certutil checkcert |
278 |
cmsutil conflict crlutil derdump digest makepqg mangle modutil multinit |
279 |
nonspr10 ocspclnt oidcalc p7content p7env p7sign p7verify pk11mode |
280 |
pk12util pp rsaperf selfserv shlibsign signtool signver ssltap strsclnt |
281 |
symkeyutil tstclnt vfychain vfyserv" |
282 |
fi |
283 |
pushd dist/*/bin >/dev/null || die |
284 |
for f in ${nssutils}; do |
285 |
dobin ${f} |
286 |
done |
287 |
popd >/dev/null || die |
288 |
fi |
289 |
|
290 |
# Prelink breaks the CHK files. We don't have any reliable way to run |
291 |
# shlibsign after prelink. |
292 |
local l libs=() liblist |
293 |
for l in ${NSS_CHK_SIGN_LIBS} ; do |
294 |
libs+=("${EPREFIX}/usr/$(get_libdir)/lib${l}.so") |
295 |
done |
296 |
liblist=$(printf '%s:' "${libs[@]}") |
297 |
echo -e "PRELINK_PATH_MASK=${liblist%:}" > "${T}/90nss-${ABI}" |
298 |
doenvd "${T}/90nss-${ABI}" |
299 |
} |
300 |
|
301 |
pkg_postinst() { |
302 |
multilib_pkg_postinst() { |
303 |
# We must re-sign the libraries AFTER they are stripped. |
304 |
local shlibsign="${EROOT}/usr/bin/shlibsign" |
305 |
# See if we can execute it (cross-compiling & such). #436216 |
306 |
"${shlibsign}" -h >&/dev/null |
307 |
if [[ $? -gt 1 ]] ; then |
308 |
shlibsign="shlibsign" |
309 |
fi |
310 |
generate_chk "${shlibsign}" "${EROOT}"/usr/$(get_libdir) |
311 |
} |
312 |
|
313 |
multilib_foreach_abi multilib_pkg_postinst |
314 |
} |
315 |
|
316 |
pkg_postrm() { |
317 |
multilib_pkg_postrm() { |
318 |
cleanup_chk "${EROOT}"/usr/$(get_libdir) |
319 |
} |
320 |
|
321 |
multilib_foreach_abi multilib_pkg_postrm |
322 |
} |