Gentoo Archives: gentoo-commits

From: "Anthony G. Basile" <blueness@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/hardened-dev:uclibc commit in: sys-libs/uclibc/
Date: Fri, 28 Dec 2012 15:57:59
Message-Id: 1356710252.d2993f562b2819e4c3d4fea616c112d489b580ae.blueness@gentoo
1 commit: d2993f562b2819e4c3d4fea616c112d489b580ae
2 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
3 AuthorDate: Fri Dec 28 15:57:32 2012 +0000
4 Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
5 CommitDate: Fri Dec 28 15:57:32 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=d2993f56
7
8 sys-libs/uclibc-0.9.33.2-r99: remove SYS_utime from bits/sysnum.h for arm, bug #425006
9
10 Package-Manager: portage-2.1.11.31
11 Manifest-Sign-Key: 0xF52D4BBA
12
13 ---
14 sys-libs/uclibc/metadata.xml | 29 +++
15 sys-libs/uclibc/uclibc-0.9.33.2-r99.ebuild | 377 ++++++++++++++++++++++++++++
16 2 files changed, 406 insertions(+), 0 deletions(-)
17
18 diff --git a/sys-libs/uclibc/metadata.xml b/sys-libs/uclibc/metadata.xml
19 new file mode 100644
20 index 0000000..9077023
21 --- /dev/null
22 +++ b/sys-libs/uclibc/metadata.xml
23 @@ -0,0 +1,29 @@
24 +<?xml version="1.0" encoding="UTF-8"?>
25 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
26 +<pkgmetadata>
27 + <herd>embedded</herd>
28 + <maintainer>
29 + <email>vapier@g.o</email>
30 + <description>Primary Maintainer</description>
31 + </maintainer>
32 + <longdescription>
33 +uClibc pronounced yew-see-lib-see is a C library for developing embedded Linux
34 +systems. It is much smaller than the GNU C Library, but nearly all applications supported
35 +by glibc also work perfectly with uClibc. Porting applications from glibc to uClibc
36 +typically involves just recompiling the source code. uClibc even supports shared libraries
37 +and threading. It currently runs on standard Linux and MMU-less (also known as uClinux)
38 +systems with support for alpha, ARM, cris, i386, i960, h8300, m68k, mips/mipsel, PowerPC,
39 +SH, SPARC, and v850 processors.
40 +</longdescription>
41 +<use>
42 + <flag name='rpc'>Enable sun nis/rpc support (you should use libtirpc though)</flag>
43 + <flag name='ssp'>Force the use of ssp to be built into a hardened uclibc setup</flag>
44 + <flag name='pregen'>Use pregenerated locales</flag>
45 + <flag name='savedconfig'>Adds support for user defined configs</flag>
46 + <flag name='uclibc-compat'>Build uclibc with backwards compatible
47 + options</flag>
48 + <flag name='userlocales'>Build only the locales specified in
49 + /etc/locales.build</flag>
50 + <flag name='wordexp'>Add support for word expansion (wordexp.h)</flag>
51 +</use>
52 +</pkgmetadata>
53
54 diff --git a/sys-libs/uclibc/uclibc-0.9.33.2-r99.ebuild b/sys-libs/uclibc/uclibc-0.9.33.2-r99.ebuild
55 new file mode 100644
56 index 0000000..819174f
57 --- /dev/null
58 +++ b/sys-libs/uclibc/uclibc-0.9.33.2-r99.ebuild
59 @@ -0,0 +1,377 @@
60 +# Copyright 1999-2012 Gentoo Foundation
61 +# Distributed under the terms of the GNU General Public License v2
62 +# $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/uclibc-0.9.33.2-r2.ebuild,v 1.1 2012/08/18 05:52:58 vapier Exp $
63 +
64 +inherit eutils flag-o-matic multilib toolchain-funcs savedconfig
65 +if [[ ${PV} == "9999" ]] ; then
66 + EGIT_REPO_URI="git://git.busybox.net/uClibc"
67 + inherit git-2
68 +fi
69 +
70 +export CBUILD=${CBUILD:-${CHOST}}
71 +export CTARGET=${CTARGET:-${CHOST}}
72 +if [[ ${CTARGET} == ${CHOST} ]] ; then
73 + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
74 + export CTARGET=${CATEGORY/cross-}
75 + fi
76 +fi
77 +
78 +MY_P=uClibc-${PV}
79 +DESCRIPTION="C library for developing embedded Linux systems"
80 +HOMEPAGE="http://www.uclibc.org/"
81 +if [[ ${PV} != "9999" ]] ; then
82 + PATCH_VER="3"
83 + SRC_URI="http://uclibc.org/downloads/${MY_P}.tar.bz2
84 + ${PATCH_VER:+mirror://gentoo/${MY_P}-patches-${PATCH_VER}.tar.bz2}"
85 + KEYWORDS="-* ~amd64 ~arm ~m68k ~mips ~ppc ~sh ~sparc ~x86"
86 +fi
87 +
88 +LICENSE="LGPL-2"
89 +SLOT="0"
90 +IUSE="debug hardened iconv ipv6 nptl rpc ssp uclibc-compat wordexp crosscompile_opts_headers-only"
91 +RESTRICT="strip"
92 +
93 +S=${WORKDIR}/${MY_P}
94 +
95 +is_crosscompile() {
96 + [[ ${CHOST} != ${CTARGET} ]]
97 +}
98 +alt_build_kprefix() {
99 + if [[ ${CBUILD} == ${CHOST} && ${CTARGET} == ${CHOST} ]] ; then
100 + echo /usr/include
101 + else
102 + echo /usr/${CTARGET}/usr/include
103 + fi
104 +}
105 +
106 +just_headers() {
107 + use crosscompile_opts_headers-only && is_crosscompile
108 +}
109 +
110 +uclibc_endian() {
111 + # XXX: this wont work for a toolchain which is bi-endian, but we
112 + # dont have any such thing at the moment, so not a big deal
113 + touch "${T}"/endian.s
114 + $(tc-getAS ${CTARGET}) "${T}"/endian.s -o "${T}"/endian.o
115 + case $(file "${T}"/endian.o) in
116 + *" MSB "*) echo "BIG";;
117 + *" LSB "*) echo "LITTLE";;
118 + *) echo "NFC";;
119 + esac
120 + rm -f "${T}"/endian.{s,o}
121 +}
122 +
123 +pkg_setup() {
124 + if [ ${CTARGET} == ${CHOST} ] ; then
125 + case ${CHOST} in
126 + *-uclinux*|*-uclibc*) ;;
127 + *) die "Use sys-devel/crossdev to build a uclibc toolchain" ;;
128 + esac
129 + fi
130 +}
131 +
132 +# XXX: We should kill these off.
133 +CPU_ALPHA=""
134 +CPU_AMD64=""
135 +CPU_ARM="GENERIC_ARM ARM{610,710,7TDMI,720T,920T,922T,926T,10T,1136JF_S,1176JZ{_,F_}S,_{SA110,SA1100,XSCALE,IWMMXT},_CORTEX_{M3,M1}}"
136 +CPU_IA64=""
137 +CPU_M68K=""
138 +CPU_MIPS="MIPS_ISA_{1,2,3,4,MIPS{32{,R2},64}} MIPS_{N64,O32,N32}_ABI"
139 +CPU_PPC=""
140 +CPU_SH="SH{2,2A,3,4,5}"
141 +CPU_SPARC="SPARC_V{7,8,9,9B}"
142 +CPU_X86="GENERIC_386 {3,4,5,6}86 586MMX PENTIUM{II,III,4} K{6,7} ELAN CRUSOE WINCHIP{C6,2} CYRIXIII NEHEMIAH"
143 +IUSE_UCLIBC_CPU="${CPU_ARM} ${CPU_MIPS} ${CPU_PPC} ${CPU_SH} ${CPU_SPARC} ${CPU_X86}"
144 +
145 +check_cpu_opts() {
146 + local cpu_var="CPU_$(echo $(tc-arch) | tr [a-z] [A-Z])"
147 + [[ -z ${!cpu_var} ]] && return 0
148 +
149 + if [[ -z ${UCLIBC_CPU} ]] ; then
150 + ewarn "You really should consider setting UCLIBC_CPU"
151 + ewarn "Otherwise, the build will be generic (read: slow)."
152 + ewarn "Available CPU options:"
153 + UCLIBC_CPU=$(eval echo ${!cpu_var})
154 + echo ${UCLIBC_CPU}
155 + case ${CTARGET} in
156 + mips[1234]*) export UCLIBC_CPU="MIPS_ISA_${CTARGET:4:1}";;
157 + sh[2345]*) export UCLIBC_CPU="SH${CTARGET:2:1}";;
158 + i[456]86*) export UCLIBC_CPU="${CTARGET:1:1}86";;
159 + *) export UCLIBC_CPU=${UCLIBC_CPU%% *};;
160 + esac
161 + else
162 + local cpu found=0
163 + for cpu in $(eval echo ${!cpu_var}) ; do
164 + [[ ${UCLIBC_CPU} == "${cpu}" ]] && found=1 && break
165 + done
166 + if [[ ${found} -eq 0 ]] ; then
167 + ewarn "UCLIBC_CPU choice '${UCLIBC_CPU}' not supported"
168 + ewarn "Valid choices:"
169 + eval echo ${!cpu_var}
170 + die "pick a supported cpu type"
171 + fi
172 + fi
173 +}
174 +
175 +kconfig_q_opt() {
176 + local flag=$1; shift
177 + case ${flag} in
178 + y|n) ;;
179 + *) flag=$(usex ${flag} y n) ;;
180 + esac
181 +
182 + local var="defs_${flag}"
183 + eval "${var}+=( $* )"
184 +}
185 +
186 +get_opt() {
187 + (
188 + unset ${1}
189 + . ${2:-"${S}"/.config}
190 + echo ${!1}
191 + )
192 +}
193 +
194 +src_oldconfig() {
195 + yes "" 2>/dev/null | emake -s oldconfig >/dev/null
196 +}
197 +src_config() {
198 + restore_config .config
199 + if [ -f .config ]; then
200 + src_oldconfig
201 + return 0
202 + else
203 + ewarn "Could not locate user configfile, so we will save a default one"
204 + fi
205 +
206 + emake ARCH=${target} defconfig >/dev/null || die
207 +
208 + local defs_{y,n} defs
209 +
210 + defs=(
211 + DO{DEBUG_PT,ASSERTS}
212 + SUPPORT_LD_DEBUG_EARLY
213 + UCLIBC_HAS_PROFILING
214 + )
215 + kconfig_q_opt n "${defs[@]}"
216 + kconfig_q_opt debug DODEBUG SUPPORT_LD_DEBUG
217 +
218 + sed -i -e '/ARCH_.*_ENDIAN/d' .config
219 + kconfig_q_opt y "ARCH_WANTS_$(uclibc_endian)_ENDIAN"
220 +
221 + if [[ ${CTARGET} == arm* ]] ; then
222 + kconfig_q_opt n CONFIG_ARM_OABI
223 + kconfig_q_opt y CONFIG_ARM_EABI
224 + fi
225 +
226 + defs=(
227 + MALLOC_GLIBC_COMPAT
228 + DO_C99_MATH
229 + UCLIBC_HAS_{CTYPE_CHECKED,WCHAR,HEXADECIMAL_FLOATS,GLIBC_CUSTOM_PRINTF,FOPEN_EXCLUSIVE_MODE,GLIBC_CUSTOM_STREAMS,PRINTF_M_SPEC}
230 + UCLIBC_HAS_FENV
231 + UCLIBC_HAS_{N,}FTW
232 + UCLIBC_HAS_GNU_GLOB
233 + UCLIBC_HAS_LIBUTIL
234 + UCLIBC_HAS_PROGRAM_INVOCATION_NAME
235 + UCLIBC_HAS_RESOLVER_SUPPORT
236 + UCLIBC_HAS_TZ_FILE_READ_MANY
237 + UCLIBC_HAS_UTMPX
238 + UCLIBC_SUSV3_LEGACY
239 + UCLIBC_SUSV3_LEGACY_MACROS
240 + UCLIBC_SUSV4_LEGACY
241 + PTHREADS_DEBUG_SUPPORT
242 + )
243 + kconfig_q_opt y "${defs[@]}"
244 + kconfig_q_opt n UCLIBC_HAS_CTYPE_UNSAFE
245 + kconfig_q_opt n UCLIBC_HAS_LOCALE
246 + kconfig_q_opt n HAS_NO_THREADS
247 + kconfig_q_opt ipv6 UCLIBC_HAS_IPV6
248 + kconfig_q_opt nptl UCLIBC_HAS_THREADS_NATIVE
249 + kconfig_q_opt !nptl LINUXTHREADS_OLD
250 + kconfig_q_opt rpc UCLIBC_HAS_{,{FULL,REENTRANT}_}RPC
251 + kconfig_q_opt wordexp UCLIBC_HAS_WORDEXP
252 + kconfig_q_opt uclibc-compat UCLIBC_HAS_LIB{NSL,RESOLV}_STUB COMPAT_ATEXIT
253 +
254 + # we need to do it independently of hardened to get ssp.c built into libc
255 + kconfig_q_opt y UCLIBC_HAS_SSP
256 + kconfig_q_opt n UCLIBC_HAS_SSP_COMPAT
257 + kconfig_q_opt y UCLIBC_HAS_ARC4RANDOM
258 + kconfig_q_opt n PROPOLICE_BLOCK_ABRT
259 + kconfig_q_opt y PROPOLICE_BLOCK_SEGV
260 +
261 + # arm/mips do not emit PT_GNU_STACK, but if we enable this here
262 + # it will be emitted as RWE, ppc has to be checked, x86 needs it
263 + # this option should be used independently of hardened
264 + if has $(tc-arch) x86 || has $(tc-arch) ppc ; then
265 + kconfig_q_opt y UCLIBC_BUILD_NOEXECSTACK
266 + else
267 + kconfig_q_opt n UCLIBC_BUILD_NOEXECSTACK
268 + fi
269 + kconfig_q_opt y UCLIBC_BUILD_RELRO
270 + kconfig_q_opt hardened UCLIBC_BUILD_PIE
271 + kconfig_q_opt hardened UCLIBC_BUILD_NOW
272 + kconfig_q_opt !ssp SSP_QUICK_CANARY
273 + kconfig_q_opt ssp UCLIBC_BUILD_SSP
274 +
275 + local def
276 + for def in 1 2 ; do
277 + # Run twice as some config opts depend on others being enabled first.
278 + for def in ${defs_y[@]} ; do
279 + sed -i -e "s:.*\<${def}\>.*set:${def}=y:g" .config
280 + done
281 + for def in ${defs_n[@]} ; do
282 + sed -i -e "s:${def}=y:# ${def} is not set:g" .config
283 + done
284 + src_oldconfig
285 + done
286 +
287 + einfo "Enabled options:"
288 + for def in ${defs_y[@]} ; do
289 + einfo " " $(grep "^${def}=y" .config || echo "could not find ${def}")
290 + done
291 + einfo "Disabled options:"
292 + for def in ${defs_n[@]} ; do
293 + einfo " " $(grep "^# ${def} is not set" .config || echo "could not find ${def}")
294 + done
295 +
296 + # setup build and run paths
297 + sed -i \
298 + -e "/^CROSS_COMPILER_PREFIX/s:=.*:=\"${CTARGET}-\":" \
299 + -e "/^KERNEL_HEADERS/s:=.*:=\"$(alt_build_kprefix)\":" \
300 + -e "/^SHARED_LIB_LOADER_PREFIX/s:=.*:=\"/$(get_libdir)\":" \
301 + -e "/^DEVEL_PREFIX/s:=.*:=\"/usr\":" \
302 + -e "/^RUNTIME_PREFIX/s:=.*:=\"/\":" \
303 + -e "/^UCLIBC_EXTRA_CFLAGS/s:=.*:=\"${UCLIBC_EXTRA_CFLAGS}\":" \
304 + .config || die
305 +
306 + src_oldconfig
307 +}
308 +
309 +src_unpack() {
310 + if [[ ${PV} == "9999" ]] ; then
311 + git-2_src_unpack
312 + else
313 + unpack ${A}
314 + fi
315 + cd "${S}"
316 + if [[ -n ${PATCH_VER} ]] ; then
317 + EPATCH_SUFFIX="patch" epatch "${WORKDIR}"/patch
318 + fi
319 +
320 + check_cpu_opts
321 +
322 + echo
323 + einfo "Runtime Prefix: /"
324 + einfo "Devel Prefix: /usr"
325 + einfo "Kernel Prefix: $(alt_build_kprefix)"
326 + einfo "CBUILD: ${CBUILD}"
327 + einfo "CHOST: ${CHOST}"
328 + einfo "CTARGET: ${CTARGET}"
329 + einfo "CPU: ${UCLIBC_CPU:-default}"
330 + einfo "ENDIAN: $(uclibc_endian)"
331 + echo
332 +
333 + ########## CPU SELECTION ##########
334 +
335 + local target config_target
336 + case $(tc-arch) in
337 + alpha) target="alpha"; config_target="no cpu-specific options";;
338 + amd64) target="x86_64"; config_target="no cpu-specific options";;
339 + arm) target="arm"; config_target="GENERIC_ARM";;
340 + avr) target="avr32"; config_target="no cpu-specific options";;
341 + ia64) target="ia64"; config_target="no cpu-specific options";;
342 + m68k) target="m68k"; config_target="no cpu-specific options";;
343 + mips) target="mips"; config_target="MIPS_ISA_1";;
344 + ppc) target="powerpc"; config_target="no cpu-specific options";;
345 + sh) target="sh"; config_target="SH4";;
346 + sparc) target="sparc"; config_target="no cpu-specific options";;
347 + x86) target="i386"; config_target="GENERIC_386";;
348 + *) die "$(tc-arch) lists no defaults :/";;
349 + esac
350 + sed -i -e "s:default CONFIG_${config_target}:default CONFIG_${UCLIBC_CPU:-${config_target}}:" \
351 + extra/Configs/Config.${target}
352 + sed -i -e "s:^HOSTCC.*=.*:HOSTCC=$(tc-getBUILD_CC):" Rules.mak
353 +
354 + src_config
355 +
356 + if use iconv ; then
357 + # Run after make clean, otherwise files removed
358 + find ./extra/locale/charmaps -name "*.pairs" > extra/locale/codesets.txt
359 + if [[ ! -f /etc/locale.gen ]] ; then
360 + # See ./extra/locale/LOCALES for examples
361 + die "Please create an appropriate /etc/locale.gen for locale support"
362 + fi
363 + echo -e "@euro e\n@cyrillic c\n#---\nUTF-8 yes\n8-BIT yes\n#---\n\n" > ./extra/locale/locales.txt
364 + cat /etc/locale.gen >> ./extra/locale/locales.txt
365 + fi
366 +}
367 +
368 +src_compile() {
369 + emake headers || die
370 + just_headers && return 0
371 +
372 + emake || die
373 + if is_crosscompile ; then
374 + emake -C utils hostutils || die
375 + else
376 + emake utils || die
377 + fi
378 +}
379 +
380 +src_test() {
381 + is_crosscompile && return 0
382 +
383 + # assert test fails on pax/grsec enabled kernels - normal
384 + # vfork test fails in sandbox (both glibc/uclibc)
385 + emake UCLIBC_ONLY=1 check || die
386 +}
387 +
388 +src_install() {
389 + local sysroot=${D}
390 + is_crosscompile && sysroot+="/usr/${CTARGET}"
391 +
392 + local target="install"
393 + just_headers && target="install_headers"
394 + emake DESTDIR="${sysroot}" ${target} || die
395 +
396 + save_config .config
397 +
398 + # remove files coming from kernel-headers
399 + rm -rf "${sysroot}"/usr/include/{linux,asm*}
400 +
401 + # Address bug #425006
402 + if use arm; then
403 + sed -i '/SYS_utime __NR_utime$/d' "${sysroot}"/usr/include/bits/sysnum.h
404 + fi
405 +
406 + # Make sure we install the sys-include symlink so that when
407 + # we build a 2nd stage cross-compiler, gcc finds the target
408 + # system headers correctly. See gcc/doc/gccinstall.info
409 + if is_crosscompile ; then
410 + dosym usr/include /usr/${CTARGET}/sys-include
411 + if ! just_headers && [[ -n $(get_opt HAVE_SHARED) ]] ; then
412 + newbin utils/ldconfig.host ${CTARGET}-ldconfig || die
413 + newbin utils/ldd.host ${CTARGET}-ldd || die
414 + fi
415 + return 0
416 + fi
417 +
418 + emake DESTDIR="${D}" install_utils || die
419 + dobin extra/scripts/getent
420 + dodoc Changelog* README TODO docs/*.txt DEDICATION.mjn3
421 +}
422 +
423 +pkg_postinst() {
424 + is_crosscompile && return 0
425 +
426 + if [ ! -e "${ROOT}"/etc/TZ ] ; then
427 + ewarn "Please remember to set your timezone in /etc/TZ"
428 + mkdir -p "${ROOT}"/etc
429 + echo "UTC" > "${ROOT}"/etc/TZ
430 + fi
431 + [ "${ROOT}" != "/" ] && return 0
432 + # update cache before reloading init
433 + ldconfig
434 + # reload init ...
435 + /sbin/telinit U 2>/dev/null
436 +}