net-fs/openafs-kernel: remove vulnerable versions
[gentoo.git] / eclass / emul-linux-x86.eclass
1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 # @DEAD
6
7 #
8 # Original Author: Mike Doty <kingtaco@gentoo.org>
9 # Adapted from emul-libs.eclass
10 # Purpose: Providing a template for the app-emulation/emul-linux-* packages
11 #
12
13 inherit eutils multilib
14
15 case "${EAPI:-0}" in
16         3|4|5)
17                 EXPORT_FUNCTIONS src_prepare src_install
18                 ;;
19         *) die "EAPI=${EAPI} is not supported" ;;
20 esac
21
22 eqawarn "emul-linux-x86.eclass is last rited and will be removed on 2015-11-24."
23 eqawarn "Please remove your copies of emul-linux-x86 ebuilds as they are"
24 eqawarn "no longer supported."
25
26 DESCRIPTION="Provides precompiled 32bit libraries"
27 #HOMEPAGE="https://amd64.gentoo.org/emul/content.xml"
28 HOMEPAGE="https://dev.gentoo.org/~pacho/emul.html"
29 SRC_URI="https://dev.gentoo.org/~pacho/emul/${P}.tar.xz"
30
31 IUSE="+development"
32
33 RESTRICT="strip"
34 S=${WORKDIR}
35
36 QA_PREBUILT="*"
37
38 SLOT="0"
39
40 DEPEND=">=sys-apps/findutils-4.2.26"
41 RDEPEND=""
42
43 emul-linux-x86_src_prepare() {
44         ALLOWED=${ALLOWED:-^${S}/etc/env.d}
45         use development && ALLOWED="${ALLOWED}|/usr/lib32/pkgconfig"
46         find "${S}" ! -type d ! '(' -name '*.so' -o -name '*.so.[0-9]*' -o -name '*.h' ')' | egrep -v "${ALLOWED}" | xargs -d $'\n' rm -f || die 'failed to remove everything but *.so*'
47 }
48
49 emul-linux-x86_src_install() {
50         for dir in etc/env.d etc/revdep-rebuild ; do
51                 if [[ -d "${S}"/${dir} ]] ; then
52                         for f in "${S}"/${dir}/* ; do
53                                 mv -f "$f"{,-emul}
54                         done
55                 fi
56         done
57
58         # remove void directories
59         find "${S}" -depth -type d -print0 | xargs -0 rmdir 2&>/dev/null
60
61         cp -pPR "${S}"/* "${ED}"/ || die "copying files failed!"
62
63         # Do not hardcode lib32, bug #429726
64         local x86_libdir=$(get_abi_LIBDIR x86)
65         if [[ ${x86_libdir} != "lib32" ]] ; then
66                 ewarn "Moving lib32/ to ${x86_libdir}/; some libs might not work"
67                 mv "${D}"/usr/lib32 "${D}"/usr/${x86_libdir} || die
68                 if [[ -d ${D}/lib32 ]] ; then
69                         mv "${D}"/lib32 "${D}"/${x86_libdir} || die
70                 fi
71
72                 pushd "${D}"/usr/${x86_libdir} >/dev/null
73
74                 # Fix linker script paths.
75                 local ldscripts
76                 if ldscripts=( $(grep -ls '^GROUP.*/lib32/' *.so) ) ; then
77                         sed -i \
78                                 -e "s:/lib32/:/${x86_libdir}/:" \
79                                 "${ldscripts[@]}" || die
80                 fi
81
82                 # Rewrite symlinks (if need be).
83                 local sym tgt
84                 while read sym ; do
85                         tgt=$(readlink "${sym}")
86                         ln -sf "${tgt/lib32/${x86_libdir}}" "${sym}" || die
87                 done < <(find -xtype l)
88
89                 popd >/dev/null
90         fi
91
92         # Since header wrapping is added as part of gx86-multilib support,
93         # all packages involved install their own copies of i686* headers
94         # when built with abi_x86_32.
95         if [[ -d "${D}"/usr/include ]] && use abi_x86_32; then
96                 rm -r "${D}"/usr/include || die
97         fi
98         # The same goes for ${CHOST}- multilib tool prefixing.
99         if path_exists "${D}"/usr/bin/i686-pc-linux-gnu-* && use abi_x86_32; then
100                 rm "${D}"/usr/bin/i686-pc-linux-gnu-* || die
101         fi
102 }