Gentoo Archives: gentoo-commits

From: Julian Ospald <hasufell@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-misc/ca-certificates/
Date: Sun, 20 Sep 2015 13:28:48
Message-Id: 1442755646.bbfbe6bb7a3d2dc6db850438154e37573e979a95.hasufell@gentoo
1 commit: bbfbe6bb7a3d2dc6db850438154e37573e979a95
2 Author: Julian Ospald <hasufell <AT> gentoo <DOT> org>
3 AuthorDate: Sun Sep 20 13:27:26 2015 +0000
4 Commit: Julian Ospald <hasufell <AT> gentoo <DOT> org>
5 CommitDate: Sun Sep 20 13:27:26 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bbfbe6bb
7
8 app-misc/ca-certificates: add libressl support
9
10 .../ca-certificates-20141019.3.19-r1.ebuild | 190 +++++++++++++++++++++
11 1 file changed, 190 insertions(+)
12
13 diff --git a/app-misc/ca-certificates/ca-certificates-20141019.3.19-r1.ebuild b/app-misc/ca-certificates/ca-certificates-20141019.3.19-r1.ebuild
14 new file mode 100644
15 index 0000000..309784d
16 --- /dev/null
17 +++ b/app-misc/ca-certificates/ca-certificates-20141019.3.19-r1.ebuild
18 @@ -0,0 +1,190 @@
19 +# Copyright 1999-2015 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +# $Id$
22 +
23 +# The Debian ca-certificates package merely takes the CA database as it exists
24 +# in the nss package and repackages it for use by openssl.
25 +#
26 +# The issue with using the compiled debs directly is two fold:
27 +# - they do not update frequently enough for us to rely on them
28 +# - they pull the CA database from nss tip of tree rather than the release
29 +#
30 +# So we take the Debian source tools and combine them with the latest nss
31 +# release to produce (largely) the same end result. The difference is that
32 +# now we know our cert database is kept in sync with nss and, if need be,
33 +# can be sync with nss tip of tree more frequently to respond to bugs.
34 +
35 +# When triaging bugs from users, here's some handy tips:
36 +# - To see what cert is hitting errors, use openssl:
37 +# openssl s_client -port 443 -CApath /etc/ssl/certs/ -host $HOSTNAME
38 +# Focus on the errors written to stderr.
39 +#
40 +# - Look at the upstream log as to why certs were added/removed:
41 +# https://hg.mozilla.org/projects/nss/log/tip/lib/ckfw/builtins/certdata.txt
42 +#
43 +# - If people want to add/remove certs, tell them to file w/mozilla:
44 +# https://bugzilla.mozilla.org/enter_bug.cgi?product=NSS&component=CA%20Certificates&version=trunk
45 +
46 +EAPI="4"
47 +PYTHON_COMPAT=( python2_7 )
48 +
49 +inherit eutils python-any-r1
50 +
51 +if [[ ${PV} == *.* ]] ; then
52 + # Compile from source ourselves.
53 + PRECOMPILED=false
54 + inherit versionator
55 +
56 + DEB_VER=$(get_version_component_range 1)
57 + NSS_VER=$(get_version_component_range 2-)
58 + RTM_NAME="NSS_${NSS_VER//./_}_RTM"
59 +else
60 + # Debian precompiled version.
61 + PRECOMPILED=true
62 + inherit unpacker
63 +fi
64 +
65 +DESCRIPTION="Common CA Certificates PEM files"
66 +HOMEPAGE="http://packages.debian.org/sid/ca-certificates"
67 +NMU_PR=""
68 +if ${PRECOMPILED} ; then
69 + SRC_URI="mirror://debian/pool/main/c/${PN}/${PN}_${PV}${NMU_PR:++nmu}${NMU_PR}_all.deb"
70 +else
71 + SRC_URI="mirror://debian/pool/main/c/${PN}/${PN}_${DEB_VER}${NMU_PR:++nmu}${NMU_PR}.tar.xz
72 + ftp://ftp.mozilla.org/pub/mozilla.org/security/nss/releases/${RTM_NAME}/src/nss-${NSS_VER}.tar.gz
73 + cacert? ( https://dev.gentoo.org/~anarchy/patches/nss-3.14.1-add_spi+cacerts_ca_certs.patch )"
74 +fi
75 +
76 +LICENSE="MPL-1.1"
77 +SLOT="0"
78 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris ~x86-winnt"
79 +IUSE="libressl"
80 +${PRECOMPILED} || IUSE+=" +cacert"
81 +
82 +DEPEND=""
83 +if ${PRECOMPILED} ; then
84 + # platforms like AIX don't have a good ar
85 + DEPEND+="
86 + kernel_AIX? ( app-arch/deb2targz )
87 + !<sys-apps/portage-2.1.10.41"
88 +fi
89 +# openssl: we run `c_rehash`; newer version for alt-cert-paths #552540
90 +# debianutils: we run `run-parts`
91 +RDEPEND="${DEPEND}
92 + !libressl? ( >=dev-libs/openssl-1.0.1o:0 )
93 + libressl? (
94 + app-misc/c_rehash
95 + dev-libs/libressl
96 + )
97 + sys-apps/debianutils"
98 +
99 +if ! ${PRECOMPILED}; then
100 + DEPEND+=" ${PYTHON_DEPS}"
101 +fi
102 +
103 +S=${WORKDIR}
104 +
105 +pkg_setup() {
106 + # For the conversion to having it in CONFIG_PROTECT_MASK,
107 + # we need to tell users about it once manually first.
108 + [[ -f "${EPREFIX}"/etc/env.d/98ca-certificates ]] \
109 + || ewarn "You should run update-ca-certificates manually after etc-update"
110 +}
111 +
112 +src_unpack() {
113 + ${PRECOMPILED} || default
114 +
115 + mv ${PN}-*/ ${PN} || die
116 +
117 + # Do all the work in the image subdir to avoid conflicting with source
118 + # dirs in $WORKDIR. Need to perform everything in the offset #381937
119 + mkdir -p "image/${EPREFIX}"
120 + cd "image/${EPREFIX}" || die
121 +
122 + ${PRECOMPILED} && unpacker_src_unpack
123 +}
124 +
125 +src_prepare() {
126 + cd "image/${EPREFIX}" || die
127 + if ! ${PRECOMPILED} ; then
128 + mkdir -p usr/sbin
129 + cp -p "${S}"/${PN}/sbin/update-ca-certificates usr/sbin/ || die
130 +
131 + if use cacert ; then
132 + pushd "${S}"/nss-${NSS_VER} >/dev/null
133 + epatch "${DISTDIR}"/nss-3.14.1-add_spi+cacerts_ca_certs.patch
134 + popd >/dev/null
135 + fi
136 + fi
137 +
138 + epatch "${FILESDIR}"/${PN}-20141019-root.patch
139 + local relp=$(echo "${EPREFIX}" | sed -e 's:[^/]\+:..:g')
140 + sed -i \
141 + -e '/="$ROOT/s:ROOT/:ROOT'"${EPREFIX}"'/:' \
142 + -e '/RELPATH="\.\./s:"$:'"${relp}"'":' \
143 + usr/sbin/update-ca-certificates || die
144 +}
145 +
146 +src_compile() {
147 + cd "image/${EPREFIX}" || die
148 + if ! ${PRECOMPILED} ; then
149 + python_setup
150 + local d="${S}/${PN}/mozilla"
151 + # Grab the database from the nss sources.
152 + cp "${S}"/nss-${NSS_VER}/nss/lib/ckfw/builtins/{certdata.txt,nssckbi.h} "${d}" || die
153 + emake -C "${d}"
154 +
155 + # Now move the files to the same places that the precompiled would.
156 + mkdir -p etc/ssl/certs etc/ca-certificates/update.d usr/share/ca-certificates/mozilla
157 + if use cacert ; then
158 + mkdir -p usr/share/ca-certificates/{cacert.org,spi-inc.org}
159 + mv "${d}"/CAcert_Inc..crt usr/share/ca-certificates/cacert.org/cacert.org_root.crt || die
160 + mv "${d}"/SPI_Inc..crt usr/share/ca-certificates/spi-inc.org/spi-cacert-2008.crt || die
161 + fi
162 + mv "${d}"/*.crt usr/share/ca-certificates/mozilla/ || die
163 + else
164 + mv usr/share/doc/{ca-certificates,${PF}} || die
165 + fi
166 +
167 + (
168 + echo "# Automatically generated by ${CATEGORY}/${PF}"
169 + echo "# $(date -u)"
170 + echo "# Do not edit."
171 + cd usr/share/ca-certificates
172 + find * -name '*.crt' | LC_ALL=C sort
173 + ) > etc/ca-certificates.conf
174 +
175 + sh usr/sbin/update-ca-certificates --root "${S}/image" || die
176 +}
177 +
178 +src_install() {
179 + cp -pPR image/* "${D}"/ || die
180 + if ! ${PRECOMPILED} ; then
181 + cd ca-certificates
182 + doman sbin/*.8
183 + dodoc debian/README.* examples/ca-certificates-local/README
184 + fi
185 +
186 + echo 'CONFIG_PROTECT_MASK="/etc/ca-certificates.conf"' > 98ca-certificates
187 + doenvd 98ca-certificates
188 +}
189 +
190 +pkg_postinst() {
191 + if [ -d "${EROOT}/usr/local/share/ca-certificates" ] ; then
192 + # if the user has local certs, we need to rebuild again
193 + # to include their stuff in the db.
194 + # However it's too overzealous when the user has custom certs in place.
195 + # --fresh is to clean up dangling symlinks
196 + "${EROOT}"/usr/sbin/update-ca-certificates --root "${ROOT}"
197 + fi
198 +
199 + local c badcerts=0
200 + for c in $(find -L "${EROOT}"etc/ssl/certs/ -type l) ; do
201 + ewarn "Broken symlink for a certificate at $c"
202 + badcerts=1
203 + done
204 + if [ $badcerts -eq 1 ]; then
205 + ewarn "Removing the following broken symlinks:"
206 + ewarn "$(find -L "${EROOT}"/etc/ssl/certs/ -type l -printf '%p -> %l\n' -delete)"
207 + fi
208 +}