| 1 |
# Copyright 1999-2013 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/glibc-9999.ebuild,v 1.20 2013/02/09 04:42:17 vapier Exp $
|
| 4 |
|
| 5 |
inherit eutils versionator toolchain-funcs flag-o-matic gnuconfig multilib unpacker multiprocessing
|
| 6 |
|
| 7 |
DESCRIPTION="GNU libc6 (also called glibc2) C library"
|
| 8 |
HOMEPAGE="http://www.gnu.org/software/libc/libc.html"
|
| 9 |
|
| 10 |
LICENSE="LGPL-2.1+ BSD HPND ISC inner-net rc PCRE"
|
| 11 |
#KEYWORDS="~alpha ~amd64 ~arm -hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
|
| 12 |
RESTRICT="strip" # strip ourself #46186
|
| 13 |
EMULTILIB_PKG="true"
|
| 14 |
|
| 15 |
# Configuration variables
|
| 16 |
RELEASE_VER=""
|
| 17 |
case ${PV} in
|
| 18 |
9999*)
|
| 19 |
EGIT_REPO_URIS="git://sourceware.org/git/glibc.git"
|
| 20 |
EGIT_SOURCEDIRS="${S}"
|
| 21 |
inherit git-2
|
| 22 |
;;
|
| 23 |
*)
|
| 24 |
RELEASE_VER=${PV}
|
| 25 |
;;
|
| 26 |
esac
|
| 27 |
PATCH_VER="" # Gentoo patchset
|
| 28 |
NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.16"} # min kernel version nptl requires
|
| 29 |
|
| 30 |
IUSE="debug gd hardened multilib nscd selinux systemtap profile suid vanilla crosscompile_opts_headers-only"
|
| 31 |
|
| 32 |
# Here's how the cross-compile logic breaks down ...
|
| 33 |
# CTARGET - machine that will target the binaries
|
| 34 |
# CHOST - machine that will host the binaries
|
| 35 |
# CBUILD - machine that will build the binaries
|
| 36 |
# If CTARGET != CHOST, it means you want a libc for cross-compiling.
|
| 37 |
# If CHOST != CBUILD, it means you want to cross-compile the libc.
|
| 38 |
# CBUILD = CHOST = CTARGET - native build/install
|
| 39 |
# CBUILD != (CHOST = CTARGET) - cross-compile a native build
|
| 40 |
# (CBUILD = CHOST) != CTARGET - libc for cross-compiler
|
| 41 |
# CBUILD != CHOST != CTARGET - cross-compile a libc for a cross-compiler
|
| 42 |
# For install paths:
|
| 43 |
# CHOST = CTARGET - install into /
|
| 44 |
# CHOST != CTARGET - install into /usr/CTARGET/
|
| 45 |
|
| 46 |
export CBUILD=${CBUILD:-${CHOST}}
|
| 47 |
export CTARGET=${CTARGET:-${CHOST}}
|
| 48 |
if [[ ${CTARGET} == ${CHOST} ]] ; then
|
| 49 |
if [[ ${CATEGORY} == cross-* ]] ; then
|
| 50 |
export CTARGET=${CATEGORY#cross-}
|
| 51 |
fi
|
| 52 |
fi
|
| 53 |
|
| 54 |
[[ ${CTARGET} == hppa* ]] && NPTL_KERN_VER=${NPTL_KERN_VER/2.6.16/2.6.20}
|
| 55 |
|
| 56 |
is_crosscompile() {
|
| 57 |
[[ ${CHOST} != ${CTARGET} ]]
|
| 58 |
}
|
| 59 |
|
| 60 |
# Why SLOT 2.2 you ask yourself while sippin your tea ?
|
| 61 |
# Everyone knows 2.2 > 0, duh.
|
| 62 |
SLOT="2.2"
|
| 63 |
|
| 64 |
# General: We need a new-enough binutils/gcc to match upstream baseline.
|
| 65 |
# arch: we need to make sure our binutils/gcc supports TLS.
|
| 66 |
DEPEND=">=app-misc/pax-utils-0.1.10
|
| 67 |
!<sys-apps/sandbox-1.6
|
| 68 |
!<sys-apps/portage-2.1.2
|
| 69 |
selinux? ( sys-libs/libselinux )"
|
| 70 |
RDEPEND="!sys-kernel/ps3-sources
|
| 71 |
selinux? ( sys-libs/libselinux )
|
| 72 |
!sys-libs/nss-db"
|
| 73 |
|
| 74 |
if [[ ${CATEGORY} == cross-* ]] ; then
|
| 75 |
DEPEND+=" !crosscompile_opts_headers-only? (
|
| 76 |
>=${CATEGORY}/binutils-2.20
|
| 77 |
>=${CATEGORY}/gcc-4.3
|
| 78 |
)"
|
| 79 |
[[ ${CATEGORY} == *-linux* ]] && DEPEND+=" ${CATEGORY}/linux-headers"
|
| 80 |
else
|
| 81 |
DEPEND+="
|
| 82 |
>=sys-devel/binutils-2.20
|
| 83 |
>=sys-devel/gcc-4.3
|
| 84 |
virtual/os-headers
|
| 85 |
!vanilla? ( >=sys-libs/timezone-data-2012c )"
|
| 86 |
RDEPEND+="
|
| 87 |
vanilla? ( !sys-libs/timezone-data )
|
| 88 |
!vanilla? ( sys-libs/timezone-data )"
|
| 89 |
fi
|
| 90 |
|
| 91 |
SRC_URI=$(
|
| 92 |
upstream_uris() {
|
| 93 |
echo mirror://gnu/glibc/$1 ftp://sourceware.org/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
|
| 94 |
}
|
| 95 |
gentoo_uris() {
|
| 96 |
local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
|
| 97 |
devspace=${devspace//HTTP/http://dev.gentoo.org/}
|
| 98 |
echo mirror://gentoo/$1 ${devspace//URI/$1}
|
| 99 |
}
|
| 100 |
|
| 101 |
[[ -z ${EGIT_REPO_URIS} ]] && upstream_uris ${P}.tar.xz
|
| 102 |
[[ -n ${PATCH_VER} ]] && gentoo_uris ${P}-patches-${PATCH_VER}.tar.bz2
|
| 103 |
)
|
| 104 |
|
| 105 |
# eblit-include [--skip] <function> [version]
|
| 106 |
eblit-include() {
|
| 107 |
local skipable=false
|
| 108 |
[[ $1 == "--skip" ]] && skipable=true && shift
|
| 109 |
[[ $1 == pkg_* ]] && skipable=true
|
| 110 |
|
| 111 |
local e v func=$1 ver=$2
|
| 112 |
[[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
|
| 113 |
for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
|
| 114 |
e="${FILESDIR}/eblits/${func}${v}.eblit"
|
| 115 |
if [[ -e ${e} ]] ; then
|
| 116 |
source "${e}"
|
| 117 |
return 0
|
| 118 |
fi
|
| 119 |
done
|
| 120 |
${skipable} && return 0
|
| 121 |
die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
|
| 122 |
}
|
| 123 |
|
| 124 |
# eblit-run-maybe <function>
|
| 125 |
# run the specified function if it is defined
|
| 126 |
eblit-run-maybe() {
|
| 127 |
[[ $(type -t "$@") == "function" ]] && "$@"
|
| 128 |
}
|
| 129 |
|
| 130 |
# eblit-run <function> [version]
|
| 131 |
# aka: src_unpack() { eblit-run src_unpack ; }
|
| 132 |
eblit-run() {
|
| 133 |
eblit-include --skip common "${*:2}"
|
| 134 |
eblit-include "$@"
|
| 135 |
eblit-run-maybe eblit-$1-pre
|
| 136 |
eblit-${PN}-$1
|
| 137 |
eblit-run-maybe eblit-$1-post
|
| 138 |
}
|
| 139 |
|
| 140 |
src_unpack() { eblit-run src_unpack ; }
|
| 141 |
src_compile() { eblit-run src_compile ; }
|
| 142 |
src_test() { eblit-run src_test ; }
|
| 143 |
src_install() { eblit-run src_install ; }
|
| 144 |
|
| 145 |
# FILESDIR might not be available during binpkg install
|
| 146 |
for x in setup {pre,post}inst ; do
|
| 147 |
e="${FILESDIR}/eblits/pkg_${x}.eblit"
|
| 148 |
if [[ -e ${e} ]] ; then
|
| 149 |
. "${e}"
|
| 150 |
eval "pkg_${x}() { eblit-run pkg_${x} ; }"
|
| 151 |
fi
|
| 152 |
done
|
| 153 |
|
| 154 |
eblit-src_unpack-post() {
|
| 155 |
if use hardened ; then
|
| 156 |
cd "${S}"
|
| 157 |
einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
|
| 158 |
gcc-specs-pie && epatch "${FILESDIR}"/2.16/glibc-2.16-hardened-pie.patch
|
| 159 |
epatch "${FILESDIR}"/2.10/glibc-2.10-hardened-configure-picdefault.patch
|
| 160 |
epatch "${FILESDIR}"/2.10/glibc-2.10-hardened-inittls-nosysenter.patch
|
| 161 |
|
| 162 |
einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
|
| 163 |
cp -f "${FILESDIR}"/2.6/glibc-2.6-gentoo-stack_chk_fail.c \
|
| 164 |
debug/stack_chk_fail.c || die
|
| 165 |
cp -f "${FILESDIR}"/2.10/glibc-2.10-gentoo-chk_fail.c \
|
| 166 |
debug/chk_fail.c || die
|
| 167 |
|
| 168 |
if use debug ; then
|
| 169 |
# When using Hardened Gentoo stack handler, have smashes dump core for
|
| 170 |
# analysis - debug only, as core could be an information leak
|
| 171 |
# (paranoia).
|
| 172 |
sed -i \
|
| 173 |
-e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
|
| 174 |
debug/Makefile \
|
| 175 |
|| die "Failed to modify debug/Makefile for debug stack handler"
|
| 176 |
sed -i \
|
| 177 |
-e '/^CFLAGS-backtrace.c/ iCFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
|
| 178 |
debug/Makefile \
|
| 179 |
|| die "Failed to modify debug/Makefile for debug fortify handler"
|
| 180 |
fi
|
| 181 |
|
| 182 |
# Build nscd with ssp-all
|
| 183 |
sed -i \
|
| 184 |
-e 's:-fstack-protector$:-fstack-protector-all:' \
|
| 185 |
nscd/Makefile \
|
| 186 |
|| die "Failed to ensure nscd builds with ssp-all"
|
| 187 |
fi
|
| 188 |
}
|
| 189 |
|
| 190 |
eblit-pkg_preinst-post() {
|
| 191 |
if [[ ${CTARGET} == arm* ]] ; then
|
| 192 |
# Backwards compat support for renaming hardfp ldsos #417287
|
| 193 |
local oldso='/lib/ld-linux.so.3'
|
| 194 |
local nldso='/lib/ld-linux-armhf.so.3'
|
| 195 |
if [[ -e ${D}${nldso} ]] ; then
|
| 196 |
if scanelf -qRyi "${ROOT}$(alt_prefix)"/*bin/ | grep -s "^${oldso}" ; then
|
| 197 |
ewarn "Symlinking old ldso (${oldso}) to new ldso (${nldso})."
|
| 198 |
ewarn "Please rebuild all packages using this old ldso as compat"
|
| 199 |
ewarn "support will be dropped in the future."
|
| 200 |
ln -s "${nldso##*/}" "${D}$(alt_prefix)${oldso}"
|
| 201 |
fi
|
| 202 |
fi
|
| 203 |
fi
|
| 204 |
}
|