kde-base/kdelibs - fix patch files
[anomen-overlay.git] / dev-libs / openssl / openssl-0.9.8l-r3.ebuild
blob2b8d3225642e4c9c6d9b786b843d255a33b57ce5
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/dev-libs/openssl/openssl-0.9.8l-r2.ebuild,v 1.1 2009/11/27 22:00:12 vapier Exp $
5 inherit eutils flag-o-matic toolchain-funcs
7 DESCRIPTION="Toolkit for SSL v2/v3 and TLS v1"
8 HOMEPAGE="http://www.openssl.org/"
9 SRC_URI="mirror://openssl/source/${P}.tar.gz"
11 LICENSE="openssl"
12 SLOT="0"
13 KEYWORDS="~amd64 ~x86"
14 IUSE="bindist gmp kerberos sse2 test zlib vulnerable"
16 RDEPEND="gmp? ( dev-libs/gmp )
17 zlib? ( sys-libs/zlib )
18 kerberos? ( app-crypt/mit-krb5 )"
19 DEPEND="${RDEPEND}
20 sys-apps/diffutils
21 >=dev-lang/perl-5
22 test? ( sys-devel/bc )"
23 PDEPEND="app-misc/ca-certificates"
25 src_unpack() {
26 unpack ${A}
27 cd "${S}"
29 use vulnerable && epatch "${FILESDIR}/md_rand.patch"
31 epatch "${FILESDIR}"/${PN}-0.9.7e-gentoo.patch
32 #Forward port of the -b patch. Parallel make fails though.
33 epatch "${FILESDIR}"/${PN}-0.9.8j-parallel-build.patch
34 epatch "${FILESDIR}"/${PN}-0.9.8-make-engines-dir.patch
35 epatch "${FILESDIR}"/${PN}-0.9.8k-toolchain.patch
36 epatch "${FILESDIR}"/${PN}-0.9.8b-doc-updates.patch
37 epatch "${FILESDIR}"/${PN}-0.9.8-makedepend.patch #149583
38 epatch "${FILESDIR}"/${PN}-0.9.8e-make.patch #146316
39 #epatch "${FILESDIR}"/${PN}-0.9.8e-bsd-sparc64.patch
40 epatch "${FILESDIR}"/${PN}-0.9.8g-sslv3-no-tlsext.patch
41 #epatch "${FILESDIR}"/${PN}-0.9.8h-ldflags.patch #181438
42 epatch "${FILESDIR}"/${PN}-0.9.8l-CVE-2009-137{7,8,9}.patch #270305
43 epatch "${FILESDIR}"/${P}-CVE-2009-1387.patch #270305
44 epatch "${FILESDIR}"/${P}-CVE-2009-2409.patch #280591
45 epatch "${FILESDIR}"/${P}-dtls-compat.patch #280370
46 epatch "${FILESDIR}"/${PN}-0.9.8l-binutils.patch #289130
47 sed -i -e '/DIRS/ s/ fips / /g' Makefile{,.org} \
48 || die "Removing fips from openssl failed."
50 # allow openssl to be cross-compiled
51 cp "${FILESDIR}"/gentoo.config-0.9.8 gentoo.config || die "cp cross-compile failed"
52 chmod a+rx gentoo.config
54 # Don't build manpages if we don't want them
55 has noman FEATURES \
56 && sed -i '/^install:/s:install_docs::' Makefile.org \
57 || sed -i '/^MANDIR=/s:=.*:=/usr/share/man:' Makefile.org
59 # Try to derice users and work around broken ass toolchains
60 if [[ $(gcc-major-version) == "3" ]] ; then
61 filter-flags -fprefetch-loop-arrays -freduce-all-givs -funroll-loops
62 [[ $(tc-arch) == "ppc64" ]] && replace-flags -O? -O
64 [[ $(tc-arch) == ppc* ]] && append-flags -fno-strict-aliasing
65 append-flags -Wa,--noexecstack
67 # using a library directory other than lib requires some magic
68 sed -i \
69 -e "s+\(\$(INSTALL_PREFIX)\$(INSTALLTOP)\)/lib+\1/$(get_libdir)+g" \
70 -e "s+libdir=\$\${exec_prefix}/lib+libdir=\$\${exec_prefix}/$(get_libdir)+g" \
71 Makefile.org engines/Makefile \
72 || die "sed failed"
73 sed -i '1s,^:$,#!/usr/bin/perl,' Configure #141906
74 sed -i '/^"debug-steve/d' Configure # 0.9.8k shipped broken
75 ./config --test-sanity || die "I AM NOT SANE"
78 src_compile() {
79 unset APPS #197996
81 tc-export CC AR RANLIB
83 # Clean out patent-or-otherwise-encumbered code
84 # Camellia: Royalty Free http://en.wikipedia.org/wiki/Camellia_(cipher)
85 # IDEA: 5,214,703 25/05/2010 http://en.wikipedia.org/wiki/International_Data_Encryption_Algorithm
86 # EC: ????????? ??/??/2015 http://en.wikipedia.org/wiki/Elliptic_Curve_Cryptography
87 # MDC2: Expired http://en.wikipedia.org/wiki/MDC-2
88 # RC5: 5,724,428 03/03/2015 http://en.wikipedia.org/wiki/RC5
90 use_ssl() { use $1 && echo "enable-${2:-$1} ${*:3}" || echo "no-${2:-$1}" ; }
91 echoit() { echo "$@" ; "$@" ; }
93 local krb5=$(has_version app-crypt/mit-krb5 && echo "MIT" || echo "Heimdal")
95 local sslout=$(./gentoo.config)
96 einfo "Use configuration ${sslout:-(openssl knows best)}"
97 local config="Configure"
98 [[ -z ${sslout} ]] && config="config"
99 echoit \
100 ./${config} \
101 ${sslout} \
102 $(use sse2 || echo "no-sse2") \
103 enable-camellia \
104 $(use_ssl !bindist ec) \
105 $(use_ssl !bindist idea) \
106 enable-mdc2 \
107 $(use_ssl !bindist rc5) \
108 enable-tlsext \
109 $(use_ssl gmp) \
110 $(use_ssl kerberos krb5 --with-krb5-flavor=${krb5}) \
111 $(use_ssl zlib) \
112 --prefix=/usr \
113 --openssldir=/etc/ssl \
114 shared threads \
115 || die "Configure failed"
117 # Clean out hardcoded flags that openssl uses
118 local CFLAG=$(grep ^CFLAG= Makefile | LC_ALL=C sed \
119 -e 's:^CFLAG=::' \
120 -e 's:-fomit-frame-pointer ::g' \
121 -e 's:-O[0-9] ::g' \
122 -e 's:-march=[-a-z0-9]* ::g' \
123 -e 's:-mcpu=[-a-z0-9]* ::g' \
124 -e 's:-m[a-z0-9]* ::g' \
126 sed -i \
127 -e "/^CFLAG/s:=.*:=${CFLAG} ${CFLAGS}:" \
128 -e "/^SHARED_LDFLAGS=/s:$: ${LDFLAGS}:" \
129 Makefile || die
131 # depend is needed to use $confopts
132 # rehash is needed to prep the certs/ dir
133 emake -j1 depend || die "depend failed"
134 emake -j1 all rehash || die "make all failed"
137 src_test() {
138 emake -j1 test || die "make test failed"
141 src_install() {
142 emake -j1 INSTALL_PREFIX="${D}" install || die
143 dodoc CHANGES* FAQ NEWS README doc/*.txt doc/c-indentation.el
144 dohtml -r doc/*
146 # create the certs directory
147 dodir /etc/ssl/certs
148 cp -RP certs/* "${D}"/etc/ssl/certs/ || die "failed to install certs"
149 rm -r "${D}"/etc/ssl/certs/{demo,expired}
151 # Namespace openssl programs to prevent conflicts with other man pages
152 cd "${D}"/usr/share/man
153 local m d s
154 for m in $(find . -type f | xargs grep -L '#include') ; do
155 d=${m%/*} ; d=${d#./} ; m=${m##*/}
156 [[ ${m} == openssl.1* ]] && continue
157 [[ -n $(find -L ${d} -type l) ]] && die "erp, broken links already!"
158 mv ${d}/{,ssl-}${m}
159 ln -s ssl-${m} ${d}/openssl-${m}
160 # locate any symlinks that point to this man page ... we assume
161 # that any broken links are due to the above renaming
162 for s in $(find -L ${d} -type l) ; do
163 s=${s##*/}
164 rm -f ${d}/${s}
165 ln -s ssl-${m} ${d}/ssl-${s}
166 ln -s ssl-${s} ${d}/openssl-${s}
167 done
168 done
169 [[ -n $(find -L ${d} -type l) ]] && die "broken manpage links found :("
171 dodir /etc/sandbox.d #254521
172 echo 'SANDBOX_PREDICT="/dev/crypto"' > "${D}"/etc/sandbox.d/10openssl
174 diropts -m0700
175 keepdir /etc/ssl/private
178 pkg_preinst() {
179 preserve_old_lib /usr/$(get_libdir)/lib{crypto,ssl}.so.0.9.{6,7}
182 pkg_postinst() {
183 preserve_old_lib_notify /usr/$(get_libdir)/lib{crypto,ssl}.so.0.9.{6,7}