glibc security fix
Hanno Böck

Hanno Böck commited on 2010-10-25 19:46:16
Zeige 20 geänderte Dateien mit 2638 Einfügungen und 0 Löschungen.

... ...
@@ -0,0 +1,21 @@
1
+AUX 2.11/glibc-2.11-hardened-pie.patch 1492 RMD160 dacf988364e3eeeaa2bd588420a19db373347678 SHA1 f44b4389d031bc618c83a2f196c4e2afa647a68a SHA256 74277f76ace9cb6b408ef7c1d43a3604ae0d6c1af539055aeaeb542d2bfa2a46
2
+AUX 2.12/glibc-2.12-hardened-pie.patch 1542 RMD160 c42e6a8eef542506c440d58395a066129cd40dec SHA1 703b4c23a6701f41cd51b629eae362e129b60de3 SHA256 9d11da52900a4cfdaa9052476029cb1b4c8004dfaef3cf446f3b728035f75fbe
3
+AUX eblits/common.eblit 9020 RMD160 82cec0d8109f420d9d2369ff6d872c8146d60ad6 SHA1 fc2eab1c0ba49c9536a3b21821dcf1ae265ac651 SHA256 c5e218a6b138b26067293bafd1595453be9ecd4b2e5322da4796330c61368ffe
4
+AUX eblits/pkg_postinst.eblit 1159 RMD160 4b99846819bf0471d1104a8a17dd260796644f9d SHA1 4a2980fede3edebc7960d40db7cf935c7c854859 SHA256 76c403cf5c77a3a3bb7441566335f0c8da2584eaa21f05ab400e7bb00f9db810
5
+AUX eblits/pkg_preinst.eblit 3764 RMD160 f9a9d43e2d2d8df073be7e1b66655e651cb10740 SHA1 b987e2802201e0f44c357ffc7b92da4aa77cf377 SHA256 41baa253ea529156d628108247545235c4ec377b184e7824bd790eba1361299e
6
+AUX eblits/pkg_setup.eblit 2814 RMD160 8352c4b9cc460b7193e17be8bca227db5b6df5ba SHA1 8de7ea78e364521b55574b16036d57e7d35a596f SHA256 b803723f75571649e10e0707a6dbe8b459eabdc149ef155558792db736faa201
7
+AUX eblits/src_compile-2.11.2.eblit 5849 RMD160 8881ea4b50cf177d628eb70913425db8c71e681d SHA1 31d75b03578aed3aa740a88091e2c0a7fe33786c SHA256 b1b9d25fe90b860ebaa8d78b0f6865da034040b58b044b665f4e0385052bc6d5
8
+AUX eblits/src_compile.eblit 5790 RMD160 d059d6ac75b6d6d60101a1c8456e11ecd1da2676 SHA1 4417abec18bce3a8eb9798a8519d868bbf3ba489 SHA256 ce8894489fd5c21dc74cc28116b77cb6d331743bbf9ecf32f4f8e368f997a74c
9
+AUX eblits/src_install-2.11.2.eblit 8091 RMD160 aa409a8fe8cabfeeb71c89d655d345cda84a3946 SHA1 f5526f3eaa448a808cde739d7c5a75fe9bdab245 SHA256 93e1188835bdd1156b33b7b03af3822c46f6d1a1bc8338e98b8aa0f950cee868
10
+AUX eblits/src_install-2.6.eblit 7946 RMD160 6cc258a316b78212777ab328a3c0cb73de1616d4 SHA1 94895689b56fd712156e8ac84a2a639d8475da03 SHA256 54081c34217c230d0ff43c5df378897a37576e727fe41ee4d681767110667f3e
11
+AUX eblits/src_install.eblit 8017 RMD160 f0f94cf49346af96d619ebc658ddb4193a9e91a3 SHA1 f10c162a048c8ef145d269feae9b741790495513 SHA256 a624b2e926bd4233c908cec39911e6df7f78f01c6380d436c1f3d05481efec41
12
+AUX eblits/src_test-2.11.2.eblit 1169 RMD160 d7d1f430453e5278c2f3d4ee4815faff3a47a03a SHA1 9d48060c34ef901cbe6e8d7880ea923c8e1b7f28 SHA256 95b14845a80a74abc5b5c5146f2291524d7dd66f8e1bd9d12b42a3234a065010
13
+AUX eblits/src_test.eblit 1172 RMD160 a70e31e655cd3e306af6a498002de85b72258566 SHA1 4aec15e6ab67279258fd23400701fd38c106a38b SHA256 e5a390761b7ec613460b8da26df3ffe2a137217261dd9f87f2b78c3fa2a12727
14
+AUX eblits/src_unpack.eblit 5219 RMD160 3c63f22995dd13cafce46d519b28c4ede1ee0281 SHA1 b52d277a37232cc6d09666a55a8ee4f5d5d892b4 SHA256 d70a28c4f6662786822cb2852ea86836c92ff2f8059270022431e1d02da3a9e1
15
+AUX glibc-sec1 2564 RMD160 84e731c7b9835c63fbf1616fa8a5d918890a0a71 SHA1 e7d3e07c2cf76001897ab2b67190561d5d0a11bb SHA256 c555ed9e42f8124be75f9cce9b647c3252a314ff9b1a28a227e49ea7f2de8fc9
16
+AUX glibc-sec2 7820 RMD160 838bf19b0f1611d53308422b84c3d67c4fb07478 SHA1 9dbbc4bdd99f1b599e9be90611fde6c2c134a00f SHA256 c4514239863e742bd369c92e3e427e53304349ee0dc10e3819370b46cf337817
17
+AUX nscd 1621 RMD160 f6d20c4c3814f70d7741f3fa2e0b53ba32c37960 SHA1 5751fe798024c2021b7b3ed3e798618e2a38244a SHA256 6165db3a2fcb251d4f3655c0461e018ce9c92a37f7f22a8fd2b75178b5435bc8
18
+AUX nsswitch.conf 503 RMD160 f375f92f6b41029c93382c39cef896261b140cfc SHA1 42f7f5cc3de75c69bf60d806ac8490106ea63326 SHA256 6c38b8642d5da884327ad678d0351d57be3621562253bd9711394bad87e45e2d
19
+DIST glibc-2.12.1-patches-4.tar.bz2 89636 RMD160 e746b43d314666be5ed6de9f83a96a618700d60e SHA1 3433058674151dbb714bf0826d77e13603b62e3d SHA256 1977abf5b8a432d0d00a7e35608aeb309ea451f6be1359b7c5d05e046274c74c
20
+DIST glibc-2.12.1.tar.bz2 15667516 RMD160 4a46745f4220f4253af0b882d0c2072499e17653 SHA1 ef5ca1e765719d3290bd24f94705f27534f3744b SHA256 759f115c52bc12c5bb453af559dcd456d32138250b7cc96e47804e3d0ec97407
21
+EBUILD glibc-2.12.1-r2.ebuild 8814 RMD160 09cf6d2f39d9dabd6c7f595640c8b6a9dc3cb471 SHA1 2621eb1171721bd4490b76a0b5370a233c15cf10 SHA256 aff7e3c004701de9ccaffb700ef602e6b4b721cd0562361cf6061c6e7aaa606f
... ...
@@ -0,0 +1,40 @@
1
+http://bugs.gentoo.org/292139
2
+
3
+2009-11-08  Magnus Granberg  <zorry@ume.nu>
4
+
5
+	* Makeconfig (+link): Set to +link-pie.
6
+	(+link-static): Change $(static-start-installed-name) to
7
+	S$(static-start-installed-name).
8
+	(+prector): Set to +prectorS.
9
+	(+postctor): Set to +postctorS.
10
+
11
+--- libc/Makeconfig
12
++++ libc/Makeconfig
13
+@@ -447,11 +447,12 @@
14
+ 	     $(common-objpfx)libc% $(+postinit),$^) \
15
+ 	     $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
16
+ endif
17
+++link = $(+link-pie)
18
+ # Command for statically linking programs with the C library.
19
+ ifndef +link-static
20
+ +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
21
+ 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
22
+-	      $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
23
++	      $(addprefix $(csu-objpfx),S$(static-start-installed-name)) \
24
+ 	      $(+preinit) $(+prector) \
25
+ 	      $(filter-out $(addprefix $(csu-objpfx),start.o \
26
+ 						     $(start-installed-name))\
27
+@@ -549,11 +550,10 @@
28
+ ifeq ($(elf),yes)
29
+ +preinit = $(addprefix $(csu-objpfx),crti.o)
30
+ +postinit = $(addprefix $(csu-objpfx),crtn.o)
31
+-+prector = `$(CC) --print-file-name=crtbegin.o`
32
+-+postctor = `$(CC) --print-file-name=crtend.o`
33
+-# Variants of the two previous definitions for linking PIE programs.
34
+ +prectorS = `$(CC) --print-file-name=crtbeginS.o`
35
+ +postctorS = `$(CC) --print-file-name=crtendS.o`
36
+++prector = $(+prectorS)
37
+++postctor = $(+postctorS)
38
+ +interp = $(addprefix $(elf-objpfx),interp.os)
39
+ endif
40
+ csu-objpfx = $(common-objpfx)csu/
... ...
@@ -0,0 +1,39 @@
1
+2010-08-11  Magnus Granberg  <zorry@ume.nu>
2
+
3
+	#332331
4
+	* Makeconfig (+link): Set to +link-pie.
5
+	(+link-static): Change $(static-start-installed-name) to
6
+	S$(static-start-installed-name).
7
+	(+prector): Set to +prectorS.
8
+	(+postctor): Set to +postctorS.
9
+
10
+--- libc/Makeconfig
11
++++ libc/Makeconfig
12
+@@ -447,11 +447,12 @@
13
+ 	     $(common-objpfx)libc% $(+postinit),$^) \
14
+ 	     $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit)
15
+ endif
16
+++link = $(+link-pie)
17
+ # Command for statically linking programs with the C library.
18
+ ifndef +link-static
19
+ +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
20
+ 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
21
+-	      $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
22
++	      $(addprefix $(csu-objpfx),S$(static-start-installed-name)) \
23
+ 	      $(+preinit) $(+prector) \
24
+ 	      $(filter-out $(addprefix $(csu-objpfx),start.o \
25
+ 						     $(start-installed-name))\
26
+@@ -549,11 +550,10 @@
27
+ ifeq ($(elf),yes)
28
+ +preinit = $(addprefix $(csu-objpfx),crti.o)
29
+ +postinit = $(addprefix $(csu-objpfx),crtn.o)
30
+-+prector = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbegin.o`
31
+-+postctor = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
32
+-# Variants of the two previous definitions for linking PIE programs.
33
+ +prectorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginS.o`
34
+ +postctorS = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtendS.o`
35
+++prector = $(+prectorS)
36
+++postctor = $(+postctorS)
37
+ +interp = $(addprefix $(elf-objpfx),interp.os)
38
+ endif
39
+ csu-objpfx = $(common-objpfx)csu/
... ...
@@ -0,0 +1,298 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/common.eblit,v 1.12 2010/09/30 06:29:21 vapier Exp $
4
+
5
+# We need to be able to set alternative headers for
6
+# compiling for non-native platform
7
+# Will also become useful for testing kernel-headers without screwing up
8
+# the whole system.
9
+# note: intentionally undocumented.
10
+alt_headers() {
11
+	if [[ -z ${ALT_HEADERS} ]] ; then
12
+		if is_crosscompile ; then
13
+			ALT_HEADERS="/usr/${CTARGET}/usr/include"
14
+		else
15
+			ALT_HEADERS="/usr/include"
16
+		fi
17
+	fi
18
+	echo "${ALT_HEADERS}"
19
+}
20
+alt_build_headers() {
21
+	if [[ -z ${ALT_BUILD_HEADERS} ]] ; then
22
+		ALT_BUILD_HEADERS=$(alt_headers)
23
+		if tc-is-cross-compiler ; then
24
+			ALT_BUILD_HEADERS=${ROOT}$(alt_headers)
25
+			if [[ ! -e ${ALT_BUILD_HEADERS}/linux/version.h ]] ; then
26
+				local header_path=$(echo '#include <linux/version.h>' | $(tc-getCPP ${CTARGET}) ${CFLAGS} 2>&1 | grep -o '[^"]*linux/version.h')
27
+				ALT_BUILD_HEADERS=${header_path%/linux/version.h}
28
+			fi
29
+		fi
30
+	fi
31
+	echo "${ALT_BUILD_HEADERS}"
32
+}
33
+
34
+alt_usrlibdir() {
35
+	if is_crosscompile ; then
36
+		echo /usr/${CTARGET}/usr/$(get_libdir)
37
+	else
38
+		echo /usr/$(get_libdir)
39
+	fi
40
+}
41
+
42
+setup_flags() {
43
+	# Make sure host make.conf doesn't pollute us
44
+	if is_crosscompile || tc-is-cross-compiler ; then
45
+		CHOST=${CTARGET} strip-unsupported-flags
46
+	fi
47
+
48
+	# Store our CFLAGS because it's changed depending on which CTARGET
49
+	# we are building when pulling glibc on a multilib profile
50
+	CFLAGS_BASE=${CFLAGS_BASE-${CFLAGS}}
51
+	CFLAGS=${CFLAGS_BASE}
52
+	CXXFLAGS_BASE=${CXXFLAGS_BASE-${CXXFLAGS}}
53
+	CXXFLAGS=${CXXFLAGS_BASE}
54
+	ASFLAGS_BASE=${ASFLAGS_BASE-${ASFLAGS}}
55
+	ASFLAGS=${ASFLAGS_BASE}
56
+
57
+	# Over-zealous CFLAGS can often cause problems.  What may work for one
58
+	# person may not work for another.  To avoid a large influx of bugs
59
+	# relating to failed builds, we strip most CFLAGS out to ensure as few
60
+	# problems as possible.
61
+	strip-flags
62
+	strip-unsupported-flags
63
+	filter-flags -m32 -m64 -mabi=*
64
+
65
+	unset CBUILD_OPT CTARGET_OPT
66
+	if has_multilib_profile ; then
67
+		CTARGET_OPT=$(get_abi_CTARGET)
68
+		[[ -z ${CTARGET_OPT} ]] && CTARGET_OPT=$(get_abi_CHOST)
69
+	fi
70
+
71
+	case $(tc-arch) in
72
+		x86)
73
+			# -march needed for #185404
74
+			local t=${CTARGET_OPT:-${CTARGET}}
75
+			t=${t%%-*}
76
+			if ! echo "" | $(tc-getCC) ${CFLAGS} -E -dD - | grep -qs __${t}__ ; then
77
+				filter-flags '-march=*'
78
+				export CFLAGS="-march=${t} ${CFLAGS}"
79
+			fi
80
+		;;
81
+		amd64)
82
+			# Punt this when amd64's 2004.3 is removed
83
+			CFLAGS_x86="-m32"
84
+
85
+			# -march needed for #185404
86
+			local t=${CTARGET_OPT:-${CTARGET}}
87
+			t=${t%%-*}
88
+			if ! echo "" | $(tc-getCC) ${CFLAGS} ${CFLAGS_x86} -m32 -E -dD - | grep -qs __${t}__ ; then
89
+				filter-flags '-march=*'
90
+				export CFLAGS_x86="${CFLAGS_x86} -march=${t}"
91
+			fi
92
+		;;
93
+		ppc)
94
+			append-flags "-freorder-blocks"
95
+		;;
96
+		sparc)
97
+			# Both sparc and sparc64 can use -fcall-used-g6.  -g7 is bad, though.
98
+			filter-flags "-fcall-used-g7"
99
+			append-flags "-fcall-used-g6"
100
+			filter-flags "-mvis"
101
+
102
+			GLIBCMAJOR=$(get_version_component_range 1 ${PV})
103
+			GLIBCMINOR=$(get_version_component_range 2 ${PV})
104
+
105
+			# set CTARGET_OPT so glibc can use cpu-specific .S files for better performance
106
+			# - UltraSPARC T1 (niagara) support requires >= glibc 2.8
107
+			# - UltraSPARC T2 (niagara2) support requires >= glibc 2.7
108
+
109
+			if is_crosscompile || [[ ${PROFILE_ARCH} == "sparc64" ]] || { has_multilib_profile && ! tc-is-cross-compiler; } ; then
110
+				case ${ABI} in
111
+					sparc64)
112
+						filter-flags -Wa,-xarch -Wa,-A
113
+
114
+						if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
115
+							CTARGET_OPT="sparc64v2-unknown-linux-gnu"
116
+							append-flags "-Wa,-xarch=v9b"
117
+							export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
118
+						elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
119
+							CTARGET_OPT="sparc64v-unknown-linux-gnu"
120
+							append-flags "-Wa,-xarch=v9b"
121
+							export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
122
+						elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
123
+							CTARGET_OPT="sparc64b-unknown-linux-gnu"
124
+							append-flags "-Wa,-xarch=v9b"
125
+							export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9b"
126
+						else
127
+							CTARGET_OPT="sparc64-unknown-linux-gnu"
128
+							append-flags "-Wa,-xarch=v9a"
129
+							export ASFLAGS="${ASFLAGS} -Wa,-xarch=v9a"
130
+						fi
131
+					;;
132
+					*)
133
+						if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
134
+							CTARGET_OPT="sparcv9v2-unknown-linux-gnu"
135
+						elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
136
+							CTARGET_OPT="sparcv9v-unknown-linux-gnu"
137
+						elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
138
+							CTARGET_OPT="sparcv9b-unknown-linux-gnu"
139
+						else
140
+							CTARGET_OPT="sparcv9-unknown-linux-gnu"
141
+						fi
142
+					;;
143
+				esac
144
+			else
145
+				if is-flagq "-mcpu=niagara2" && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.7 ]] ; then
146
+					CTARGET_OPT="sparcv9v2-unknown-linux-gnu"
147
+				elif { is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2" ; } && [[ ${GLIBCMAJOR}.${GLIBCMINOR} > 2.6 ]] ; then
148
+					CTARGET_OPT="sparcv9v-unknown-linux-gnu"
149
+				elif is-flagq "-mcpu=ultrasparc3" || is-flagq "-mcpu=niagara" || is-flagq "-mcpu=niagara2"; then
150
+					CTARGET_OPT="sparcv9b-unknown-linux-gnu"
151
+				elif { is_crosscompile && want_nptl; } || is-flagq "-mcpu=ultrasparc2" || is-flagq "-mcpu=ultrasparc"; then
152
+					CTARGET_OPT="sparcv9-unknown-linux-gnu"
153
+				fi
154
+			fi
155
+		;;
156
+	esac
157
+
158
+	if [[ -n ${CTARGET_OPT} && ${CBUILD} == ${CHOST} ]] && ! is_crosscompile; then
159
+		CBUILD_OPT=${CTARGET_OPT}
160
+	fi
161
+
162
+	# Lock glibc at -O2 -- linuxthreads needs it and we want to be
163
+	# conservative here.  -fno-strict-aliasing is to work around #155906
164
+	filter-flags -O?
165
+	append-flags -O2 -fno-strict-aliasing
166
+
167
+	# Cant build glibc itself with fortify code
168
+	append-cppflags -U_FORTIFY_SOURCE
169
+
170
+	# building glibc with SSP is fraught with difficulty, especially
171
+	# due to __stack_chk_fail_local which would mean significant changes
172
+	# to the glibc build process. See bug #94325 #293721
173
+	use hardened && gcc-specs-ssp && append-cflags $(test-flags-CC -fno-stack-protector)
174
+
175
+	if use hardened && gcc-specs-pie ; then
176
+		# Force PIC macro definition for all compilations since they're all
177
+		# either -fPIC or -fPIE with the default-PIE compiler.
178
+		append-cppflags -DPIC
179
+	else
180
+		# Don't build -fPIE without the default-PIE compiler and the
181
+		# hardened-pie patch
182
+		filter-flags -fPIE
183
+	fi
184
+}
185
+
186
+want_nptl() {
187
+	[[ -z ${LT_VER} ]] && return 0
188
+	want_tls || return 1
189
+	use nptl || return 1
190
+
191
+	# Only list the arches that cannot do NPTL
192
+	case $(tc-arch) in
193
+		m68k) return 1;;
194
+		sparc)
195
+			# >= v9 is needed for nptl.
196
+			[[ ${PROFILE_ARCH} == "sparc" ]] && return 1
197
+		;;
198
+	esac
199
+
200
+	return 0
201
+}
202
+
203
+want_linuxthreads() {
204
+	[[ -z ${LT_VER} ]] && return 1
205
+	! use nptlonly && return 0
206
+	want_nptl || return 0
207
+	return 1
208
+}
209
+
210
+want_tls() {
211
+	# Archs that can use TLS (Thread Local Storage)
212
+	case $(tc-arch) in
213
+		sparc)
214
+			# 2.3.6 should have tls support on sparc64
215
+			# when using newer binutils
216
+			case ${CTARGET/-*} in
217
+				sparc64*) return 1 ;;
218
+				*) return 0 ;;
219
+			esac
220
+		;;
221
+		x86)
222
+			# requires i486 or better #106556
223
+			[[ ${CTARGET} == i[4567]86* ]] && return 0
224
+			return 1
225
+		;;
226
+	esac
227
+
228
+	return 0
229
+}
230
+
231
+want__thread() {
232
+	want_tls || return 1
233
+
234
+	# For some reason --with-tls --with__thread is causing segfaults on sparc32.
235
+	[[ ${PROFILE_ARCH} == "sparc" ]] && return 1
236
+
237
+	[[ -n ${WANT__THREAD} ]] && return ${WANT__THREAD}
238
+
239
+	# only test gcc -- cant test linking yet
240
+	tc-has-tls -c ${CTARGET}
241
+	WANT__THREAD=$?
242
+
243
+	return ${WANT__THREAD}
244
+}
245
+
246
+use_multilib() {
247
+	case ${CTARGET} in
248
+		sparc*|mips64*|x86_64*|powerpc64*|s390x*)
249
+			has_multilib_profile || use multilib ;;
250
+		*)  false ;;
251
+	esac
252
+}
253
+
254
+use_multiarch() {
255
+	# Make sure binutils is new enough to support indirect functions #336792
256
+	local bver=$($(tc-getLD ${CTARGET}) -v | awk '{print $NF}') nver
257
+	case $(tc-arch ${CTARGET}) in
258
+		amd64|x86) nver="2.20" ;;
259
+		sparc)     nver="2.21" ;;
260
+		*)         return 1 ;;
261
+	esac
262
+	version_is_at_least ${nver} ${bver}
263
+}
264
+
265
+# Setup toolchain variables that would be defined in the profiles for these archs.
266
+setup_env() {
267
+	# silly users
268
+	unset LD_RUN_PATH
269
+
270
+	if is_crosscompile || tc-is-cross-compiler ; then
271
+		multilib_env ${CTARGET}
272
+		if ! use multilib ; then
273
+			MULTILIB_ABIS=${DEFAULT_ABI}
274
+		else
275
+			MULTILIB_ABIS=${MULTILIB_ABIS:-${DEFAULT_ABI}}
276
+		fi
277
+
278
+		# If the user has CFLAGS_<CTARGET> in their make.conf, use that,
279
+		# and fall back on CFLAGS.
280
+		local VAR=CFLAGS_${CTARGET//[-.]/_}
281
+		CFLAGS=${!VAR-${CFLAGS}}
282
+	fi
283
+
284
+	setup_flags
285
+
286
+	export ABI=${ABI:-${DEFAULT_ABI:-default}}
287
+
288
+	if is_crosscompile || tc-is-cross-compiler ; then
289
+		local VAR=CFLAGS_${ABI}
290
+		# We need to export CFLAGS with abi information in them because
291
+		# glibc's configure script checks CFLAGS for some targets (like mips)
292
+		export CFLAGS="${!VAR} ${CFLAGS}"
293
+	fi
294
+}
295
+
296
+just_headers() {
297
+	is_crosscompile && use crosscompile_opts_headers-only
298
+}
... ...
@@ -0,0 +1,29 @@
1
+# Copyright 1999-2009 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_postinst.eblit,v 1.1 2009/03/01 21:06:22 vapier Exp $
4
+
5
+eblit-glibc-pkg_postinst() {
6
+	# nothing to do if just installing headers
7
+	just_headers && return
8
+
9
+	if ! tc-is-cross-compiler && [[ -x ${ROOT}/usr/sbin/iconvconfig ]] ; then
10
+		# Generate fastloading iconv module configuration file.
11
+		"${ROOT}"/usr/sbin/iconvconfig --prefix="${ROOT}"
12
+	fi
13
+
14
+	if ! is_crosscompile && [[ ${ROOT} == "/" ]] ; then
15
+		# Reload init ... if in a chroot or a diff init package, ignore
16
+		# errors from this step #253697
17
+		/sbin/telinit U 2>/dev/null
18
+
19
+		# if the host locales.gen contains no entries, we'll install everything
20
+		local locale_list="${ROOT}etc/locale.gen"
21
+		if [[ -z $(locale-gen --list --config "${locale_list}") ]] ; then
22
+			ewarn "Generating all locales; edit /etc/locale.gen to save time/space"
23
+			locale_list="${ROOT}usr/share/i18n/SUPPORTED"
24
+		fi
25
+		local x jobs
26
+		for x in ${MAKEOPTS} ; do [[ ${x} == -j* ]] && jobs=${x#-j} ; done
27
+		locale-gen -j ${jobs:-1} --config "${locale_list}"
28
+	fi
29
+}
... ...
@@ -0,0 +1,90 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_preinst.eblit,v 1.3 2010/10/08 15:33:13 flameeyes Exp $
4
+
5
+fix_lib64_symlinks() {
6
+	# the original Gentoo/AMD64 devs decided that since 64bit is the native
7
+	# bitdepth for AMD64, lib should be used for 64bit libraries. however,
8
+	# this ignores the FHS and breaks multilib horribly... especially
9
+	# since it wont even work without a lib64 symlink anyways. *rolls eyes*
10
+	# see bug 59710 for more information.
11
+	# Travis Tilley <lv@gentoo.org> (08 Aug 2004)
12
+	if [ -L ${ROOT}/lib64 ] ; then
13
+		ewarn "removing /lib64 symlink and moving lib to lib64..."
14
+		ewarn "dont hit ctrl-c until this is done"
15
+		rm ${ROOT}/lib64
16
+		# now that lib64 is gone, nothing will run without calling ld.so
17
+		# directly. luckily the window of brokenness is almost non-existant
18
+		use amd64 && /lib/ld-linux-x86-64.so.2 /bin/mv ${ROOT}/lib ${ROOT}/lib64
19
+		use ppc64 && /lib/ld64.so.1 /bin/mv ${ROOT}/lib ${ROOT}/lib64
20
+		# all better :)
21
+		ldconfig
22
+		ln -s lib64 ${ROOT}/lib
23
+		einfo "done! :-)"
24
+		einfo "fixed broken lib64/lib symlink in ${ROOT}"
25
+	fi
26
+	if [ -L ${ROOT}/usr/lib64 ] ; then
27
+		rm ${ROOT}/usr/lib64
28
+		mv ${ROOT}/usr/lib ${ROOT}/usr/lib64
29
+		ln -s lib64 ${ROOT}/usr/lib
30
+		einfo "fixed broken lib64/lib symlink in ${ROOT}/usr"
31
+	fi
32
+	if [ -L ${ROOT}/usr/X11R6/lib64 ] ; then
33
+		rm ${ROOT}/usr/X11R6/lib64
34
+		mv ${ROOT}/usr/X11R6/lib ${ROOT}/usr/X11R6/lib64
35
+		ln -s lib64 ${ROOT}/usr/X11R6/lib
36
+		einfo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
37
+	fi
38
+}
39
+
40
+eblit-glibc-pkg_preinst() {
41
+	# nothing to do if just installing headers
42
+	just_headers && return
43
+
44
+	# PPC64+others may want to eventually be added to this logic if they
45
+	# decide to be multilib compatible and FHS compliant. note that this
46
+	# chunk of FHS compliance only applies to 64bit archs where 32bit
47
+	# compatibility is a major concern (not IA64, for example).
48
+
49
+	# amd64's 2005.0 is the first amd64 profile to not need this code.
50
+	# 2005.0 is setup properly, and this is executed as part of the
51
+	# 2004.3 -> 2005.0 upgrade script.
52
+	# It can be removed after 2004.3 has been purged from portage.
53
+	{ use amd64 || use ppc64; } && [ "$(get_libdir)" == "lib64" ] && ! has_multilib_profile && fix_lib64_symlinks
54
+
55
+	# it appears that /lib/tls is sometimes not removed.  See bug
56
+	# 69258 for more info.
57
+	if [[ -d ${ROOT}/$(alt_libdir)/tls ]] && [[ ! -d ${D}/$(alt_libdir)/tls ]] ; then
58
+		ewarn "nptlonly or -nptl in USE, removing /${ROOT}$(alt_libdir)/tls..."
59
+		rm -r "${ROOT}"/$(alt_libdir)/tls || die
60
+	fi
61
+
62
+	# prepare /etc/ld.so.conf.d/ for files
63
+	mkdir -p "${ROOT}"/etc/ld.so.conf.d
64
+
65
+	# simple test to make sure our new glibc isnt completely broken.
66
+	# make sure we don't test with statically built binaries since
67
+	# they will fail.  also, skip if this glibc is a cross compiler.
68
+	[[ ${ROOT} != "/" ]] && return 0
69
+	[[ -d ${D}/$(get_libdir) ]] || return 0
70
+	cd / #228809
71
+	local x striptest
72
+	for x in date env ls true uname ; do
73
+		x=$(type -p ${x})
74
+		[[ -z ${x} ]] && continue
75
+		striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
76
+		[[ -z ${striptest} ]] && continue
77
+		[[ ${striptest} == *"statically linked"* ]] && continue
78
+		# we enter ${D} so to avoid trouble if the path contains
79
+		# special characters; for instance if the path contains the
80
+		# colon character (:), then the linker will try to split it
81
+		# and look for the libraries in an unexpected place. This can
82
+		# lead to unsafe code execution if the generated prefix is
83
+		# within a world-writable directory
84
+		# (e.g. /var/tmp/portage:${HOSTNAME})
85
+		pushd "${D}"/$(get_libdir) 2>/dev/null
86
+		./ld-*.so --library-path . ${x} > /dev/null \
87
+			|| die "simple run test (${x}) failed"
88
+		popd 2>/dev/null
89
+	done
90
+}
... ...
@@ -0,0 +1,67 @@
1
+# Copyright 1999-2009 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_setup.eblit,v 1.4 2009/08/21 05:46:04 vapier Exp $
4
+
5
+eblit-glibc-pkg_setup() {
6
+	# prevent native builds from downgrading ... maybe update to allow people
7
+	# to change between diff -r versions ? (2.3.6-r4 -> 2.3.6-r2)
8
+	if [[ ${ROOT} == "/" ]] && [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
9
+		if has_version '>'${CATEGORY}/${PF} ; then
10
+			eerror "Sanity check to keep you from breaking your system:"
11
+			eerror " Downgrading glibc is not supported and a sure way to destruction"
12
+			die "aborting to save your system"
13
+		fi
14
+
15
+		# Check for broken kernels #262698
16
+		cd "${T}"
17
+		printf '#include <pwd.h>\nint main(){return getpwuid(0)==0;}\n' > kern-clo-test.c
18
+		emake kern-clo-test || die
19
+		if ! ./kern-clo-test ; then
20
+			eerror "Your patched vendor kernel is broken.  You need to get an"
21
+			eerror "update from whoever is providing the kernel to you."
22
+			eerror "http://sourceware.org/bugzilla/show_bug.cgi?id=5227"
23
+			die "keeping your system alive, say thank you"
24
+		fi
25
+
26
+		# Check for broken kernels #279260
27
+		cd "${T}"
28
+		printf '#include <unistd.h>\n#include <sys/syscall.h>\nint main(){return syscall(1000)!=-1;}\n' > kern-enosys-test.c
29
+		emake kern-enosys-test || die
30
+		if ! ./kern-enosys-test ; then
31
+			eerror "Your old kernel is broken.  You need to update it to"
32
+			eerror "a newer version as syscall(<bignum>) will break."
33
+			eerror "http://bugs.gentoo.org/279260"
34
+			die "keeping your system alive, say thank you"
35
+		fi
36
+	fi
37
+
38
+	# users have had a chance to phase themselves, time to give em the boot
39
+	if [[ -e ${ROOT}/etc/locale.gen ]] && [[ -e ${ROOT}/etc/locales.build ]] ; then
40
+		eerror "You still haven't deleted ${ROOT}/etc/locales.build."
41
+		eerror "Do so now after making sure ${ROOT}/etc/locale.gen is kosher."
42
+		die "lazy upgrader detected"
43
+	fi
44
+
45
+	if [[ ${CTARGET} == i386-* ]] ; then
46
+		eerror "i386 CHOSTs are no longer supported."
47
+		eerror "Chances are you don't actually want/need i386."
48
+		eerror "Please read http://www.gentoo.org/doc/en/change-chost.xml"
49
+		die "please fix your CHOST"
50
+	fi
51
+
52
+	if [[ -n ${LT_VER} ]] ; then
53
+		if use nptlonly && ! use nptl ; then
54
+			eerror "If you want nptlonly, add nptl to your USE too ;p"
55
+			die "nptlonly without nptl"
56
+		fi
57
+	fi
58
+
59
+	if [[ -e /proc/xen ]] && [[ $(tc-arch) == "x86" ]] && ! is-flag -mno-tls-direct-seg-refs ; then
60
+		ewarn "You are using Xen but don't have -mno-tls-direct-seg-refs in your CFLAGS."
61
+		ewarn "This will result in a 50% performance penalty when running with a 32bit"
62
+		ewarn "hypervisor, which is probably not what you want."
63
+	fi
64
+
65
+	use hardened && ! gcc-specs-pie && \
66
+		ewarn "PIE hardening not applied, as your compiler doesn't default to PIE"
67
+}
... ...
@@ -0,0 +1,208 @@
1
+# Copyright 1999-2007 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_compile-2.11.2.eblit,v 1.1 2010/08/10 08:08:05 vapier Exp $
4
+
5
+glibc_do_configure() {
6
+	local myconf
7
+
8
+	# set addons
9
+	pushd "${S}" > /dev/null
10
+	local ADDONS=$(echo */configure | sed \
11
+		-e 's:/configure::g' \
12
+		-e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
13
+		-e 's: \+$::' \
14
+		-e 's! !,!g' \
15
+		-e 's!^!,!' \
16
+		-e '/^,\*$/d')
17
+	[[ -d ports ]] && ADDONS="${ADDONS},ports"
18
+	popd > /dev/null
19
+
20
+	use nls || myconf="${myconf} --disable-nls"
21
+	myconf="${myconf} $(use_enable hardened stackguard-randomization)"
22
+	if [[ $(<"${T}"/.ssp.compat) == "yes" ]] ; then
23
+		myconf="${myconf} --enable-old-ssp-compat"
24
+	else
25
+		myconf="${myconf} --disable-old-ssp-compat"
26
+	fi
27
+
28
+	use glibc-omitfp && myconf="${myconf} --enable-omitfp"
29
+
30
+	[[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
31
+
32
+	if [[ $1 == "linuxthreads" ]] ; then
33
+		if want_tls ; then
34
+			myconf="${myconf} --with-tls"
35
+
36
+			if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
37
+				myconf="${myconf} --without-__thread"
38
+			else
39
+				myconf="${myconf} --with-__thread"
40
+			fi
41
+		else
42
+			myconf="${myconf} --without-tls --without-__thread"
43
+		fi
44
+
45
+		myconf="${myconf} --disable-sanity-checks"
46
+		myconf="${myconf} --enable-add-ons=linuxthreads${ADDONS}"
47
+		myconf="${myconf} --enable-kernel=${LT_KER_VER}"
48
+	elif [[ $1 == "nptl" ]] ; then
49
+		myconf="${myconf} --enable-add-ons=nptl${ADDONS}"
50
+		myconf="${myconf} --enable-kernel=${NPTL_KERN_VER}"
51
+	else
52
+		die "invalid pthread option"
53
+	fi
54
+
55
+	# Since SELinux support is only required for nscd, only enable it if:
56
+	# 1. USE selinux
57
+	# 2. only for the primary ABI on multilib systems
58
+	# 3. Not a crosscompile
59
+	if ! is_crosscompile && use selinux ; then
60
+		if use multilib || has_multilib_profile ; then
61
+			if is_final_abi ; then
62
+				myconf="${myconf} --with-selinux"
63
+			else
64
+				myconf="${myconf} --without-selinux"
65
+			fi
66
+		else
67
+			myconf="${myconf} --with-selinux"
68
+		fi
69
+	else
70
+		myconf="${myconf} --without-selinux"
71
+	fi
72
+
73
+	myconf="${myconf}
74
+		--without-cvs
75
+		--enable-bind-now
76
+		--build=${CBUILD_OPT:-${CBUILD}}
77
+		--host=${CTARGET_OPT:-${CTARGET}}
78
+		$(use_enable profile)
79
+		$(use_with gd)
80
+		--with-headers=$(alt_build_headers)
81
+		--prefix=/usr
82
+		--libdir=/usr/$(get_libdir)
83
+		--mandir=/usr/share/man
84
+		--infodir=/usr/share/info
85
+		--libexecdir=/usr/$(get_libdir)/misc/glibc
86
+		${EXTRA_ECONF}"
87
+
88
+	# There is no configure option for this and we need to export it
89
+	# since the glibc build will re-run configure on itself
90
+	export libc_cv_slibdir=/$(get_libdir)
91
+
92
+	has_version app-admin/eselect-compiler || export CC=$(tc-getCC ${CTARGET})
93
+
94
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
95
+	mkdir -p "${GBUILDDIR}"
96
+	cd "${GBUILDDIR}"
97
+	einfo "Configuring GLIBC for $1 with: ${myconf// /\n\t\t}"
98
+	"${S}"/configure ${myconf} || die "failed to configure glibc"
99
+
100
+	# since we'll be punting them for cross-compilers, and they can cause
101
+	# problems (ia64+static), we'll just skip building altogether
102
+	is_crosscompile && sed -i '1ibuild-programs = no' config.make
103
+}
104
+
105
+toolchain-glibc_src_compile() {
106
+	echo
107
+	local v
108
+	for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
109
+		einfo " $(printf '%15s' ${v}:)   ${!v}"
110
+	done
111
+	echo
112
+
113
+	if want_linuxthreads ; then
114
+		glibc_do_configure linuxthreads
115
+		einfo "Building GLIBC with linuxthreads..."
116
+		make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
117
+	fi
118
+	if want_nptl ; then
119
+		# ... and then do the optional nptl build
120
+		unset LD_ASSUME_KERNEL
121
+		glibc_do_configure nptl
122
+		einfo "Building GLIBC with NPTL..."
123
+		make PARALLELMFLAGS="${MAKEOPTS}" || die "make for ${ABI} failed"
124
+	fi
125
+}
126
+
127
+toolchain-glibc_headers_compile() {
128
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
129
+	mkdir -p "${GBUILDDIR}"
130
+	cd "${GBUILDDIR}"
131
+
132
+	# if we don't have a compiler yet, we cant really test it now ...
133
+	# hopefully they don't affect header geneation, so let's hope for
134
+	# the best here ...
135
+	export \
136
+		libc_cv_386_tls=yes \
137
+		libc_cv_asm_cfi_directives=yes \
138
+		libc_cv_broken_visibility_attribute=no \
139
+		libc_cv_gcc___thread=yes \
140
+		libc_cv_mlong_double_128=yes \
141
+		libc_cv_mlong_double_128ibm=yes \
142
+		libc_cv_ppc_machine=yes \
143
+		libc_cv_visibility_attribute=yes \
144
+		libc_cv_z_combreloc=yes \
145
+		libc_cv_z_execstack=yes \
146
+		libc_cv_z_initfirst=yes \
147
+		libc_cv_z_nodelete=yes \
148
+		libc_cv_z_nodlopen=yes \
149
+		libc_cv_z_relro=yes
150
+
151
+	# Pick out the correct location for build headers
152
+	local ports="" myconf="--disable-sanity-checks --enable-hacker-mode"
153
+	[[ -d ${S}/ports ]] && ports=",ports"
154
+	myconf="${myconf}
155
+		--enable-add-ons=nptl${ports}
156
+		--without-cvs
157
+		--enable-bind-now
158
+		--build=${CBUILD_OPT:-${CBUILD}}
159
+		--host=${CTARGET_OPT:-${CTARGET}}
160
+		--with-headers=$(alt_build_headers)
161
+		--prefix=/usr
162
+		${EXTRA_ECONF}"
163
+
164
+	# Nothing is compiled here which would affect the headers for the target.
165
+	# so forcing CC/CFLAGS is sane.  unless you dont have `gcc`.  then i
166
+	# dont care :p.
167
+	einfo "Configuring GLIBC headers with: ${myconf// /\n\t\t}"
168
+	CC=gcc \
169
+	CFLAGS="-O1 -pipe" \
170
+	"${S}"/configure ${myconf} || die "failed to configure glibc"
171
+}
172
+
173
+eblit-glibc-src_compile() {
174
+	if is_crosscompile ; then
175
+		export \
176
+			libc_cv_c_cleanup=yes \
177
+			libc_cv_forced_unwind=yes
178
+	fi
179
+
180
+	if just_headers ; then
181
+		toolchain-glibc_headers_compile
182
+		return
183
+	fi
184
+
185
+	setup_env
186
+
187
+	if [[ -z ${OABI} ]] ; then
188
+		local abilist=""
189
+		if has_multilib_profile ; then
190
+			abilist=$(get_install_abis)
191
+			einfo "Building multilib glibc for ABIs: ${abilist}"
192
+		elif is_crosscompile || tc-is-cross-compiler ; then
193
+			abilist=${DEFAULT_ABI}
194
+		fi
195
+		if [[ -n ${abilist} ]] ; then
196
+			OABI=${ABI}
197
+			for ABI in ${abilist} ; do
198
+				export ABI
199
+				src_compile
200
+			done
201
+			ABI=${OABI}
202
+			unset OABI
203
+			return 0
204
+		fi
205
+	fi
206
+
207
+	toolchain-glibc_src_compile
208
+}
... ...
@@ -0,0 +1,210 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_compile.eblit,v 1.15 2010/09/30 06:29:21 vapier Exp $
4
+
5
+glibc_do_configure() {
6
+	local myconf
7
+
8
+	einfo "Configuring GLIBC for $1"
9
+
10
+	# set addons
11
+	pushd "${S}" > /dev/null
12
+	local ADDONS=$(echo */configure | sed \
13
+		-e 's:/configure::g' \
14
+		-e 's:\(linuxthreads\|nptl\|rtkaio\|glibc-compat\)\( \|$\)::g' \
15
+		-e 's: \+$::' \
16
+		-e 's! !,!g' \
17
+		-e 's!^!,!' \
18
+		-e '/^,\*$/d')
19
+	[[ -d ports ]] && ADDONS="${ADDONS},ports"
20
+	popd > /dev/null
21
+
22
+	use nls || myconf="${myconf} --disable-nls"
23
+	myconf="${myconf} $(use_enable hardened stackguard-randomization)"
24
+	if [[ $(<"${T}"/.ssp.compat) == "yes" ]] ; then
25
+		myconf="${myconf} --enable-old-ssp-compat"
26
+	else
27
+		myconf="${myconf} --disable-old-ssp-compat"
28
+	fi
29
+
30
+	use glibc-omitfp && myconf="${myconf} --enable-omitfp"
31
+
32
+	[[ ${CTARGET//_/-} == *-softfloat-* ]] && myconf="${myconf} --without-fp"
33
+
34
+	if [[ $1 == "linuxthreads" ]] ; then
35
+		if want_tls ; then
36
+			myconf="${myconf} --with-tls"
37
+
38
+			if ! want__thread || use glibc-compat20 || [[ ${LT_KER_VER} == 2.[02].* ]] ; then
39
+				myconf="${myconf} --without-__thread"
40
+			else
41
+				myconf="${myconf} --with-__thread"
42
+			fi
43
+		else
44
+			myconf="${myconf} --without-tls --without-__thread"
45
+		fi
46
+
47
+		myconf="${myconf} --disable-sanity-checks"
48
+		myconf="${myconf} --enable-add-ons=linuxthreads${ADDONS}"
49
+		myconf="${myconf} --enable-kernel=${LT_KER_VER}"
50
+	elif [[ $1 == "nptl" ]] ; then
51
+		myconf="${myconf} --enable-add-ons=nptl${ADDONS}"
52
+		myconf="${myconf} --enable-kernel=${NPTL_KERN_VER}"
53
+	else
54
+		die "invalid pthread option"
55
+	fi
56
+
57
+	# Since SELinux support is only required for nscd, only enable it if:
58
+	# 1. USE selinux
59
+	# 2. only for the primary ABI on multilib systems
60
+	# 3. Not a crosscompile
61
+	if ! is_crosscompile && use selinux ; then
62
+		if use multilib || has_multilib_profile ; then
63
+			if is_final_abi ; then
64
+				myconf="${myconf} --with-selinux"
65
+			else
66
+				myconf="${myconf} --without-selinux"
67
+			fi
68
+		else
69
+			myconf="${myconf} --with-selinux"
70
+		fi
71
+	else
72
+		myconf="${myconf} --without-selinux"
73
+	fi
74
+
75
+	myconf="${myconf}
76
+		--without-cvs
77
+		--enable-bind-now
78
+		--build=${CBUILD_OPT:-${CBUILD}}
79
+		--host=${CTARGET_OPT:-${CTARGET}}
80
+		$(use_enable profile)
81
+		$(use_with gd)
82
+		--with-headers=$(alt_build_headers)
83
+		--prefix=/usr
84
+		--libdir=/usr/$(get_libdir)
85
+		--mandir=/usr/share/man
86
+		--infodir=/usr/share/info
87
+		--libexecdir=/usr/$(get_libdir)/misc/glibc
88
+		$(use_multiarch || echo --disable-multi-arch)
89
+		${EXTRA_ECONF}"
90
+
91
+	# There is no configure option for this and we need to export it
92
+	# since the glibc build will re-run configure on itself
93
+	export libc_cv_slibdir=/$(get_libdir)
94
+
95
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-$1
96
+	mkdir -p "${GBUILDDIR}"
97
+	cd "${GBUILDDIR}"
98
+	echo "${S}"/configure ${myconf}
99
+	"${S}"/configure ${myconf} || die "failed to configure glibc"
100
+
101
+	# since we'll be punting them for cross-compilers, and they can cause
102
+	# problems (ia64+static), we'll just skip building altogether
103
+	is_crosscompile && sed -i '1ibuild-programs = no' config.make
104
+}
105
+
106
+toolchain-glibc_src_compile() {
107
+	echo
108
+	local v
109
+	for v in ABI CBUILD CHOST CTARGET CBUILD_OPT CTARGET_OPT CC CFLAGS ; do
110
+		einfo " $(printf '%15s' ${v}:)   ${!v}"
111
+	done
112
+	export CC=$(tc-getCC ${CTARGET})
113
+	einfo " $(printf '%15s' 'Manual CC:')   ${CC}"
114
+	echo
115
+
116
+	if want_linuxthreads ; then
117
+		glibc_do_configure linuxthreads
118
+		emake || die "make for ${ABI} failed"
119
+	fi
120
+	if want_nptl ; then
121
+		# ... and then do the optional nptl build
122
+		unset LD_ASSUME_KERNEL
123
+		glibc_do_configure nptl
124
+		emake || die "make for ${ABI} failed"
125
+	fi
126
+}
127
+
128
+toolchain-glibc_headers_compile() {
129
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
130
+	mkdir -p "${GBUILDDIR}"
131
+	cd "${GBUILDDIR}"
132
+
133
+	# if we don't have a compiler yet, we cant really test it now ...
134
+	# hopefully they don't affect header geneation, so let's hope for
135
+	# the best here ...
136
+	export \
137
+		libc_cv_386_tls=yes \
138
+		libc_cv_asm_cfi_directives=yes \
139
+		libc_cv_broken_visibility_attribute=no \
140
+		libc_cv_gcc___thread=yes \
141
+		libc_cv_mlong_double_128=yes \
142
+		libc_cv_mlong_double_128ibm=yes \
143
+		libc_cv_ppc_machine=yes \
144
+		libc_cv_ppc_rel16=yes \
145
+		libc_cv_visibility_attribute=yes \
146
+		libc_cv_z_combreloc=yes \
147
+		libc_cv_z_execstack=yes \
148
+		libc_cv_z_initfirst=yes \
149
+		libc_cv_z_nodelete=yes \
150
+		libc_cv_z_nodlopen=yes \
151
+		libc_cv_z_relro=yes
152
+
153
+	# Pick out the correct location for build headers
154
+	local ports="" myconf="--disable-sanity-checks --enable-hacker-mode"
155
+	[[ -d ${S}/ports ]] && ports=",ports"
156
+	myconf="${myconf}
157
+		--enable-add-ons=nptl${ports}
158
+		--without-cvs
159
+		--enable-bind-now
160
+		--build=${CBUILD_OPT:-${CBUILD}}
161
+		--host=${CTARGET_OPT:-${CTARGET}}
162
+		--with-headers=$(alt_build_headers)
163
+		--prefix=/usr
164
+		${EXTRA_ECONF}"
165
+
166
+	# Nothing is compiled here which would affect the headers for the target.
167
+	# so forcing CC/CFLAGS is sane.  unless you dont have `gcc`.  then i
168
+	# dont care :p.
169
+	einfo "Configuring GLIBC headers with: ${myconf// /\n\t\t}"
170
+	CC=gcc \
171
+	CFLAGS="-O1 -pipe" \
172
+	"${S}"/configure ${myconf} || die "failed to configure glibc"
173
+}
174
+
175
+eblit-glibc-src_compile() {
176
+	if is_crosscompile ; then
177
+		export \
178
+			libc_cv_c_cleanup=yes \
179
+			libc_cv_forced_unwind=yes
180
+	fi
181
+
182
+	if just_headers ; then
183
+		toolchain-glibc_headers_compile
184
+		return
185
+	fi
186
+
187
+	setup_env
188
+
189
+	if [[ -z ${OABI} ]] ; then
190
+		local abilist=""
191
+		if has_multilib_profile ; then
192
+			abilist=$(get_install_abis)
193
+			einfo "Building multilib glibc for ABIs: ${abilist}"
194
+		elif is_crosscompile || tc-is-cross-compiler ; then
195
+			abilist=${DEFAULT_ABI}
196
+		fi
197
+		if [[ -n ${abilist} ]] ; then
198
+			OABI=${ABI}
199
+			for ABI in ${abilist} ; do
200
+				export ABI
201
+				src_compile
202
+			done
203
+			ABI=${OABI}
204
+			unset OABI
205
+			return 0
206
+		fi
207
+	fi
208
+
209
+	toolchain-glibc_src_compile
210
+}
... ...
@@ -0,0 +1,252 @@
1
+# Copyright 1999-2007 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_install-2.11.2.eblit,v 1.1 2010/08/10 08:08:05 vapier Exp $
4
+
5
+toolchain-glibc_src_install() {
6
+	local GBUILDDIR
7
+	if want_linuxthreads ; then
8
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
9
+	else
10
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
11
+	fi
12
+
13
+	local install_root=${D}
14
+	is_crosscompile && install_root="${install_root}/usr/${CTARGET}"
15
+	if want_linuxthreads ; then
16
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
17
+		einfo "Installing GLIBC ${ABI} with linuxthreads ..."
18
+	else # nptlonly
19
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
20
+		einfo "Installing GLIBC ${ABI} with NPTL ..."
21
+	fi
22
+	make PARALLELMFLAGS="${MAKEOPTS}" \
23
+		install_root="${install_root}" \
24
+		install || die
25
+
26
+	if is_crosscompile ; then
27
+		# punt all the junk not needed by a cross-compiler
28
+		cd "${D}"/usr/${CTARGET} || die
29
+		rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
30
+	fi
31
+
32
+	if want_linuxthreads && want_nptl ; then
33
+		einfo "Installing NPTL to $(alt_libdir)/tls/..."
34
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
35
+		dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
36
+
37
+		local l src_lib
38
+		for l in libc libm librt libpthread libthread_db ; do
39
+			# take care of shared lib first ...
40
+			l=${l}.so
41
+			if [[ -e ${l} ]] ; then
42
+				src_lib=${l}
43
+			else
44
+				src_lib=$(eval echo */${l})
45
+			fi
46
+			cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
47
+			fperms a+rx $(alt_libdir)/tls/${l}
48
+			dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
49
+
50
+			# then grab the linker script or the symlink ...
51
+			if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
52
+				dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
53
+			else
54
+				sed \
55
+					-e "s:/${l}:/tls/${l}:g" \
56
+					-e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
57
+					"${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
58
+			fi
59
+
60
+			# then grab the static lib ...
61
+			src_lib=${src_lib/%.so/.a}
62
+			[[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
63
+			cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
64
+			src_lib=${src_lib/%.a/_nonshared.a}
65
+			if [[ -e ${src_lib} ]] ; then
66
+				cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
67
+			fi
68
+		done
69
+
70
+		# use the nptl linker instead of the linuxthreads one as the linuxthreads
71
+		# one may lack TLS support and that can be really bad for business
72
+		cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
73
+	fi
74
+
75
+	# We'll take care of the cache ourselves
76
+	rm -f "${D}"/etc/ld.so.cache
77
+
78
+	# Some things want this, notably ash.
79
+	dosym libbsd-compat.a $(alt_usrlibdir)/libbsd.a
80
+
81
+	# Handle includes for different ABIs if glibc itself doesn't do it
82
+	# XXX: curr glibc should finally handle all of them correctly
83
+	#case $(tc-arch) in
84
+	#	amd64|mips|ppc|s390) ;;
85
+	#	*) prep_ml_includes $(alt_headers) ;;
86
+	#esac
87
+
88
+	# When cross-compiling for a non-multilib setup, make sure we have
89
+	# lib and a proper symlink setup
90
+	if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
91
+		cd "${D}"$(alt_libdir)/..
92
+		mv $(get_libdir) lib || die
93
+		ln -s lib $(get_libdir) || die
94
+		cd "${D}"$(alt_usrlibdir)/..
95
+		mv $(get_libdir) lib || die
96
+		ln -s lib $(get_libdir) || die
97
+	fi
98
+
99
+	#################################################################
100
+	# EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
101
+	# Make sure we install some symlink hacks so that when we build
102
+	# a 2nd stage cross-compiler, gcc finds the target system
103
+	# headers correctly.  See gcc/doc/gccinstall.info
104
+	if is_crosscompile ; then
105
+		dosym usr/include /usr/${CTARGET}/sys-include
106
+		return 0
107
+	fi
108
+
109
+	# Everything past this point just needs to be done once ...
110
+	is_final_abi || return 0
111
+
112
+	# Make sure the non-native interp can be found on multilib systems
113
+	if has_multilib_profile ; then
114
+		case $(tc-arch) in
115
+			amd64)
116
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
117
+				dosym ../$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
118
+				;;
119
+			ppc64)
120
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
121
+				dosym ../$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
122
+				;;
123
+		esac
124
+	fi
125
+
126
+	# Files for Debian-style locale updating
127
+	dodir /usr/share/i18n
128
+	sed \
129
+		-e "/^#/d" \
130
+		-e "/SUPPORTED-LOCALES=/d" \
131
+		-e "s: \\\\::g" -e "s:/: :g" \
132
+		"${S}"/localedata/SUPPORTED > "${D}"/usr/share/i18n/SUPPORTED \
133
+		|| die "generating /usr/share/i18n/SUPPORTED failed"
134
+	cd "${WORKDIR}"/extra/locale
135
+	dosbin locale-gen || die
136
+	doman *.[0-8]
137
+	insinto /etc
138
+	doins locale.gen || die
139
+
140
+	# Make sure all the ABI's can find the locales and so we only
141
+	# have to generate one set
142
+	local a
143
+	keepdir /usr/$(get_libdir)/locale
144
+	for a in $(get_install_abis) ; do
145
+		if [[ ! -e ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
146
+			dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
147
+		fi
148
+	done
149
+
150
+	if ! has noinfo ${FEATURES} && [[ -n ${INFOPAGE_VER} ]] ; then
151
+		einfo "Installing info pages..."
152
+
153
+		make \
154
+			-C "${GBUILDDIR}" \
155
+			PARALLELMFLAGS="${MAKEOPTS}" \
156
+			install_root="${install_root}" \
157
+			info -i || die
158
+	fi
159
+
160
+	if [[ -n ${MANPAGE_VER} ]] ; then
161
+		einfo "Installing man pages..."
162
+
163
+		# Install linuxthreads man pages even if nptl is enabled
164
+		cd "${WORKDIR}"/man
165
+		doman *.3thr
166
+	fi
167
+
168
+	cd "${S}"
169
+
170
+	# Install misc network config files
171
+	insinto /etc
172
+	doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
173
+	doins "${WORKDIR}"/extra/etc/*.conf || die
174
+	doinitd "${WORKDIR}"/extra/etc/nscd || die
175
+
176
+	sed -i -e "s:@PIDFILE@:$(strings "${D}"/usr/sbin/nscd | grep nscd.pid):" "${D}"/etc/init.d/nscd
177
+
178
+	echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
179
+	doenvd "${T}"/00glibc || die
180
+
181
+	dodoc BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README*
182
+
183
+	# Prevent overwriting of the /etc/localtime symlink.  We'll handle the
184
+	# creation of the "factory" symlink in pkg_postinst().
185
+	rm -f "${D}"/etc/localtime
186
+}
187
+
188
+toolchain-glibc_headers_install() {
189
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
190
+	cd "${GBUILDDIR}"
191
+	make install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
192
+	# Copy over headers that are not part of install-headers ... these
193
+	# are pretty much taken verbatim from crosstool, see it for more details
194
+	insinto $(alt_headers)/bits
195
+	doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
196
+	insinto $(alt_headers)/gnu
197
+	doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
198
+	# Make sure we install the sys-include symlink so that when
199
+	# we build a 2nd stage cross-compiler, gcc finds the target
200
+	# system headers correctly.  See gcc/doc/gccinstall.info
201
+	dosym usr/include /usr/${CTARGET}/sys-include
202
+}
203
+
204
+src_strip() {
205
+	# gdb is lame and requires some debugging information to remain in
206
+	# libpthread, so we need to strip it by hand.  libthread_db makes no
207
+	# sense stripped as it is only used when debugging.
208
+	local pthread=$(hasq splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
209
+	env \
210
+		-uRESTRICT \
211
+		CHOST=${CTARGET} \
212
+		STRIP_MASK="/*/{,tls/}${pthread}*" \
213
+		prepallstrip
214
+	# if user has stripping enabled and does not have split debug turned on,
215
+	# then leave the debugging sections in libpthread.
216
+	if ! hasq nostrip ${FEATURES} && ! hasq splitdebug ${FEATURES} ; then
217
+		${STRIP:-${CTARGET}-strip} --strip-debug "${D}"/*/libpthread-*.so
218
+	fi
219
+}
220
+
221
+eblit-glibc-src_install() {
222
+	if just_headers ; then
223
+		toolchain-glibc_headers_install
224
+		return
225
+	fi
226
+
227
+	setup_env
228
+
229
+	if [[ -z ${OABI} ]] ; then
230
+		local abilist=""
231
+		if has_multilib_profile ; then
232
+			abilist=$(get_install_abis)
233
+			einfo "Installing multilib glibc for ABIs: ${abilist}"
234
+		elif is_crosscompile || tc-is-cross-compiler ; then
235
+			abilist=${DEFAULT_ABI}
236
+		fi
237
+		if [[ -n ${abilist} ]] ; then
238
+			OABI=${ABI}
239
+			for ABI in ${abilist} ; do
240
+				export ABI
241
+				eblit-glibc-src_install
242
+			done
243
+			ABI=${OABI}
244
+			unset OABI
245
+			src_strip
246
+			return 0
247
+		fi
248
+	fi
249
+
250
+	toolchain-glibc_src_install
251
+	[[ -z ${OABI} ]] && src_strip
252
+}
... ...
@@ -0,0 +1,250 @@
1
+# Copyright 1999-2007 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_install-2.6.eblit,v 1.2 2008/06/29 16:39:23 vapier Exp $
4
+
5
+toolchain-glibc_src_install() {
6
+	# These should not be set, else the
7
+	# zoneinfo do not always get installed ...
8
+	unset LANGUAGE LANG LC_ALL
9
+
10
+	local GBUILDDIR
11
+	if want_linuxthreads ; then
12
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
13
+	else
14
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
15
+	fi
16
+
17
+	local install_root=${D}
18
+	is_crosscompile && install_root="${install_root}/usr/${CTARGET}"
19
+	if want_linuxthreads ; then
20
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
21
+		einfo "Installing GLIBC ${ABI} with linuxthreads ..."
22
+		make PARALLELMFLAGS="${MAKEOPTS}" \
23
+			install_root="${install_root}" \
24
+			install || die
25
+	else # nptlonly
26
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
27
+		einfo "Installing GLIBC ${ABI} with NPTL ..."
28
+		make PARALLELMFLAGS="${MAKEOPTS}" \
29
+			install_root="${install_root}" \
30
+			install || die
31
+	fi
32
+
33
+	if is_crosscompile ; then
34
+		# punt all the junk not needed by a cross-compiler
35
+		cd "${D}"/usr/${CTARGET} || die
36
+		rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
37
+	fi
38
+
39
+	if want_linuxthreads && want_nptl ; then
40
+		einfo "Installing NPTL to $(alt_libdir)/tls/..."
41
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
42
+		dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
43
+
44
+		local l src_lib
45
+		for l in libc libm librt libpthread libthread_db ; do
46
+			# take care of shared lib first ...
47
+			l=${l}.so
48
+			if [[ -e ${l} ]] ; then
49
+				src_lib=${l}
50
+			else
51
+				src_lib=$(eval echo */${l})
52
+			fi
53
+			cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
54
+			fperms a+rx $(alt_libdir)/tls/${l}
55
+			dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
56
+
57
+			# then grab the linker script or the symlink ...
58
+			if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
59
+				dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
60
+			else
61
+				sed \
62
+					-e "s:/${l}:/tls/${l}:g" \
63
+					-e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
64
+					"${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
65
+			fi
66
+
67
+			# then grab the static lib ...
68
+			src_lib=${src_lib/%.so/.a}
69
+			[[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
70
+			cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
71
+			src_lib=${src_lib/%.a/_nonshared.a}
72
+			if [[ -e ${src_lib} ]] ; then
73
+				cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
74
+			fi
75
+		done
76
+
77
+		# use the nptl linker instead of the linuxthreads one as the linuxthreads
78
+		# one may lack TLS support and that can be really bad for business
79
+		cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
80
+	fi
81
+
82
+	# We'll take care of the cache ourselves
83
+	rm -f "${D}"/etc/ld.so.cache
84
+
85
+	# Some things want this, notably ash.
86
+	dosym libbsd-compat.a $(alt_usrlibdir)/libbsd.a
87
+
88
+	# Handle includes for different ABIs
89
+	prep_ml_includes $(alt_headers)
90
+
91
+	# When cross-compiling for a non-multilib setup, make sure we have
92
+	# lib and a proper symlink setup
93
+	if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
94
+		cd "${D}"$(alt_libdir)/..
95
+		mv $(get_libdir) lib || die
96
+		ln -s lib $(get_libdir) || die
97
+		cd "${D}"$(alt_usrlibdir)/..
98
+		mv $(get_libdir) lib || die
99
+		ln -s lib $(get_libdir) || die
100
+	fi
101
+
102
+	#################################################################
103
+	# EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
104
+	# Make sure we install some symlink hacks so that when we build
105
+	# a 2nd stage cross-compiler, gcc finds the target system
106
+	# headers correctly.  See gcc/doc/gccinstall.info
107
+	if is_crosscompile ; then
108
+		dosym usr/include /usr/${CTARGET}/sys-include
109
+		return 0
110
+	fi
111
+
112
+	# Everything past this point just needs to be done once ...
113
+	is_final_abi || return 0
114
+
115
+	# Make sure the non-native interp can be found on multilib systems
116
+	if has_multilib_profile ; then
117
+		case $(tc-arch) in
118
+			amd64)
119
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
120
+				dosym ../$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
121
+				;;
122
+			ppc64)
123
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
124
+				dosym ../$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
125
+				;;
126
+		esac
127
+	fi
128
+
129
+	# Files for Debian-style locale updating
130
+	dodir /usr/share/i18n
131
+	sed \
132
+		-e "/^#/d" \
133
+		-e "/SUPPORTED-LOCALES=/d" \
134
+		-e "s: \\\\::g" -e "s:/: :g" \
135
+		"${S}"/localedata/SUPPORTED > "${D}"/usr/share/i18n/SUPPORTED \
136
+		|| die "generating /usr/share/i18n/SUPPORTED failed"
137
+	cd "${WORKDIR}"/extra/locale
138
+	dosbin locale-gen || die
139
+	doman *.[0-8]
140
+	insinto /etc
141
+	doins locale.gen || die
142
+
143
+	# Make sure all the ABI's can find the locales and so we only
144
+	# have to generate one set
145
+	local a
146
+	keepdir /usr/$(get_libdir)/locale
147
+	for a in $(get_install_abis) ; do
148
+		if [[ ! -e ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
149
+			dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
150
+		fi
151
+	done
152
+
153
+	if ! has noinfo ${FEATURES} && [[ -n ${INFOPAGE_VER} ]] ; then
154
+		einfo "Installing info pages..."
155
+
156
+		make \
157
+			-C "${GBUILDDIR}" \
158
+			PARALLELMFLAGS="${MAKEOPTS}" \
159
+			install_root="${install_root}" \
160
+			info -i || die
161
+	fi
162
+
163
+	if [[ -n ${MANPAGE_VER} ]] ; then
164
+		einfo "Installing man pages..."
165
+
166
+		# Install linuxthreads man pages even if nptl is enabled
167
+		cd "${WORKDIR}"/man
168
+		doman *.3thr
169
+	fi
170
+
171
+	cd "${S}"
172
+
173
+	# Install misc network config files
174
+	insinto /etc
175
+	doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
176
+	doins "${WORKDIR}"/extra/etc/*.conf || die
177
+	doinitd "${WORKDIR}"/extra/etc/nscd || die
178
+
179
+	dodoc BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README*
180
+
181
+	# Prevent overwriting of the /etc/localtime symlink.  We'll handle the
182
+	# creation of the "factory" symlink in pkg_postinst().
183
+	rm -f "${D}"/etc/localtime
184
+}
185
+
186
+toolchain-glibc_headers_install() {
187
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
188
+	cd "${GBUILDDIR}"
189
+	make install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
190
+	# Copy over headers that are not part of install-headers ... these
191
+	# are pretty much taken verbatim from crosstool, see it for more details
192
+	insinto $(alt_headers)/bits
193
+	doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
194
+	insinto $(alt_headers)/gnu
195
+	doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
196
+	# Make sure we install the sys-include symlink so that when
197
+	# we build a 2nd stage cross-compiler, gcc finds the target
198
+	# system headers correctly.  See gcc/doc/gccinstall.info
199
+	dosym usr/include /usr/${CTARGET}/sys-include
200
+}
201
+
202
+src_strip() {
203
+	# gdb is lame and requires some debugging information to remain in
204
+	# libpthread, so we need to strip it by hand.  libthread_db makes no
205
+	# sense stripped as it is only used when debugging.
206
+	local pthread=$(hasq splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
207
+	env \
208
+		-uRESTRICT \
209
+		CHOST=${CTARGET} \
210
+		STRIP_MASK="/*/{,tls/}${pthread}*" \
211
+		prepallstrip
212
+	# if user has stripping enabled and does not have split debug turned on,
213
+	# then leave the debugging sections in libpthread.
214
+	if ! hasq nostrip ${FEATURES} && ! hasq splitdebug ${FEATURES} ; then
215
+		${STRIP:-${CTARGET}-strip} --strip-debug "${D}"/*/libpthread-*.so
216
+	fi
217
+}
218
+
219
+eblit-glibc-src_install() {
220
+	if just_headers ; then
221
+		toolchain-glibc_headers_install
222
+		return
223
+	fi
224
+
225
+	setup_env
226
+
227
+	if [[ -z ${OABI} ]] ; then
228
+		local abilist=""
229
+		if has_multilib_profile ; then
230
+			abilist=$(get_install_abis)
231
+			einfo "Installing multilib glibc for ABIs: ${abilist}"
232
+		elif is_crosscompile || tc-is-cross-compiler ; then
233
+			abilist=${DEFAULT_ABI}
234
+		fi
235
+		if [[ -n ${abilist} ]] ; then
236
+			OABI=${ABI}
237
+			for ABI in ${abilist} ; do
238
+				export ABI
239
+				eblit-glibc-src_install
240
+			done
241
+			ABI=${OABI}
242
+			unset OABI
243
+			src_strip
244
+			return 0
245
+		fi
246
+	fi
247
+
248
+	toolchain-glibc_src_install
249
+	[[ -z ${OABI} ]] && src_strip
250
+}
... ...
@@ -0,0 +1,249 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_install.eblit,v 1.10 2010/08/10 08:08:05 vapier Exp $
4
+
5
+toolchain-glibc_src_install() {
6
+	local GBUILDDIR
7
+	if want_linuxthreads ; then
8
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-linuxthreads
9
+	else
10
+		GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-nptl
11
+	fi
12
+
13
+	local install_root=${D}
14
+	is_crosscompile && install_root="${install_root}/usr/${CTARGET}"
15
+	if want_linuxthreads ; then
16
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-linuxthreads
17
+		einfo "Installing GLIBC ${ABI} with linuxthreads ..."
18
+	else # nptlonly
19
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
20
+		einfo "Installing GLIBC ${ABI} with NPTL ..."
21
+	fi
22
+	emake install_root="${install_root}" install || die
23
+
24
+	if is_crosscompile ; then
25
+		# punt all the junk not needed by a cross-compiler
26
+		cd "${D}"/usr/${CTARGET} || die
27
+		rm -rf ./{,usr/}{bin,etc,sbin,share} ./{,usr/}*/{gconv,misc}
28
+	fi
29
+
30
+	if want_linuxthreads && want_nptl ; then
31
+		einfo "Installing NPTL to $(alt_libdir)/tls/..."
32
+		cd "${WORKDIR}"/build-${ABI}-${CTARGET}-nptl
33
+		dodir $(alt_libdir)/tls $(alt_usrlibdir)/nptl
34
+
35
+		local l src_lib
36
+		for l in libc libm librt libpthread libthread_db ; do
37
+			# take care of shared lib first ...
38
+			l=${l}.so
39
+			if [[ -e ${l} ]] ; then
40
+				src_lib=${l}
41
+			else
42
+				src_lib=$(eval echo */${l})
43
+			fi
44
+			cp -a ${src_lib} "${D}"$(alt_libdir)/tls/${l} || die "copying nptl ${l}"
45
+			fperms a+rx $(alt_libdir)/tls/${l}
46
+			dosym ${l} $(alt_libdir)/tls/$(scanelf -qSF'%S#F' ${src_lib})
47
+
48
+			# then grab the linker script or the symlink ...
49
+			if [[ -L ${D}$(alt_usrlibdir)/${l} ]] ; then
50
+				dosym $(alt_libdir)/tls/${l} $(alt_usrlibdir)/nptl/${l}
51
+			else
52
+				sed \
53
+					-e "s:/${l}:/tls/${l}:g" \
54
+					-e "s:/${l/%.so/_nonshared.a}:/nptl/${l/%.so/_nonshared.a}:g" \
55
+					"${D}"$(alt_usrlibdir)/${l} > "${D}"$(alt_usrlibdir)/nptl/${l}
56
+			fi
57
+
58
+			# then grab the static lib ...
59
+			src_lib=${src_lib/%.so/.a}
60
+			[[ ! -e ${src_lib} ]] && src_lib=${src_lib/%.a/_pic.a}
61
+			cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
62
+			src_lib=${src_lib/%.a/_nonshared.a}
63
+			if [[ -e ${src_lib} ]] ; then
64
+				cp -a ${src_lib} "${D}"$(alt_usrlibdir)/nptl/ || die "copying nptl ${src_lib}"
65
+			fi
66
+		done
67
+
68
+		# use the nptl linker instead of the linuxthreads one as the linuxthreads
69
+		# one may lack TLS support and that can be really bad for business
70
+		cp -a elf/ld.so "${D}"$(alt_libdir)/$(scanelf -qSF'%S#F' elf/ld.so) || die "copying nptl interp"
71
+	fi
72
+
73
+	# We'll take care of the cache ourselves
74
+	rm -f "${D}"/etc/ld.so.cache
75
+
76
+	# Some things want this, notably ash.
77
+	dosym libbsd-compat.a $(alt_usrlibdir)/libbsd.a
78
+
79
+	# Handle includes for different ABIs if glibc itself doesn't do it
80
+	# XXX: curr glibc should finally handle all of them correctly
81
+	#case $(tc-arch) in
82
+	#	amd64|mips|ppc|s390) ;;
83
+	#	*) prep_ml_includes $(alt_headers) ;;
84
+	#esac
85
+
86
+	# When cross-compiling for a non-multilib setup, make sure we have
87
+	# lib and a proper symlink setup
88
+	if is_crosscompile && ! use multilib && ! has_multilib_profile && [[ $(get_libdir) != "lib" ]] ; then
89
+		cd "${D}"$(alt_libdir)/..
90
+		mv $(get_libdir) lib || die
91
+		ln -s lib $(get_libdir) || die
92
+		cd "${D}"$(alt_usrlibdir)/..
93
+		mv $(get_libdir) lib || die
94
+		ln -s lib $(get_libdir) || die
95
+	fi
96
+
97
+	#################################################################
98
+	# EVERYTHING AFTER THIS POINT IS FOR NATIVE GLIBC INSTALLS ONLY #
99
+	# Make sure we install some symlink hacks so that when we build
100
+	# a 2nd stage cross-compiler, gcc finds the target system
101
+	# headers correctly.  See gcc/doc/gccinstall.info
102
+	if is_crosscompile ; then
103
+		dosym usr/include /usr/${CTARGET}/sys-include
104
+		return 0
105
+	fi
106
+
107
+	# Everything past this point just needs to be done once ...
108
+	is_final_abi || return 0
109
+
110
+	# Make sure the non-native interp can be found on multilib systems
111
+	if has_multilib_profile ; then
112
+		case $(tc-arch) in
113
+			amd64)
114
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR amd64) /lib
115
+				dosym ../$(get_abi_LIBDIR x86)/ld-linux.so.2 /lib/ld-linux.so.2
116
+				;;
117
+			ppc64)
118
+				[[ ! -e ${D}/lib ]] && dosym $(get_abi_LIBDIR ppc64) /lib
119
+				dosym ../$(get_abi_LIBDIR ppc)/ld.so.1 /lib/ld.so.1
120
+				;;
121
+		esac
122
+	fi
123
+
124
+	# Files for Debian-style locale updating
125
+	dodir /usr/share/i18n
126
+	sed \
127
+		-e "/^#/d" \
128
+		-e "/SUPPORTED-LOCALES=/d" \
129
+		-e "s: \\\\::g" -e "s:/: :g" \
130
+		"${S}"/localedata/SUPPORTED > "${D}"/usr/share/i18n/SUPPORTED \
131
+		|| die "generating /usr/share/i18n/SUPPORTED failed"
132
+	cd "${WORKDIR}"/extra/locale
133
+	dosbin locale-gen || die
134
+	doman *.[0-8]
135
+	insinto /etc
136
+	doins locale.gen || die
137
+
138
+	# Make sure all the ABI's can find the locales and so we only
139
+	# have to generate one set
140
+	local a
141
+	keepdir /usr/$(get_libdir)/locale
142
+	for a in $(get_install_abis) ; do
143
+		if [[ ! -e ${D}/usr/$(get_abi_LIBDIR ${a})/locale ]] ; then
144
+			dosym /usr/$(get_libdir)/locale /usr/$(get_abi_LIBDIR ${a})/locale
145
+		fi
146
+	done
147
+
148
+	if ! has noinfo ${FEATURES} && [[ -n ${INFOPAGE_VER} ]] ; then
149
+		einfo "Installing info pages..."
150
+
151
+		emake \
152
+			-C "${GBUILDDIR}" \
153
+			install_root="${install_root}" \
154
+			info -i || die
155
+	fi
156
+
157
+	if [[ -n ${MANPAGE_VER} ]] ; then
158
+		einfo "Installing man pages..."
159
+
160
+		# Install linuxthreads man pages even if nptl is enabled
161
+		cd "${WORKDIR}"/man
162
+		doman *.3thr
163
+	fi
164
+
165
+	cd "${S}"
166
+
167
+	# Install misc network config files
168
+	insinto /etc
169
+	doins nscd/nscd.conf posix/gai.conf nss/nsswitch.conf || die
170
+	doins "${WORKDIR}"/extra/etc/*.conf || die
171
+	doinitd "${WORKDIR}"/extra/etc/nscd || die
172
+
173
+	sed -i -e "s:@PIDFILE@:$(strings "${D}"/usr/sbin/nscd | grep nscd.pid):" "${D}"/etc/init.d/nscd
174
+
175
+	echo 'LDPATH="include ld.so.conf.d/*.conf"' > "${T}"/00glibc
176
+	doenvd "${T}"/00glibc || die
177
+
178
+	dodoc BUGS ChangeLog* CONFORMANCE FAQ NEWS NOTES PROJECTS README*
179
+
180
+	# Prevent overwriting of the /etc/localtime symlink.  We'll handle the
181
+	# creation of the "factory" symlink in pkg_postinst().
182
+	rm -f "${D}"/etc/localtime
183
+}
184
+
185
+toolchain-glibc_headers_install() {
186
+	local GBUILDDIR=${WORKDIR}/build-${ABI}-${CTARGET}-headers
187
+	cd "${GBUILDDIR}"
188
+	emake install_root="${D}/usr/${CTARGET}" install-headers || die "install-headers failed"
189
+	# Copy over headers that are not part of install-headers ... these
190
+	# are pretty much taken verbatim from crosstool, see it for more details
191
+	insinto $(alt_headers)/bits
192
+	doins misc/syscall-list.h bits/stdio_lim.h || die "doins include bits"
193
+	insinto $(alt_headers)/gnu
194
+	doins "${S}"/include/gnu/stubs.h || die "doins include gnu"
195
+	# Make sure we install the sys-include symlink so that when
196
+	# we build a 2nd stage cross-compiler, gcc finds the target
197
+	# system headers correctly.  See gcc/doc/gccinstall.info
198
+	dosym usr/include /usr/${CTARGET}/sys-include
199
+}
200
+
201
+src_strip() {
202
+	# gdb is lame and requires some debugging information to remain in
203
+	# libpthread, so we need to strip it by hand.  libthread_db makes no
204
+	# sense stripped as it is only used when debugging.
205
+	local pthread=$(hasq splitdebug ${FEATURES} && echo "libthread_db" || echo "lib{pthread,thread_db}")
206
+	env \
207
+		-uRESTRICT \
208
+		CHOST=${CTARGET} \
209
+		STRIP_MASK="/*/{,tls/}${pthread}*" \
210
+		prepallstrip
211
+	# if user has stripping enabled and does not have split debug turned on,
212
+	# then leave the debugging sections in libpthread.
213
+	if ! hasq nostrip ${FEATURES} && ! hasq splitdebug ${FEATURES} ; then
214
+		${STRIP:-${CTARGET}-strip} --strip-debug "${D}"/*/libpthread-*.so
215
+	fi
216
+}
217
+
218
+eblit-glibc-src_install() {
219
+	if just_headers ; then
220
+		toolchain-glibc_headers_install
221
+		return
222
+	fi
223
+
224
+	setup_env
225
+
226
+	if [[ -z ${OABI} ]] ; then
227
+		local abilist=""
228
+		if has_multilib_profile ; then
229
+			abilist=$(get_install_abis)
230
+			einfo "Installing multilib glibc for ABIs: ${abilist}"
231
+		elif is_crosscompile || tc-is-cross-compiler ; then
232
+			abilist=${DEFAULT_ABI}
233
+		fi
234
+		if [[ -n ${abilist} ]] ; then
235
+			OABI=${ABI}
236
+			for ABI in ${abilist} ; do
237
+				export ABI
238
+				eblit-glibc-src_install
239
+			done
240
+			ABI=${OABI}
241
+			unset OABI
242
+			src_strip
243
+			return 0
244
+		fi
245
+	fi
246
+
247
+	toolchain-glibc_src_install
248
+	[[ -z ${OABI} ]] && src_strip
249
+}
... ...
@@ -0,0 +1,42 @@
1
+# Copyright 1999-2007 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_test-2.11.2.eblit,v 1.1 2010/08/10 08:08:05 vapier Exp $
4
+
5
+toolchain-glibc_src_test() {
6
+	cd "${WORKDIR}"/build-${ABI}-${CTARGET}-$1 || die "cd build-${ABI}-${CTARGET}-$1"
7
+	unset LD_ASSUME_KERNEL
8
+	make check && return 0
9
+	einfo "make check failed - re-running with --keep-going to get the rest of the results"
10
+	make -k check
11
+	ewarn "make check failed for ${ABI}-${CTARGET}-$1"
12
+	return 1
13
+}
14
+
15
+eblit-glibc-src_test() {
16
+	local ret=0
17
+
18
+	setup_env
19
+
20
+	# give tests more time to complete
21
+	export TIMEOUTFACTOR=5
22
+
23
+	if [[ -z ${OABI} ]] && has_multilib_profile ; then
24
+		OABI=${ABI}
25
+		einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
26
+		for ABI in $(get_install_abis) ; do
27
+			export ABI
28
+			einfo "   Testing ${ABI} glibc"
29
+			src_test
30
+			((ret+=$?))
31
+		done
32
+		ABI=${OABI}
33
+		unset OABI
34
+		[[ ${ret} -ne 0 ]] \
35
+			&& die "tests failed" \
36
+			|| return 0
37
+	fi
38
+
39
+	want_linuxthreads && toolchain-glibc_src_test linuxthreads ; ((ret+=$?))
40
+	want_nptl && toolchain-glibc_src_test nptl ; ((ret+=$?))
41
+	return ${ret}
42
+}
... ...
@@ -0,0 +1,42 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_test.eblit,v 1.4 2010/08/10 08:08:05 vapier Exp $
4
+
5
+toolchain-glibc_src_test() {
6
+	cd "${WORKDIR}"/build-${ABI}-${CTARGET}-$1 || die "cd build-${ABI}-${CTARGET}-$1"
7
+	unset LD_ASSUME_KERNEL
8
+	emake -j1 check && return 0
9
+	einfo "make check failed - re-running with --keep-going to get the rest of the results"
10
+	emake -j1 -k check
11
+	ewarn "make check failed for ${ABI}-${CTARGET}-$1"
12
+	return 1
13
+}
14
+
15
+eblit-glibc-src_test() {
16
+	local ret=0
17
+
18
+	setup_env
19
+
20
+	# give tests more time to complete
21
+	export TIMEOUTFACTOR=5
22
+
23
+	if [[ -z ${OABI} ]] && has_multilib_profile ; then
24
+		OABI=${ABI}
25
+		einfo "Testing multilib glibc for ABIs: $(get_install_abis)"
26
+		for ABI in $(get_install_abis) ; do
27
+			export ABI
28
+			einfo "   Testing ${ABI} glibc"
29
+			src_test
30
+			((ret+=$?))
31
+		done
32
+		ABI=${OABI}
33
+		unset OABI
34
+		[[ ${ret} -ne 0 ]] \
35
+			&& die "tests failed" \
36
+			|| return 0
37
+	fi
38
+
39
+	want_linuxthreads && toolchain-glibc_src_test linuxthreads ; ((ret+=$?))
40
+	want_nptl && toolchain-glibc_src_test nptl ; ((ret+=$?))
41
+	return ${ret}
42
+}
... ...
@@ -0,0 +1,178 @@
1
+# Copyright 1999-2009 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/src_unpack.eblit,v 1.11 2010/06/08 04:59:56 vapier Exp $
4
+
5
+int_to_KV() {
6
+	local version=$1 major minor micro
7
+	major=$((version / 65536))
8
+	minor=$(((version % 65536) / 256))
9
+	micro=$((version % 256))
10
+	echo ${major}.${minor}.${micro}
11
+}
12
+
13
+eend_KV() {
14
+	[[ $(KV_to_int $1) -ge $(KV_to_int $2) ]]
15
+	eend $?
16
+}
17
+
18
+get_kheader_version() {
19
+	printf '#include <linux/version.h>\nLINUX_VERSION_CODE\n' | \
20
+	$(tc-getCPP ${CTARGET}) -I "$(alt_build_headers)" | \
21
+	tail -n 1
22
+}
23
+
24
+check_nptl_support() {
25
+	# don't care about the compiler here as we arent using it
26
+	just_headers && return
27
+
28
+	local run_kv build_kv want_kv
29
+	run_kv=$(int_to_KV $(get_KV))
30
+	build_kv=$(int_to_KV $(get_kheader_version))
31
+	want_kv=${NPTL_KERN_VER}
32
+
33
+	ebegin "Checking gcc for __thread support"
34
+	if ! eend $(want__thread ; echo $?) ; then
35
+		echo
36
+		eerror "Could not find a gcc that supports the __thread directive!"
37
+		eerror "Please update your binutils/gcc and try again."
38
+		die "No __thread support in gcc!"
39
+	fi
40
+
41
+	if ! is_crosscompile && ! tc-is-cross-compiler ; then
42
+		# Building fails on an non-supporting kernel
43
+		ebegin "Checking kernel version (${run_kv} >= ${want_kv})"
44
+		if ! eend_KV ${run_kv} ${want_kv} ; then
45
+			echo
46
+			eerror "You need a kernel of at least ${want_kv} for NPTL support!"
47
+			die "Kernel version too low!"
48
+		fi
49
+	fi
50
+
51
+	ebegin "Checking linux-headers version (${build_kv} >= ${want_kv})"
52
+	if ! eend_KV ${build_kv} ${want_kv} ; then
53
+		echo
54
+		eerror "You need linux-headers of at least ${want_kv} for NPTL support!"
55
+		die "linux-headers version too low!"
56
+	fi
57
+}
58
+
59
+unpack_pkg() {
60
+	local a=${PN}
61
+	[[ -n ${SNAP_VER} ]] && a="${a}-${RELEASE_VER}"
62
+	[[ -n $1 ]] && a="${a}-$1"
63
+	if [[ -n ${SNAP_VER} ]] ; then
64
+		a="${a}-${SNAP_VER}"
65
+	else
66
+		if [[ -n $2 ]] ; then
67
+			a="${a}-$2"
68
+		else
69
+			a="${a}-${RELEASE_VER}"
70
+		fi
71
+	fi
72
+	unpack ${a}.tar.bz2
73
+	[[ -n $1 ]] && mv ${a} $1
74
+}
75
+
76
+toolchain-glibc_src_unpack() {
77
+	# Check NPTL support _before_ we unpack things to save some time
78
+	want_nptl && check_nptl_support
79
+
80
+	unpack_pkg
81
+
82
+	cd "${S}"
83
+	touch locale/C-translit.h #185476 #218003
84
+	[[ -n ${LT_VER}     ]] && unpack_pkg linuxthreads ${LT_VER}
85
+	[[ -n ${PORTS_VER}  ]] && unpack_pkg ports ${PORTS_VER}
86
+	[[ -n ${LIBIDN_VER} ]] && unpack_pkg libidn
87
+
88
+	if [[ -n ${PATCH_VER} ]] ; then
89
+		cd "${WORKDIR}"
90
+		unpack glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
91
+		# pull out all the addons
92
+		local d
93
+		for d in extra/*/configure ; do
94
+			d=${d%/configure}
95
+			[[ -d ${S}/${d} ]] && die "${d} already exists in \${S}"
96
+			mv "${d}" "${S}" || die "moving ${d} failed"
97
+		done
98
+	fi
99
+
100
+	# XXX: We should do the branchupdate, before extracting the manpages and
101
+	# infopages else it does not help much (mtimes change if there is a change
102
+	# to them with branchupdate)
103
+	if [[ -n ${BRANCH_UPDATE} ]] ; then
104
+		cd "${S}"
105
+		epatch "${DISTDIR}"/glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
106
+
107
+		# Snapshot date patch
108
+		einfo "Patching version to display snapshot date ..."
109
+		sed -i -e "s:\(#define RELEASE\).*:\1 \"${BRANCH_UPDATE}\":" version.h
110
+	fi
111
+
112
+	if [[ -n ${MANPAGE_VER} ]] ; then
113
+		cd "${WORKDIR}"
114
+		unpack glibc-manpages-${MANPAGE_VER}.tar.bz2
115
+	fi
116
+
117
+	if [[ -n ${INFOPAGE_VER} ]] ; then
118
+		cd "${S}"
119
+		unpack glibc-infopages-${INFOPAGE_VER}.tar.bz2
120
+	fi
121
+
122
+	# tag, glibc is it
123
+	cd "${S}"
124
+	[[ -e csu/Banner ]] && die "need new banner location"
125
+	[[ -n ${SNAP_VER} ]] && echo "Gentoo snapshot ${SNAP_VER}" >> csu/Banner
126
+	[[ -n ${BRANCH_UPDATE} ]] && echo "Gentoo branch ${BRANCH_UPDATE}" >> csu/Banner
127
+	if [[ -n ${PATCH_VER} ]] && ! use vanilla ; then
128
+		cd "${S}"
129
+		EPATCH_MULTI_MSG="Applying Gentoo Glibc Patchset ${RELEASE_VER}-${PATCH_VER} ..." \
130
+		EPATCH_EXCLUDE=${GLIBC_PATCH_EXCLUDE} \
131
+		EPATCH_SUFFIX="patch" \
132
+		ARCH=$(tc-arch) \
133
+		epatch "${WORKDIR}"/patches
134
+		echo "Gentoo patchset ${PATCH_VER}" >> csu/Banner
135
+	fi
136
+
137
+	epatch_user
138
+
139
+	gnuconfig_update
140
+}
141
+
142
+eblit-glibc-src_unpack() {
143
+	setup_env
144
+
145
+	toolchain-glibc_src_unpack
146
+
147
+	# Backwards SSP support
148
+	cd "${S}"
149
+# For now, we force everyone to have the extra symbols
150
+#	einfon "Scanning system for __guard to see if we need SSP compat ... "
151
+#	if [[ -n $(scanelf -qyls__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
152
+		echo "yes" > "${T}"/.ssp.compat
153
+#	else
154
+#		# ok, a quick scan didnt find it, so lets do a deep scan ...
155
+#		if [[ -n $(scanelf -qyRlps__guard -F'#s%F' | grep -v '^/lib.*/libc-2.*.so$') ]] ; then
156
+#			echo "yes" > "${T}"/.ssp.compat
157
+#		else
158
+#			echo "no" > "${T}"/.ssp.compat
159
+#		fi
160
+#	fi
161
+#	cat "${T}"/.ssp.compat
162
+
163
+	# Glibc is stupid sometimes, and doesn't realize that with a
164
+	# static C-Only gcc, -lgcc_eh doesn't exist.
165
+	# http://sources.redhat.com/ml/libc-alpha/2003-09/msg00100.html
166
+	# http://sourceware.org/ml/libc-alpha/2005-02/msg00042.html
167
+	echo 'int main(){}' > "${T}"/gcc_eh_test.c
168
+	if ! $(tc-getCC ${CTARGET}) "${T}"/gcc_eh_test.c -lgcc_eh 2>/dev/null ; then
169
+		sed -i -e 's:-lgcc_eh::' Makeconfig || die "sed gcc_eh"
170
+	fi
171
+
172
+	cd "${WORKDIR}"
173
+	find . -type f '(' -size 0 -o -name "*.orig" ')' -exec rm -f {} \;
174
+	find . -name configure -exec touch {} \;
175
+
176
+	# Fix permissions on some of the scripts
177
+	chmod u+x "${S}"/scripts/*.sh
178
+}
... ...
@@ -0,0 +1,73 @@
1
+diff --git a/elf/dl-load.c b/elf/dl-load.c
2
+index a7162eb..776f7e4 100644
3
+--- a/elf/dl-load.c
4
++++ b/elf/dl-load.c
5
+@@ -169,8 +169,7 @@ local_strdup (const char *s)
6
+ 
7
+ 
8
+ static size_t
9
+-is_dst (const char *start, const char *name, const char *str,
10
+-	int is_path, int secure)
11
++is_dst (const char *start, const char *name, const char *str, int is_path)
12
+ {
13
+   size_t len;
14
+   bool is_curly = false;
15
+@@ -199,11 +198,6 @@ is_dst (const char *start, const char *name, const char *str,
16
+ 	   && (!is_path || name[len] != ':'))
17
+     return 0;
18
+ 
19
+-  if (__builtin_expect (secure, 0)
20
+-      && ((name[len] != '\0' && (!is_path || name[len] != ':'))
21
+-	  || (name != start + 1 && (!is_path || name[-2] != ':'))))
22
+-    return 0;
23
+-
24
+   return len;
25
+ }
26
+ 
27
+@@ -218,13 +212,12 @@ _dl_dst_count (const char *name, int is_path)
28
+     {
29
+       size_t len;
30
+ 
31
+-      /* $ORIGIN is not expanded for SUID/GUID programs (except if it
32
+-	 is $ORIGIN alone) and it must always appear first in path.  */
33
++      /* $ORIGIN is not expanded for SUID/GUID programs.  */
34
+       ++name;
35
+-      if ((len = is_dst (start, name, "ORIGIN", is_path,
36
+-			 INTUSE(__libc_enable_secure))) != 0
37
+-	  || (len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0
38
+-	  || (len = is_dst (start, name, "LIB", is_path, 0)) != 0)
39
++      if (((len = is_dst (start, name, "ORIGIN", is_path)) != 0
40
++	   && !INTUSE(__libc_enable_secure))
41
++	  || (len = is_dst (start, name, "PLATFORM", is_path)) != 0
42
++	  || (len = is_dst (start, name, "LIB", is_path)) != 0)
43
+ 	++cnt;
44
+ 
45
+       name = strchr (name + len, '$');
46
+@@ -256,9 +249,12 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
47
+ 	  size_t len;
48
+ 
49
+ 	  ++name;
50
+-	  if ((len = is_dst (start, name, "ORIGIN", is_path,
51
+-			     INTUSE(__libc_enable_secure))) != 0)
52
++	  if ((len = is_dst (start, name, "ORIGIN", is_path)) != 0)
53
+ 	    {
54
++	      /* Ignore this path element in SUID/SGID programs.  */
55
++	      if (INTUSE(__libc_enable_secure))
56
++		repl = (const char *) -1;
57
++	      else
58
+ #ifndef SHARED
59
+ 	      if (l == NULL)
60
+ 		repl = _dl_get_origin ();
61
+@@ -266,9 +262,9 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
62
+ #endif
63
+ 		repl = l->l_origin;
64
+ 	    }
65
+-	  else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
66
++	  else if ((len = is_dst (start, name, "PLATFORM", is_path)) != 0)
67
+ 	    repl = GLRO(dl_platform);
68
+-	  else if ((len = is_dst (start, name, "LIB", is_path, 0)) != 0)
69
++	  else if ((len = is_dst (start, name, "LIB", is_path)) != 0)
70
+ 	    repl = DL_DST_LIB;
71
+ 
72
+ 	  if (repl != NULL && repl != (const char *) -1)
73
+
... ...
@@ -0,0 +1,201 @@
1
+diff --git a/elf/dl-deps.c b/elf/dl-deps.c
2
+index e5b9cdf..1cab2d1 100644
3
+--- a/elf/dl-deps.c
4
++++ b/elf/dl-deps.c
5
+@@ -62,7 +62,7 @@ openaux (void *a)
6
+ {
7
+   struct openaux_args *args = (struct openaux_args *) a;
8
+ 
9
+-  args->aux = _dl_map_object (args->map, args->name, 0,
10
++  args->aux = _dl_map_object (args->map, args->name,
11
+ 			      (args->map->l_type == lt_executable
12
+ 			       ? lt_library : args->map->l_type),
13
+ 			      args->trace_mode, args->open_mode,
14
+diff --git a/elf/dl-load.c b/elf/dl-load.c
15
+index 776f7e4..9ab3520 100644
16
+--- a/elf/dl-load.c
17
++++ b/elf/dl-load.c
18
+@@ -1808,7 +1808,7 @@ open_verify (const char *name, struct filebuf *fbp, struct link_map *loader,
19
+    if MAY_FREE_DIRS is true.  */
20
+ 
21
+ static int
22
+-open_path (const char *name, size_t namelen, int preloaded,
23
++open_path (const char *name, size_t namelen, int secure,
24
+ 	   struct r_search_path_struct *sps, char **realname,
25
+ 	   struct filebuf *fbp, struct link_map *loader, int whatcode,
26
+ 	   bool *found_other_class)
27
+@@ -1890,7 +1890,7 @@ open_path (const char *name, size_t namelen, int preloaded,
28
+ 	  /* Remember whether we found any existing directory.  */
29
+ 	  here_any |= this_dir->status[cnt] != nonexisting;
30
+ 
31
+-	  if (fd != -1 && __builtin_expect (preloaded, 0)
32
++	  if (fd != -1 && __builtin_expect (secure, 0)
33
+ 	      && INTUSE(__libc_enable_secure))
34
+ 	    {
35
+ 	      /* This is an extra security effort to make sure nobody can
36
+@@ -1959,7 +1959,7 @@ open_path (const char *name, size_t namelen, int preloaded,
37
+ 
38
+ struct link_map *
39
+ internal_function
40
+-_dl_map_object (struct link_map *loader, const char *name, int preloaded,
41
++_dl_map_object (struct link_map *loader, const char *name,
42
+ 		int type, int trace_mode, int mode, Lmid_t nsid)
43
+ {
44
+   int fd;
45
+@@ -2063,7 +2063,8 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
46
+ 	  for (l = loader; l; l = l->l_loader)
47
+ 	    if (cache_rpath (l, &l->l_rpath_dirs, DT_RPATH, "RPATH"))
48
+ 	      {
49
+-		fd = open_path (name, namelen, preloaded, &l->l_rpath_dirs,
50
++		fd = open_path (name, namelen, mode & __RTLD_SECURE,
51
++				&l->l_rpath_dirs,
52
+ 				&realname, &fb, loader, LA_SER_RUNPATH,
53
+ 				&found_other_class);
54
+ 		if (fd != -1)
55
+@@ -2078,14 +2079,15 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
56
+ 	      && main_map != NULL && main_map->l_type != lt_loaded
57
+ 	      && cache_rpath (main_map, &main_map->l_rpath_dirs, DT_RPATH,
58
+ 			      "RPATH"))
59
+-	    fd = open_path (name, namelen, preloaded, &main_map->l_rpath_dirs,
60
++	    fd = open_path (name, namelen, mode & __RTLD_SECURE,
61
++			    &main_map->l_rpath_dirs,
62
+ 			    &realname, &fb, loader ?: main_map, LA_SER_RUNPATH,
63
+ 			    &found_other_class);
64
+ 	}
65
+ 
66
+       /* Try the LD_LIBRARY_PATH environment variable.  */
67
+       if (fd == -1 && env_path_list.dirs != (void *) -1)
68
+-	fd = open_path (name, namelen, preloaded, &env_path_list,
69
++	fd = open_path (name, namelen, mode & __RTLD_SECURE, &env_path_list,
70
+ 			&realname, &fb,
71
+ 			loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded,
72
+ 			LA_SER_LIBPATH, &found_other_class);
73
+@@ -2094,12 +2096,12 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
74
+       if (fd == -1 && loader != NULL
75
+ 	  && cache_rpath (loader, &loader->l_runpath_dirs,
76
+ 			  DT_RUNPATH, "RUNPATH"))
77
+-	fd = open_path (name, namelen, preloaded,
78
++	fd = open_path (name, namelen, mode & __RTLD_SECURE,
79
+ 			&loader->l_runpath_dirs, &realname, &fb, loader,
80
+ 			LA_SER_RUNPATH, &found_other_class);
81
+ 
82
+       if (fd == -1
83
+-	  && (__builtin_expect (! preloaded, 1)
84
++	  && (__builtin_expect (! (mode & __RTLD_SECURE), 1)
85
+ 	      || ! INTUSE(__libc_enable_secure)))
86
+ 	{
87
+ 	  /* Check the list of libraries in the file /etc/ld.so.cache,
88
+@@ -2165,7 +2167,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
89
+ 	  && ((l = loader ?: GL(dl_ns)[nsid]._ns_loaded) == NULL
90
+ 	      || __builtin_expect (!(l->l_flags_1 & DF_1_NODEFLIB), 1))
91
+ 	  && rtld_search_dirs.dirs != (void *) -1)
92
+-	fd = open_path (name, namelen, preloaded, &rtld_search_dirs,
93
++	fd = open_path (name, namelen, mode & __RTLD_SECURE, &rtld_search_dirs,
94
+ 			&realname, &fb, l, LA_SER_DEFAULT, &found_other_class);
95
+ 
96
+       /* Add another newline when we are tracing the library loading.  */
97
+diff --git a/elf/dl-open.c b/elf/dl-open.c
98
+index c394b3f..cf8e8cc 100644
99
+--- a/elf/dl-open.c
100
++++ b/elf/dl-open.c
101
+@@ -223,7 +223,7 @@ dl_open_worker (void *a)
102
+ 
103
+   /* Load the named object.  */
104
+   struct link_map *new;
105
+-  args->map = new = _dl_map_object (call_map, file, 0, lt_loaded, 0,
106
++  args->map = new = _dl_map_object (call_map, file, lt_loaded, 0,
107
+ 				    mode | __RTLD_CALLMAP, args->nsid);
108
+ 
109
+   /* If the pointer returned is NULL this means the RTLD_NOLOAD flag is
110
+diff --git a/elf/rtld.c b/elf/rtld.c
111
+index 201c9cf..4a8cee8 100644
112
+--- a/elf/rtld.c
113
++++ b/elf/rtld.c
114
+@@ -587,7 +587,6 @@ struct map_args
115
+   /* Argument to map_doit.  */
116
+   char *str;
117
+   struct link_map *loader;
118
+-  int is_preloaded;
119
+   int mode;
120
+   /* Return value of map_doit.  */
121
+   struct link_map *map;
122
+@@ -625,16 +624,17 @@ static void
123
+ map_doit (void *a)
124
+ {
125
+   struct map_args *args = (struct map_args *) a;
126
+-  args->map = _dl_map_object (args->loader, args->str,
127
+-			      args->is_preloaded, lt_library, 0, args->mode,
128
+-			      LM_ID_BASE);
129
++  args->map = _dl_map_object (args->loader, args->str, lt_library, 0,
130
++			      args->mode, LM_ID_BASE);
131
+ }
132
+ 
133
+ static void
134
+ dlmopen_doit (void *a)
135
+ {
136
+   struct dlmopen_args *args = (struct dlmopen_args *) a;
137
+-  args->map = _dl_open (args->fname, RTLD_LAZY | __RTLD_DLOPEN | __RTLD_AUDIT,
138
++  args->map = _dl_open (args->fname,
139
++			(RTLD_LAZY | __RTLD_DLOPEN | __RTLD_AUDIT
140
++			 | __RTLD_SECURE),
141
+ 			dl_main, LM_ID_NEWLM, _dl_argc, INTUSE(_dl_argv),
142
+ 			__environ);
143
+ }
144
+@@ -804,8 +804,7 @@ do_preload (char *fname, struct link_map *main_map, const char *where)
145
+ 
146
+   args.str = fname;
147
+   args.loader = main_map;
148
+-  args.is_preloaded = 1;
149
+-  args.mode = 0;
150
++  args.mode = __RTLD_SECURE;
151
+ 
152
+   unsigned int old_nloaded = GL(dl_ns)[LM_ID_BASE]._ns_nloaded;
153
+ 
154
+@@ -1050,7 +1049,6 @@ of this helper program; chances are you did not intend to run this program.\n\
155
+ 
156
+ 	  args.str = rtld_progname;
157
+ 	  args.loader = NULL;
158
+-	  args.is_preloaded = 0;
159
+ 	  args.mode = __RTLD_OPENEXEC;
160
+ 	  (void) _dl_catch_error (&objname, &err_str, &malloced, map_doit,
161
+ 				  &args);
162
+@@ -1062,7 +1060,7 @@ of this helper program; chances are you did not intend to run this program.\n\
163
+       else
164
+ 	{
165
+ 	  HP_TIMING_NOW (start);
166
+-	  _dl_map_object (NULL, rtld_progname, 0, lt_library, 0,
167
++	  _dl_map_object (NULL, rtld_progname, lt_library, 0,
168
+ 			  __RTLD_OPENEXEC, LM_ID_BASE);
169
+ 	  HP_TIMING_NOW (stop);
170
+ 
171
+diff --git a/include/dlfcn.h b/include/dlfcn.h
172
+index a67426d..af92483 100644
173
+--- a/include/dlfcn.h
174
++++ b/include/dlfcn.h
175
+@@ -9,6 +9,7 @@
176
+ #define __RTLD_OPENEXEC	0x20000000
177
+ #define __RTLD_CALLMAP	0x10000000
178
+ #define __RTLD_AUDIT	0x08000000
179
++#define __RTLD_SECURE	0x04000000 /* Apply additional security checks.  */
180
+ 
181
+ #define __LM_ID_CALLER	-2
182
+ 
183
+diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h
184
+index fcc943b..fa4b6b2 100644
185
+--- a/sysdeps/generic/ldsodefs.h
186
++++ b/sysdeps/generic/ldsodefs.h
187
+@@ -824,11 +824,9 @@ extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
188
+ 
189
+ /* Open the shared object NAME and map in its segments.
190
+    LOADER's DT_RPATH is used in searching for NAME.
191
+-   If the object is already opened, returns its existing map.
192
+-   For preloaded shared objects PRELOADED is set to a non-zero
193
+-   value to allow additional security checks.  */
194
++   If the object is already opened, returns its existing map.  */
195
+ extern struct link_map *_dl_map_object (struct link_map *loader,
196
+-					const char *name, int preloaded,
197
++					const char *name,
198
+ 					int type, int trace_mode, int mode,
199
+ 					Lmid_t nsid)
200
+      internal_function attribute_hidden;
201
+
... ...
@@ -0,0 +1,64 @@
1
+#!/sbin/runscript
2
+# Copyright 1999-2005 Gentoo Foundation
3
+# Distributed under the terms of the GNU General Public License v2
4
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nscd,v 1.7 2007/02/23 12:09:39 uberlord Exp $
5
+
6
+depend() {
7
+	use dns ldap net slapd
8
+}
9
+
10
+checkconfig() {
11
+	if [ ! -d /var/run/nscd ] ; then
12
+		mkdir -p /var/run/nscd
13
+		chmod 755 /var/run/nscd
14
+	fi
15
+	if [ -z "${NSCD_PERMS_OK}" ] && [ "$(stat -c %a /var/run/nscd)" != "755" ] ; then
16
+		echo ""
17
+		ewarn "nscd run dir is not world readable, you should reset the perms:"
18
+		ewarn "chmod 755 /var/run/nscd"
19
+		ewarn "chmod a+rw /var/run/nscd/socket"
20
+		echo ""
21
+		ewarn "To disable this warning, set 'NSCD_PERMS_OK' in /etc/conf.d/nscd"
22
+		echo ""
23
+	fi
24
+}
25
+
26
+start() {
27
+	checkconfig
28
+
29
+	ebegin "Starting Name Service Cache Daemon"
30
+	local secure=`while read curline ; do
31
+		table=${curline%:*}
32
+		entries=${curline##$table:}
33
+		table=${table%%[^a-z]*}
34
+		case $table in
35
+			passwd*|group*|hosts)
36
+			for entry in $entries ; do
37
+			case $entry in
38
+				nisplus*)
39
+					/usr/sbin/nscd_nischeck $table || \
40
+					/echo "-S $table,yes"
41
+				;;
42
+			esac
43
+			done
44
+		;;
45
+		esac
46
+		done < /etc/nsswitch.conf`
47
+	local pidfile="$(strings /usr/sbin/nscd | grep nscd.pid)"
48
+	mkdir -p "$(dirname ${pidfile})"
49
+	save_options pidfile "${pidfile}"
50
+	start-stop-daemon --start --quiet \
51
+		--exec /usr/sbin/nscd --pidfile "${pidfile}" \
52
+		-- $secure
53
+	eend $?
54
+}
55
+
56
+stop() {
57
+	local pidfile="$(get_options pidfile)"
58
+	[ -n "${pidfile}" ] && pidfile="--pidfile ${pidfile}"
59
+	ebegin "Shutting down Name Service Cache Daemon"
60
+	start-stop-daemon --stop --quiet --exec /usr/sbin/nscd ${pidfile}
61
+	eend $?
62
+}
63
+
64
+# vim:ts=4
... ...
@@ -0,0 +1,24 @@
1
+# /etc/nsswitch.conf:
2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nsswitch.conf,v 1.1 2005/05/17 00:52:41 vapier Exp $
3
+
4
+passwd:      compat
5
+shadow:      compat
6
+group:       compat
7
+
8
+# passwd:    db files nis
9
+# shadow:    db files nis
10
+# group:     db files nis
11
+
12
+hosts:       files dns
13
+networks:    files dns
14
+
15
+services:    db files
16
+protocols:   db files
17
+rpc:         db files
18
+ethers:      db files
19
+netmasks:    files
20
+netgroup:    files
21
+bootparams:  files
22
+
23
+automount:   files
24
+aliases:     files
... ...
@@ -0,0 +1,261 @@
1
+# Copyright 1999-2010 Gentoo Foundation
2
+# Distributed under the terms of the GNU General Public License v2
3
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/glibc-2.12.1-r1.ebuild,v 1.4 2010/10/13 23:58:12 vapier Exp $
4
+
5
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib
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"
11
+KEYWORDS="~amd64 ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
12
+RESTRICT="strip" # strip ourself #46186
13
+EMULTILIB_PKG="true"
14
+
15
+# Configuration variables
16
+if [[ ${PV} == *_p* ]] ; then
17
+RELEASE_VER=${PV%_p*}
18
+BRANCH_UPDATE=""
19
+SNAP_VER=${PV#*_p}
20
+else
21
+RELEASE_VER=${PV}
22
+BRANCH_UPDATE=""
23
+SNAP_VER=""
24
+fi
25
+MANPAGE_VER=""                                 # pregenerated manpages
26
+INFOPAGE_VER=""                                # pregenerated infopages
27
+LIBIDN_VER=""                                  # it's integrated into the main tarball now
28
+PATCH_VER="4"                                  # Gentoo patchset
29
+PORTS_VER= #${RELEASE_VER%.?}                  # version of glibc ports addon
30
+LT_VER=""                                      # version of linuxthreads addon
31
+NPTL_KERN_VER=${NPTL_KERN_VER:-"2.6.9"}        # min kernel version nptl requires
32
+#LT_KERN_VER=${LT_KERN_VER:-"2.4.1"}           # min kernel version linuxthreads requires
33
+
34
+IUSE="debug gd glibc-omitfp hardened multilib nls selinux profile vanilla crosscompile_opts_headers-only ${LT_VER:+glibc-compat20 nptl nptlonly}"
35
+S=${WORKDIR}/glibc-${RELEASE_VER}${SNAP_VER:+-${SNAP_VER}}
36
+
37
+# Here's how the cross-compile logic breaks down ...
38
+#  CTARGET - machine that will target the binaries
39
+#  CHOST   - machine that will host the binaries
40
+#  CBUILD  - machine that will build the binaries
41
+# If CTARGET != CHOST, it means you want a libc for cross-compiling.
42
+# If CHOST != CBUILD, it means you want to cross-compile the libc.
43
+#  CBUILD = CHOST = CTARGET    - native build/install
44
+#  CBUILD != (CHOST = CTARGET) - cross-compile a native build
45
+#  (CBUILD = CHOST) != CTARGET - libc for cross-compiler
46
+#  CBUILD != CHOST != CTARGET  - cross-compile a libc for a cross-compiler
47
+# For install paths:
48
+#  CHOST = CTARGET  - install into /
49
+#  CHOST != CTARGET - install into /usr/CTARGET/
50
+
51
+export CBUILD=${CBUILD:-${CHOST}}
52
+export CTARGET=${CTARGET:-${CHOST}}
53
+if [[ ${CTARGET} == ${CHOST} ]] ; then
54
+	if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
55
+		export CTARGET=${CATEGORY/cross-}
56
+	fi
57
+fi
58
+
59
+[[ ${CTARGET} == hppa* ]] && NPTL_KERN_VER=${NPTL_KERN_VER/2.6.9/2.6.20}
60
+
61
+is_crosscompile() {
62
+	[[ ${CHOST} != ${CTARGET} ]]
63
+}
64
+alt_libdir() {
65
+	if is_crosscompile ; then
66
+		echo /usr/${CTARGET}/$(get_libdir)
67
+	else
68
+		echo /$(get_libdir)
69
+	fi
70
+}
71
+
72
+if is_crosscompile ; then
73
+	SLOT="${CTARGET}-2.2"
74
+else
75
+	# Why SLOT 2.2 you ask yourself while sippin your tea ?
76
+	# Everyone knows 2.2 > 0, duh.
77
+	SLOT="2.2"
78
+	PROVIDE="virtual/libc"
79
+fi
80
+
81
+# General: We need a new-enough binutils for as-needed
82
+# arch: we need to make sure our binutils/gcc supports TLS
83
+DEPEND=">=sys-devel/gcc-3.4.4
84
+	arm? ( >=sys-devel/binutils-2.16.90 >=sys-devel/gcc-4.1.0 )
85
+	x86? ( >=sys-devel/gcc-4.3 )
86
+	amd64? ( >=sys-devel/binutils-2.19 >=sys-devel/gcc-4.3 )
87
+	ppc? ( >=sys-devel/gcc-4.1.0 )
88
+	ppc64? ( >=sys-devel/gcc-4.1.0 )
89
+	>=sys-devel/binutils-2.15.94
90
+	${LT_VER:+nptl? (} >=sys-kernel/linux-headers-${NPTL_KERN_VER} ${LT_VER:+)}
91
+	>=sys-devel/gcc-config-1.3.12
92
+	>=app-misc/pax-utils-0.1.10
93
+	virtual/os-headers
94
+	nls? ( sys-devel/gettext )
95
+	>=sys-apps/sandbox-1.2.18.1-r2
96
+	!<sys-apps/portage-2.1.2
97
+	selinux? ( sys-libs/libselinux )"
98
+RDEPEND="!sys-kernel/ps3-sources
99
+	nls? ( sys-devel/gettext )
100
+	selinux? ( sys-libs/libselinux )"
101
+
102
+if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
103
+	DEPEND="${DEPEND} !crosscompile_opts_headers-only? ( ${CATEGORY}/gcc )"
104
+	[[ ${CATEGORY} == *-linux* ]] && DEPEND="${DEPEND} ${CATEGORY}/linux-headers"
105
+else
106
+	DEPEND="${DEPEND} !vanilla? ( >=sys-libs/timezone-data-2007c )"
107
+	RDEPEND="${RDEPEND}
108
+		vanilla? ( !sys-libs/timezone-data )
109
+		!vanilla? ( sys-libs/timezone-data )"
110
+fi
111
+
112
+SRC_URI=$(
113
+	upstream_uris() {
114
+		echo mirror://gnu/glibc/$1 ftp://sources.redhat.com/pub/glibc/{releases,snapshots}/$1 mirror://gentoo/$1
115
+	}
116
+	gentoo_uris() {
117
+		local devspace="HTTP~vapier/dist/URI HTTP~azarah/glibc/URI"
118
+		devspace=${devspace//HTTP/http://dev.gentoo.org/}
119
+		echo mirror://gentoo/$1 ${devspace//URI/$1}
120
+	}
121
+
122
+	TARNAME=${PN}
123
+	if [[ -n ${SNAP_VER} ]] ; then
124
+		TARNAME="${PN}-${RELEASE_VER}"
125
+		[[ -n ${PORTS_VER} ]] && PORTS_VER=${SNAP_VER}
126
+		upstream_uris ${TARNAME}-${SNAP_VER}.tar.bz2
127
+	else
128
+		upstream_uris ${TARNAME}-${RELEASE_VER}.tar.bz2
129
+	fi
130
+	[[ -n ${LIBIDN_VER}    ]] && upstream_uris glibc-libidn-${LIBIDN_VER}.tar.bz2
131
+	[[ -n ${PORTS_VER}     ]] && upstream_uris ${TARNAME}-ports-${PORTS_VER}.tar.bz2
132
+	[[ -n ${LT_VER}        ]] && upstream_uris ${TARNAME}-linuxthreads-${LT_VER}.tar.bz2
133
+	[[ -n ${BRANCH_UPDATE} ]] && gentoo_uris glibc-${RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
134
+	[[ -n ${PATCH_VER}     ]] && gentoo_uris glibc-${RELEASE_VER}-patches-${PATCH_VER}.tar.bz2
135
+	[[ -n ${MANPAGE_VER}   ]] && gentoo_uris glibc-manpages-${MANPAGE_VER}.tar.bz2
136
+	[[ -n ${INFOPAGE_VER}  ]] && gentoo_uris glibc-infopages-${INFOPAGE_VER}.tar.bz2
137
+)
138
+
139
+# eblit-include [--skip] <function> [version]
140
+eblit-include() {
141
+	local skipable=false
142
+	[[ $1 == "--skip" ]] && skipable=true && shift
143
+	[[ $1 == pkg_* ]] && skipable=true
144
+
145
+	local e v func=$1 ver=$2
146
+	[[ -z ${func} ]] && die "Usage: eblit-include <function> [version]"
147
+	for v in ${ver:+-}${ver} -${PVR} -${PV} "" ; do
148
+		e="${FILESDIR}/eblits/${func}${v}.eblit"
149
+		if [[ -e ${e} ]] ; then
150
+			source "${e}"
151
+			return 0
152
+		fi
153
+	done
154
+	${skipable} && return 0
155
+	die "Could not locate requested eblit '${func}' in ${FILESDIR}/eblits/"
156
+}
157
+
158
+# eblit-run-maybe <function>
159
+# run the specified function if it is defined
160
+eblit-run-maybe() {
161
+	[[ $(type -t "$@") == "function" ]] && "$@"
162
+}
163
+
164
+# eblit-run <function> [version]
165
+# aka: src_unpack() { eblit-run src_unpack ; }
166
+eblit-run() {
167
+	eblit-include --skip common "${*:2}"
168
+	eblit-include "$@"
169
+	eblit-run-maybe eblit-$1-pre
170
+	eblit-${PN}-$1
171
+	eblit-run-maybe eblit-$1-post
172
+}
173
+
174
+src_unpack()  { eblit-run src_unpack  ;
175
+	cd "${S}"
176
+	epatch "${FILESDIR}/glibc-sec1"
177
+	epatch "${FILESDIR}/glibc-sec2"
178
+}
179
+src_compile() { eblit-run src_compile ; }
180
+src_test()    { eblit-run src_test    ; }
181
+src_install() { eblit-run src_install ; }
182
+
183
+# FILESDIR might not be available during binpkg install
184
+for x in setup {pre,post}inst ; do
185
+	e="${FILESDIR}/eblits/pkg_${x}.eblit"
186
+	if [[ -e ${e} ]] ; then
187
+		. "${e}"
188
+		eval "pkg_${x}() { eblit-run pkg_${x} ; }"
189
+	fi
190
+done
191
+
192
+pkg_setup() {
193
+	eblit-run pkg_setup
194
+
195
+	# Static binary sanity check #332927
196
+	if [[ ${ROOT} == "/" ]] && \
197
+	   has_version "<${CATEGORY}/${P}" && \
198
+	   built_with_use sys-apps/coreutils static
199
+	then
200
+		eerror "Please rebuild coreutils with USE=-static, then install"
201
+		eerror "glibc, then you may rebuild coreutils with USE=static."
202
+		die "Avoiding system meltdown #332927"
203
+	fi
204
+}
205
+
206
+eblit-src_unpack-post() {
207
+	if use hardened ; then
208
+		cd "${S}"
209
+		einfo "Patching to get working PIE binaries on PIE (hardened) platforms"
210
+		gcc-specs-pie && epatch "${FILESDIR}"/2.12/glibc-2.12-hardened-pie.patch
211
+		epatch "${FILESDIR}"/2.10/glibc-2.10-hardened-configure-picdefault.patch
212
+		epatch "${FILESDIR}"/2.10/glibc-2.10-hardened-inittls-nosysenter.patch
213
+
214
+		einfo "Patching Glibc to support older SSP __guard"
215
+		epatch "${FILESDIR}"/2.10/glibc-2.10-hardened-ssp-compat.patch
216
+
217
+		einfo "Installing Hardened Gentoo SSP and FORTIFY_SOURCE handler"
218
+		cp -f "${FILESDIR}"/2.6/glibc-2.6-gentoo-stack_chk_fail.c \
219
+			debug/stack_chk_fail.c || die
220
+		cp -f "${FILESDIR}"/2.10/glibc-2.10-gentoo-chk_fail.c \
221
+			debug/chk_fail.c || die
222
+
223
+		if use debug ; then
224
+			# When using Hardened Gentoo stack handler, have smashes dump core for
225
+			# analysis - debug only, as core could be an information leak
226
+			# (paranoia).
227
+			sed -i \
228
+				-e '/^CFLAGS-backtrace.c/ iCFLAGS-stack_chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
229
+				debug/Makefile \
230
+				|| die "Failed to modify debug/Makefile for debug stack handler"
231
+			sed -i \
232
+				-e '/^CFLAGS-backtrace.c/ iCFLAGS-chk_fail.c = -DSSP_SMASH_DUMPS_CORE' \
233
+				debug/Makefile \
234
+				|| die "Failed to modify debug/Makefile for debug fortify handler"
235
+		fi
236
+
237
+		# Build nscd with ssp-all
238
+		sed -i \
239
+			-e 's:-fstack-protector$:-fstack-protector-all:' \
240
+			nscd/Makefile \
241
+			|| die "Failed to ensure nscd builds with ssp-all"
242
+	fi
243
+}
244
+
245
+maint_pkg_create() {
246
+	local base="/usr/local/src/gnu/glibc/glibc-${PV:0:1}_${PV:2:1}"
247
+	cd ${base}
248
+	local stamp=$(date +%Y%m%d)
249
+	local d
250
+	for d in libc ports ; do
251
+		#(cd ${d} && cvs up)
252
+		case ${d} in
253
+			libc)  tarball="${P}";;
254
+			ports) tarball="${PN}-ports-${PV}";;
255
+		esac
256
+		rm -f ${tarball}*
257
+		ln -sf ${d} ${tarball}
258
+		tar hcf - ${tarball} --exclude-vcs | lzma > "${T}"/${tarball}.tar.lzma
259
+		du -b "${T}"/${tarball}.tar.lzma
260
+	done
261
+}
0 262