summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-01-12 03:51:45 +0000
committerMike Frysinger <vapier@gentoo.org>2005-01-12 03:51:45 +0000
commit58aff7e0579ef7ebb47128fb99cbd40a86aa80b5 (patch)
tree65befaf38defcbb194c3175409fb81811edf67ae /sys-libs
parentnow in sys-libs (diff)
downloadhistorical-58aff7e0579ef7ebb47128fb99cbd40a86aa80b5.tar.gz
historical-58aff7e0579ef7ebb47128fb99cbd40a86aa80b5.tar.bz2
historical-58aff7e0579ef7ebb47128fb99cbd40a86aa80b5.zip
finish moving from dev-libs
Diffstat (limited to 'sys-libs')
-rw-r--r--sys-libs/uclibc/ChangeLog4
-rw-r--r--sys-libs/uclibc/Manifest18
-rw-r--r--sys-libs/uclibc/files/0.9.26/arm-ucontext.patch10
-rw-r--r--sys-libs/uclibc/files/0.9.26/ssp.c160
-rw-r--r--sys-libs/uclibc/files/0.9.26/uClibc-20040921-ldso-unsecvars.patch36
-rw-r--r--sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-arm-dl-sysdep.patch23
-rw-r--r--sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ldso-cache.patch10
-rw-r--r--sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-resolve-segfault.patch47
-rw-r--r--sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch19
-rw-r--r--sys-libs/uclibc/files/0.9.26/unsecvars.h26
-rw-r--r--sys-libs/uclibc/files/digest-uclibc-0.9.26-r73
-rw-r--r--sys-libs/uclibc/uclibc-0.9.26-r7.ebuild265
12 files changed, 615 insertions, 6 deletions
diff --git a/sys-libs/uclibc/ChangeLog b/sys-libs/uclibc/ChangeLog
index 27741de2c29f..bc402f4cdbdf 100644
--- a/sys-libs/uclibc/ChangeLog
+++ b/sys-libs/uclibc/ChangeLog
@@ -1,6 +1,6 @@
-# ChangeLog for dev-libs/uclibc
+# ChangeLog for sys-libs/uclibc
# Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/ChangeLog,v 1.1 2005/01/12 00:50:53 vapier Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/ChangeLog,v 1.2 2005/01/12 03:51:45 vapier Exp $
11 Jan 2005; Mike Frysinger <vapier@gentoo.org> uclibc-0.9.26-r8.ebuild:
Merge psm & my cross compile work together and BAM we have a sweet ebuild.
diff --git a/sys-libs/uclibc/Manifest b/sys-libs/uclibc/Manifest
index 21ea513e4033..7a79969a7058 100644
--- a/sys-libs/uclibc/Manifest
+++ b/sys-libs/uclibc/Manifest
@@ -1,16 +1,26 @@
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
-MD5 a592172d210be32e6b23bb873a87c4e6 ChangeLog 8164
+MD5 a6d5bf199998859971d78244fd572b29 ChangeLog 8164
MD5 e96b4dfc373a1cdf7735aeae52c4cf7e metadata.xml 999
+MD5 a4612f199b26df52b09c0055f5672567 uclibc-0.9.26-r7.ebuild 7862
MD5 d095a6b2da21d6c48ff51ad967fc3d83 uclibc-0.9.26-r8.ebuild 9460
MD5 6fb9166cb9a919ce76e4ebd58f74fec5 files/0.9.26-r8-cvs.patch 1184
MD5 0b733285f186f31c1be9ffcc42f1064e files/getent 973
MD5 e0556dd58957468793213ab327c590d3 files/digest-uclibc-0.9.26-r8 232
+MD5 6d2b5c523d34c86df9bc37747d9261dc files/digest-uclibc-0.9.26-r7 231
+MD5 f1c1ccc7e86e7b9cad445b15b7409736 files/0.9.26/ssp.c 3938
+MD5 d35beaf332590fed8c619483d4598dc6 files/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch 542
+MD5 b9df87c681aa3a1ef3033cb195e516df files/0.9.26/uclibc-0.9.26-arm-dl-sysdep.patch 795
+MD5 6835449424e7a8a38e9c85ecf1b73577 files/0.9.26/arm-ucontext.patch 303
+MD5 efd96414f3be520f07eabd1c02be1ecb files/0.9.26/uclibc-0.9.26-resolve-segfault.patch 1227
+MD5 7157f784ba7672c9904d289712131a52 files/0.9.26/uclibc-0.9.26-ldso-cache.patch 410
+MD5 7ff9f1e05cdfbbe0e156ea81bf8b55ee files/0.9.26/uClibc-20040921-ldso-unsecvars.patch 1024
+MD5 a503ef49001f5f67d61cd40b0809fb76 files/0.9.26/unsecvars.h 682
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.9.14 (GNU/Linux)
-iD8DBQFB5JyqroRuSHgZdywRAlKSAJ0d+EciEbUIAIMwrej/juQh+zbG/wCfSD7u
-+s0R3L8PNEXGfqq88aujyWQ=
-=wNN4
+iD8DBQFB5J7sroRuSHgZdywRArkQAKCQClFPlqZd99c4NP6FqhPBQpCtGwCdERrO
+faaPK3yt9MwjSzs8NBLx9o4=
+=HJDg
-----END PGP SIGNATURE-----
diff --git a/sys-libs/uclibc/files/0.9.26/arm-ucontext.patch b/sys-libs/uclibc/files/0.9.26/arm-ucontext.patch
new file mode 100644
index 000000000000..78b8d4cc04e4
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/arm-ucontext.patch
@@ -0,0 +1,10 @@
+--- libc/sysdeps/linux/arm/sys/ucontext.h.orig 2004-08-06 12:08:48.234295048 -0400
++++ libc/sysdeps/linux/arm/sys/ucontext.h 2004-08-06 12:09:11.123815312 -0400
+@@ -24,6 +24,7 @@
+ #include <features.h>
+ #include <signal.h>
+ #include <sys/procfs.h>
++#include <bits/sigcontext.h>
+
+ typedef int greg_t;
+
diff --git a/sys-libs/uclibc/files/0.9.26/ssp.c b/sys-libs/uclibc/files/0.9.26/ssp.c
new file mode 100644
index 000000000000..0eac14f230fb
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/ssp.c
@@ -0,0 +1,160 @@
+/*
+ * Distributed under the terms of the GNU General Public License v2
+ * $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/files/0.9.26/ssp.c,v 1.1 2005/01/12 03:51:45 vapier Exp $
+ *
+ * This is a modified version of Hiroaki Etoh's stack smashing routines
+ * implemented for glibc.
+ *
+ * The following people have contributed input to this code.
+ * Ned Ludd - <solar[@]gentoo.org>
+ * Alexander Gabert - <pappy[@]gentoo.org>
+ * The PaX Team - <pageexec[@]freemail.hu>
+ * Peter S. Mazinger - <ps.m[@]gmx.net>
+ * Yoann Vandoorselaere - <yoann[@]prelude-ids.org>
+ * Robert Connolly - <robert[@]linuxfromscratch.org>
+ * Cory Visi <cory@visi.name>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/syslog.h>
+#include <sys/time.h>
+#include <sys/sysctl.h>
+
+#ifndef _PATH_LOG
+#define _PATH_LOG "/dev/log"
+#endif
+
+#ifdef __PROPOLICE_BLOCK_SEGV__
+#define SSP_SIGTYPE SIGSEGV
+#elif __PROPOLICE_BLOCK_KILL__
+#define SSP_SIGTYPE SIGKILL
+#else
+#define SSP_SIGTYPE SIGABRT
+#endif
+
+unsigned long __guard = 0UL;
+
+void
+__guard_setup (void)
+{
+ size_t size;
+#ifdef HAVE_DEV_ERANDOM
+ int mib[3];
+#endif
+
+ if (__guard != 0UL)
+ return;
+
+#ifndef __SSP_QUICK_CANARY__
+#ifdef HAVE_DEV_ERANDOM
+ /* Random is another depth in Linux, hence an array of 3. */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_RANDOM;
+ mib[2] = RANDOM_ERANDOM;
+
+ size = sizeof (unsigned long);
+ if (__sysctl (mib, 3, &__guard, &size, NULL, 0) != (-1))
+ if (__guard != 0UL)
+ return;
+#endif
+ /*
+ * Attempt to open kernel pseudo random device if one exists before
+ * opening urandom to avoid system entropy depletion.
+ */
+ {
+ int fd;
+#ifdef HAVE_DEV_ERANDOM
+ if ((fd = open ("/dev/erandom", O_RDONLY)) == (-1))
+#endif
+ fd = open ("/dev/urandom", O_RDONLY);
+ if (fd != (-1))
+ {
+ size = read (fd, (char *) &__guard, sizeof (__guard));
+ close (fd);
+ if (size == sizeof (__guard))
+ return;
+ }
+ }
+#endif
+
+ /* If sysctl was unsuccessful, use the "terminator canary". */
+ __guard = 0xFF0A0D00UL;
+
+ {
+ /* Everything failed? Or we are using a weakened model of the
+ * terminator canary */
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ __guard ^= tv.tv_usec ^ tv.tv_sec;
+ }
+}
+
+void
+__stack_smash_handler (char func[], int damaged)
+{
+ struct sockaddr_un sock; /* AF_UNIX address of local logger */
+ struct sigaction sa;
+ const char message[] = ": stack smashing attack in function ";
+ int bufsz, len, log;
+ char buf[512];
+ extern char *__progname;
+
+ sigset_t mask;
+ sigfillset (&mask);
+
+ sigdelset (&mask, SSP_SIGTYPE); /* Block all signal handlers */
+ sigprocmask (SIG_BLOCK, &mask, NULL); /* except SIGABRT */
+
+ bufsz = sizeof (buf);
+ strcpy (buf, "<2>");
+ len = 3;
+
+ strncat (buf, __progname, sizeof (buf) - 4);
+ len = strlen (buf);
+
+ if (bufsz > len)
+ {
+ strncat (buf, message, bufsz - len - 1);
+ len = strlen (buf);
+ }
+ if (bufsz > len)
+ {
+ strncat (buf, func, bufsz - len - 1);
+ len = strlen (buf);
+ }
+
+ /* print error message */
+ write (STDERR_FILENO, buf + 3, len - 3);
+ write (STDERR_FILENO, "()\n", 3);
+ if ((log = socket (AF_UNIX, SOCK_DGRAM, 0)) != -1)
+ {
+ /* Send "found" message to the "/dev/log" path */
+ sock.sun_family = AF_UNIX;
+ (void) strncpy (sock.sun_path, _PATH_LOG, sizeof (sock.sun_path) - 1);
+ sock.sun_path[sizeof (sock.sun_path) - 1] = '\0';
+ sendto (log, buf, len, 0, (struct sockaddr *) &sock, sizeof (sock));
+ }
+
+ /* Make sure the default handler is associated with the our signal handler */
+
+ memset (&sa, 0, sizeof (struct sigaction));
+ sigfillset (&sa.sa_mask); /* Block all signals */
+ sa.sa_flags = 0;
+ sa.sa_handler = SIG_DFL;
+ sigaction (SSP_SIGTYPE, &sa, NULL);
+ (void) kill (getpid (), SSP_SIGTYPE);
+ _exit (127);
+}
diff --git a/sys-libs/uclibc/files/0.9.26/uClibc-20040921-ldso-unsecvars.patch b/sys-libs/uclibc/files/0.9.26/uClibc-20040921-ldso-unsecvars.patch
new file mode 100644
index 000000000000..5e58588e7e80
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/uClibc-20040921-ldso-unsecvars.patch
@@ -0,0 +1,36 @@
+--- ldso/ldso/ldso.c 8 Sep 2004 09:43:24 -0000 1.121
++++ ldso/ldso/ldso.c 21 Sep 2004 05:33:40 -0000
+@@ -31,6 +31,7 @@
+
+
+ #include "ldso.h"
++#include "unsecvars.h"
+
+ #define ALLOW_ZERO_PLTGOT
+
+@@ -325,11 +326,21 @@ void _dl_get_ready_to_run(struct elf_res
+ _dl_preload = _dl_getenv("LD_PRELOAD", envp);
+ _dl_library_path = _dl_getenv("LD_LIBRARY_PATH", envp);
+ } else {
++ static const char unsecure_envvars[] =
++#ifdef EXTRA_UNSECURE_ENVVARS
++ EXTRA_UNSECURE_ENVVARS
++#endif
++ UNSECURE_ENVVARS;
++ const char *nextp;
+ _dl_secure = 1;
+- _dl_preload = _dl_getenv("LD_PRELOAD", envp);
+- _dl_unsetenv("LD_AOUT_PRELOAD", envp);
+- _dl_unsetenv("LD_LIBRARY_PATH", envp);
+- _dl_unsetenv("LD_AOUT_LIBRARY_PATH", envp);
++
++ nextp = unsecure_envvars;
++ do {
++ _dl_unsetenv (nextp, envp);
++ /* We could use rawmemchr but this need not be fast. */
++ nextp = (char *) _dl_strchr(nextp, '\0') + 1;
++ } while (*nextp != '\0');
++ _dl_preload = NULL;
+ _dl_library_path = NULL;
+ }
+ }
diff --git a/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-arm-dl-sysdep.patch b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-arm-dl-sysdep.patch
new file mode 100644
index 000000000000..a1b50c0aa5aa
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-arm-dl-sysdep.patch
@@ -0,0 +1,23 @@
+Index: ldso/ldso/arm/dl-sysdep.h
+===================================================================
+RCS file: /var/cvs/uClibc/ldso/ldso/arm/dl-sysdep.h,v
+retrieving revision 1.9
+diff -u -b -B -w -p -r1.9 dl-sysdep.h
+--- ldso/ldso/arm/dl-sysdep.h 17 Feb 2004 10:55:54 -0000 1.9
++++ ldso/ldso/arm/dl-sysdep.h 23 Jun 2004 17:57:35 -0000
+@@ -5,6 +5,9 @@
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen@codpoet.org>
+ */
+
++#ifndef __DL_SYSDEP_H__
++#define __DL_SYSDEP_H__
++
+ /* Define this if the system uses RELOCA. */
+ #undef ELF_USES_RELOCA
+
+@@ -66,3 +69,5 @@ unsigned long _dl_linux_resolver(struct
+ #define elf_machine_type_class(type) \
+ ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
+ | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
++
++#endif /* __DL_SYSDEP_H__ */
diff --git a/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ldso-cache.patch b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ldso-cache.patch
new file mode 100644
index 000000000000..40867d15152b
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ldso-cache.patch
@@ -0,0 +1,10 @@
+--- ldso/ldso/dl-elf.c.orig 2004-08-09 19:01:02 +0000
++++ ldso/ldso/dl-elf.c 2004-08-09 19:00:40 +0000
+@@ -329,6 +329,7 @@
+ #endif
+ for (i = 0; i < header->nlibs; i++) {
+ if ((libent[i].flags == LIB_ELF ||
++ libent[i].flags == LIB_ELF_LIBC0 ||
+ libent[i].flags == LIB_ELF_LIBC5) &&
+ _dl_strcmp(libname, strs + libent[i].sooffset) == 0 &&
+ (tpnt1 = _dl_load_elf_shared_library(secure,
diff --git a/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-resolve-segfault.patch b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-resolve-segfault.patch
new file mode 100644
index 000000000000..2b9b1ab1dc66
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-resolve-segfault.patch
@@ -0,0 +1,47 @@
+--- libc/inet/resolv.c.orig 2004-08-09 14:04:58 +0000
++++ libc/inet/resolv.c 2004-08-09 14:07:09 +0000
+@@ -1846,6 +1846,7 @@
+ {
+ struct in_addr *in;
+ struct in_addr **addr_list;
++ char **alias;
+ unsigned char *packet;
+ struct resolv_answer a;
+ int i;
+@@ -1899,17 +1900,27 @@
+
+ addr_list[0] = in;
+ addr_list[1] = 0;
+-
++
++ if (buflen < sizeof(char *)*(ALIAS_DIM))
++ return ERANGE;
++ alias=(char **)buf;
++ buf+=sizeof(char **)*(ALIAS_DIM);
++ buflen-=sizeof(char **)*(ALIAS_DIM);
++
+ if (buflen<256)
+ return ERANGE;
+ strncpy(buf, name, buflen);
+
++ alias[0] = buf;
++ alias[1] = NULL;
++
+ /* First check if this is already an address */
+ if (inet_aton(name, in)) {
+ result_buf->h_name = buf;
+ result_buf->h_addrtype = AF_INET;
+ result_buf->h_length = sizeof(*in);
+ result_buf->h_addr_list = (char **) addr_list;
++ result_buf->h_aliases = alias;
+ *result=result_buf;
+ *h_errnop = NETDB_SUCCESS;
+ return NETDB_SUCCESS;
+@@ -1954,6 +1965,7 @@
+ result_buf->h_addrtype = AF_INET;
+ result_buf->h_length = sizeof(*in);
+ result_buf->h_addr_list = (char **) addr_list;
++ result_buf->h_aliases = alias; /* TODO: generate the full list */
+ free(packet);
+ break;
+ } else {
diff --git a/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch
new file mode 100644
index 000000000000..b3619d079ece
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch
@@ -0,0 +1,19 @@
+--- ./libc/sysdeps/linux/common/ssp.c.old 2004-05-17 06:46:31.000000000 -0400
++++ ./libc/sysdeps/linux/common/ssp.c 2004-05-17 07:46:42.264773000 -0400
+@@ -44,9 +44,15 @@
+ #define SSP_SIGTYPE SIGABRT
+ #endif
+
++#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
++#define __attribute_used__ __attribute__((__used__))
++#else
++#define __attribute_used__ __attribute__((__unused__))
++#endif
++
+ unsigned long __guard = 0UL;
+
+-void
++__attribute_used__ void __attribute__ ((visibility ("default")))
+ __guard_setup (void)
+ {
+ size_t size;
diff --git a/sys-libs/uclibc/files/0.9.26/unsecvars.h b/sys-libs/uclibc/files/0.9.26/unsecvars.h
new file mode 100644
index 000000000000..5e060a6516dc
--- /dev/null
+++ b/sys-libs/uclibc/files/0.9.26/unsecvars.h
@@ -0,0 +1,26 @@
+/*
+ * Environment variable to be removed for SUID programs. The names are all
+ * stuffed in a single string which means they have to be terminated with a
+ * '\0' explicitly.
+ */
+
+#define UNSECURE_ENVVARS \
+ "LD_AOUT_PRELOAD\0" \
+ "LD_AOUT_LIBRARY_PATH\0" \
+ "LD_PRELOAD\0" \
+ "LD_LIBRARY_PATH\0" \
+ "LD_DEBUG\0" \
+ "LD_DEBUG_OUTPUT\0" \
+ "HOSTALIASES\0" \
+ "LOCALDOMAIN\0" \
+ "RES_OPTIONS\0" \
+ "TMPDIR\0"
+
+/*
+ * These environment variables are defined by glibc but ignored in
+ * uClibc, but may very well have an equivalent in uClibc.
+ *
+ * MALLOC_TRACE, RESOLV_HOST_CONF, TZDIR, GCONV_PATH, LD_USE_LOAD_BIAS,
+ * LD_PROFILE, LD_ORIGIN_PATH, LOCPATH, NLSPATH
+ */
+
diff --git a/sys-libs/uclibc/files/digest-uclibc-0.9.26-r7 b/sys-libs/uclibc/files/digest-uclibc-0.9.26-r7
new file mode 100644
index 000000000000..355f8d702bae
--- /dev/null
+++ b/sys-libs/uclibc/files/digest-uclibc-0.9.26-r7
@@ -0,0 +1,3 @@
+MD5 7212713c432dd0de6ec2140c2a6212e4 uClibc-0.9.26.tar.bz2 1604543
+MD5 1c082d43f02e7fa199fe724469111d88 uClibc-0.9.26-cvs-update-20040808.patch.bz2 345344
+MD5 b7820c6b79f02d2d07a7ac75abfe90a5 uClibc-0.9.26-patches-1.1.tar.bz2 7162
diff --git a/sys-libs/uclibc/uclibc-0.9.26-r7.ebuild b/sys-libs/uclibc/uclibc-0.9.26-r7.ebuild
new file mode 100644
index 000000000000..abfc9e7985df
--- /dev/null
+++ b/sys-libs/uclibc/uclibc-0.9.26-r7.ebuild
@@ -0,0 +1,265 @@
+# Copyright 1999-2005 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-libs/uclibc/uclibc-0.9.26-r7.ebuild,v 1.1 2005/01/12 03:51:45 vapier Exp $
+
+inherit eutils flag-o-matic gcc
+
+# To make a new CVS_VER we do.
+# wget -O - http://uclibc.org/downloads/snapshots/uClibc-`date +%Y%m%d`.tar.bz2 | tar jxf -
+# tar jxf /usr/portage/distfiles/uClibc-0.9.26.tar.bz2
+# diff -urN --exclude .cvsignore --exclude CVS uClibc-0.9.26 uClibc | bzip2 - > uClibc-0.9.26-cvs-update-`date +%Y%m%d`.patch.bz2
+# rm -rf uClibc-0.9.26-cvs-update-`date +%Y%m%d`.patch.bz2 uClibc uClibc-0.9.26
+
+MY_P="${P/ucl/uCl}"
+CVS_VER="20040808"
+PATCH_VER="1.1"
+DESCRIPTION="C library for developing embedded Linux systems"
+HOMEPAGE="http://www.uclibc.org/"
+SRC_URI="http://www.kernel.org/pub/linux/libs/uclibc/${MY_P}.tar.bz2
+ mirror://gentoo/${MY_P}-cvs-update-${CVS_VER}.patch.bz2
+ mirror://gentoo/${MY_P}-patches-${PATCH_VER}.tar.bz2"
+
+LICENSE="LGPL-2"
+SLOT="0"
+KEYWORDS="x86 ppc ~sparc mips arm"
+IUSE="build hardened ipv6 static debug" # nls is not supported yet
+RESTRICT="nostrip"
+
+DEPEND="sys-devel/gcc"
+RDEPEND=""
+PROVIDE="virtual/glibc virtual/libc"
+
+S=${WORKDIR}/${MY_P}
+
+check_main_libc() {
+ if [ "${CHOST/uclibc}" != "${CHOST}" ] ; then
+ SYS_LIBC=uClibc
+ else
+ SYS_LIBC=glibc
+ fi
+ export SYS_LIBC
+ echo
+ einfo "We are building for ${SYS_LIBC} system library"
+ echo
+}
+
+src_unpack() {
+ unpack ${A}
+ cd ${S}
+
+ if [ -n "${CVS_VER}" ]
+ then
+ epatch ${DISTDIR}/${MY_P}-cvs-update-${CVS_VER}.patch.bz2
+ fi
+
+ cp ${FILESDIR}/0.9.26/ssp.c ${S}/libc/sysdeps/linux/common/ \
+ || die "failed to copy ssp.c to ${S}/libc/sysdeps/linux/common/"
+ # gcc 3.4 nukes ssp without this patch
+ if [ "`gcc-major-version`" -eq "3" -a "`gcc-minor-version`" -ge "4" ]
+ then
+ epatch ${FILESDIR}/0.9.26/uclibc-0.9.26-ssp-gcc34-after-frandom.patch
+ fi
+
+ if [ -n "${PATCH_VER}" ]
+ then
+ unpack ${MY_P}-patches-${PATCH_VER}.tar.bz2
+ # for now we remove relro/now, no support for relro in ldso
+ rm -f ${WORKDIR}/patch/*relro*
+ rm -f ${WORKDIR}/patch/*now*
+ rm -f ${WORKDIR}/patch/11_all_uClibc-0.9.26-socket.patch.bz2
+ # remove default ssp build
+ use hardened || rm -f ${WORKDIR}/patch/*enable-ssp*
+ epatch ${WORKDIR}/patch
+ fi
+
+ # support archs which dont implement all syscalls
+ [ -z "${CVS_VER}" ] \
+ && epatch ${FILESDIR}/${PV}/arm-fix-missing-syscalls.patch \
+ || epatch ${FILESDIR}/${PV}/uclibc-0.9.26-arm-dl-sysdep.patch
+ epatch ${FILESDIR}/${PV}/arm-ucontext.patch
+
+ # build all .S files w/ -Wa,--noexecstack
+ if [ "0${CVS_VER}" -ge "20040730" ]; then
+ einfo "Skipping noexecstack patch. (need update)"
+ else
+ epatch ${FILESDIR}/${PV}/${PN}-${PV}-noexecstack.patch
+ fi
+
+ # fix segfaults when running things like `emerge sync`
+ epatch ${FILESDIR}/${PV}/${PN}-${PV}-resolve-segfault.patch
+
+ # allow libs tagged as ELF_LIBC0 in the cache to be loaded
+ epatch ${FILESDIR}/${PV}/${PN}-${PV}-ldso-cache.patch
+
+ # Take extra security precaution's for suid handling with environment variables
+ epatch ${FILESDIR}/${PV}/uClibc-20040921-ldso-unsecvars.patch
+ cp ${FILESDIR}/${PV}/unsecvars.h ${S}/ldso/include/ || die
+
+ # fixup for install perms
+ sed -i -e "s:-fa:-dRf:g" Makefile
+
+ local target=""
+ if [ "${ARCH}" == "x86" ] ; then
+ target="i386"
+ elif [ "${ARCH}" == "ppc" ] ; then
+ target="powerpc"
+ else
+ # sparc|mips|alpha|arm|sh
+ target="${ARCH}"
+ fi
+ sed -i \
+ -e "s:default TARGET_i386:default TARGET_${target}:" \
+ extra/Configs/Config.in
+ sed -i \
+ -e "s:default CONFIG_GENERIC_386:default CONFIG_${UCLIBC_CPU:-GENERIC_386}:" \
+ extra/Configs/Config.${target}
+
+ make defconfig >/dev/null || die "could not config"
+
+ for def in UCLIBC_PROFILING DO{DEBUG,ASSERTS} SUPPORT_LD_DEBUG{,_EARLY} ; do
+ sed -i -e "s:${def}=y:# ${def} is not set:" .config
+ done
+ if use debug ; then
+ echo "SUPPORT_LD_DEBUG=y" >> .config
+ echo "DODEBUG=y" >> .config
+ fi
+
+ for def in DO_C99_MATH UCLIBC_HAS_{RPC,CTYPE_CHECKED,WCHAR,HEXADECIMAL_FLOATS,GLIBC_CUSTOM_PRINTF,FOPEN_EXCLUSIVE_MODE,GLIBC_CUSTOM_STREAMS,PRINTF_M_SPEC,FTW} ; do
+ sed -i -e "s:# ${def} is not set:${def}=y:" .config
+ done
+ echo "UCLIBC_HAS_FULL_RPC=y" >> .config
+ echo "PTHREADS_DEBUG_SUPPORT=y" >> .config
+
+ #if use nls
+ #then
+ # sed -i -e "s:# UCLIBC_HAS_LOCALE is not set:UCLIBC_HAS_LOCALE=y:" .config
+ # echo "UCLIBC_HAS_XLOCALE=n" >> .config
+ # echo "UCLIBC_HAS_GLIBC_DIGIT_GROUPING=y" >> .config
+ # echo "UCLIBC_HAS_SCANF_LENIENT_DIGIT_GROUPING=y" >> .config
+ # echo "UCLIBC_HAS_GETTEXT_AWARENESS=y" >> .config
+ # # on pax enabled kernels the locale files can't be built
+ # echo "UCLIBC_PREGENERATED_LOCALE_DATA=n" >> .config
+ #fi
+ # we disable LOCALE for any case, gettext has to be used
+ echo "UCLIBC_HAS_LOCALE=n" >> .config
+
+ use ipv6 && sed -i -e "s:# UCLIBC_HAS_IPV6 is not set:UCLIBC_HAS_IPV6=y:" .config
+
+ if use hardened
+ then
+ if use x86
+ then
+ einfo "Enable Position Independent Executable support in ${P}"
+ sed -i -e "s:# UCLIBC_PIE_SUPPORT.*:UCLIBC_PIE_SUPPORT=y:" .config
+ fi
+
+ einfo "Enable Stack Smashing Protections support in ${P}"
+ sed -i -e "s:# UCLIBC_PROPOLICE.*:UCLIBC_PROPOLICE=y:" .config
+ echo "PROPOLICE_BLOCK_ABRT=n" >> .config
+ echo "PROPOLICE_BLOCK_SEGV=n" >> .config
+ echo "PROPOLICE_BLOCK_KILL=y" >> .config
+ fi
+
+ # we are building against system installed kernel headers
+ sed -i -e 's:KERNEL_SOURCE.*:KERNEL_SOURCE="/usr":' .config
+
+ check_main_libc
+ if [ "${SYS_LIBC}" = "uClibc" ] ; then
+ sed -i \
+ -e 's:SHARED_LIB_LOADER_PREFIX=.*:SHARED_LIB_LOADER_PREFIX="/lib":' \
+ -e 's:DEVEL_PREFIX=.*:DEVEL_PREFIX="/usr":' \
+ -e 's:RUNTIME_PREFIX=.*:RUNTIME_PREFIX="/":' \
+ .config
+ sed -i '/LIBRARY_CACHE:=/s:#::' Rules.mak
+ fi
+
+ make -s oldconfig > /dev/null || die "could not make oldconfig"
+
+ chmod +x extra/scripts/relative_path.sh
+
+ cp .config myconfig
+
+ emake clean >/dev/null || die "could not clean"
+
+ sed -i 's:-DUCLIBC:$(LIBRARY_CACHE) -DUCLIBC:' ldso/{ldso,libdl}/Makefile
+ sed -i 's:\$(R_PREFIX):\\"$(RUNTIME_PREFIX)\\" $(LIBRARY_CACHE):' utils/Makefile
+ sed -i 's: I\.: -I.:' ldso/libdl/Makefile
+ sed -i 's:sys/user\.h:asm/page.h:' libc/misc/internals/__uClibc_main.c
+}
+
+src_compile() {
+ # running tests require this
+ use build || addwrite /dev/ptmx
+ cp myconfig .config
+
+ #if use nls
+ #then
+ # # these can be built only if the build system supports locales (as of 0.9.26)
+ # emake -j1 headers
+ # cd extra/locale
+ # make clean
+ # find ./charmaps -name "*.pairs" > codesets.txt
+ # cp LOCALES locales.txt
+ # emake -j1 || die "could not make locales"
+ # cd ../..
+ #fi
+
+ emake -j1 || die "could not make"
+ check_main_libc
+ if [ "${SYS_LIBC}" = "uClibc" ]
+ then
+ emake -j1 utils || die "could not make utils"
+ fi
+
+ if ! use build
+ then
+ if ! hasq maketest $RESTRICT
+ then
+ # assert test fails on pax enabled kernels - normal
+ # vfork test fails in sandbox (both glibc/uclibc)
+ cd test; make; cd ..
+ fi
+ fi
+}
+
+src_install() {
+ emake PREFIX=${D} install || die "install failed"
+
+ # remove files coming from kernel-headers
+ # scsi is uclibc's own directory since cvs 20040212
+ check_main_libc
+ if [ "${SYS_LIBC}" = "uClibc" ]
+ then
+ rm -rf ${D}/usr/include/{asm,linux}
+ rm -f ${D}/usr/lib/lib*_pic.a
+ ! use static && use build && rm -f ${D}/usr/lib/lib*.a
+
+ emake PREFIX=${D} install_utils || die "install-utils failed"
+ dodir /usr/bin
+ exeinto /usr/bin
+ doexe ${FILESDIR}/getent
+ fi
+
+ # shameless plug for mjn3 who gives us so much...
+ # please give back if you can. -solar
+ f=DEDICATION.mjn3 ; [ -e "$f" ] && ( cat $f ; epause 2 )
+
+ if ! use build
+ then
+ dodoc Changelog* README TODO docs/*.txt DEDICATION.mjn3
+ doman debian/*.1
+ fi
+}
+
+#pkg_postinst() {
+#check_main_libc
+#if [ "${SYS_LIBC}" = "uClibc" ] ; then
+# if [ "${ROOT}" = "/" ] ; then
+# /sbin/ldconfig
+# [ ! -e /etc/TZ ] && echo UTC > /etc/TZ
+# # reload init?
+# fi
+#else
+#should we add the lib dir to ld.so.conf?
+#fi
+#}