--- /dev/null
+/* skeleton based on version from Fedora Core 3 */
+
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <dirent.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <elf.h>
+
+#define verbose_exec(failcode, fail_ok, path...) \
+ do \
+ { \
+ char *const arr[] = { path, NULL }; \
+ vexec (failcode, fail_ok, arr); \
+ } while (0)
+
+__attribute__((noinline)) void vexec (int failcode, int fail_ok, char *const path[]);
+__attribute__((noinline)) void says (const char *str);
+__attribute__((noinline)) void sayn (long num);
+__attribute__((noinline)) void message (char *const path[]);
+__attribute__((noinline)) int check_elf (const char *name);
+
+int
+main (void)
+{
+ char initpath[256];
+ struct stat root, init_root;
+
+ /* First, get rid of platform-optimized libraries. We remove any we have
+ ever built, since otherwise we might end up using some old leftover
+ libraries when new ones aren't installed in their place anymore. */
+#ifdef REMOVE_TLS_DIRS
+ const char *library[] = {"libc.so.6", "libc.so.6.1", "libm.so.6",
+ "libm.so.6.1", "librt.so.1", "librtkaio.so.1",
+ "libpthread.so.0", "libthread_db.so.1"};
+ const char *remove_dir[] = {
+#ifdef __i386__
+ "/lib/i686/",
+#endif
+#ifdef __powerpc64__
+#ifdef REMOVE_PPC_OPTIMIZE_POWER4
+ "/lib64/power4/",
+ "/lib64/ppc970/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER5
+ "/lib64/power5/",
+ "/lib64/power5+/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER6
+ "/lib64/power6/",
+ "/lib64/power6x/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER7
+ "/lib64/power7/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_CELL
+ "/lib64/ppc-cell-be/",
+#endif
+#endif /* __powerpc64__ */
+#ifdef __powerpc__
+#ifdef REMOVE_PPC_OPTIMIZE_POWER4
+ "/lib/power4/",
+ "/lib/ppc970/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER5
+ "/lib/power5/",
+ "/lib/power5+/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER6
+ "/lib/power6/",
+ "/lib/power6x/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_POWER7
+ "/lib/power7/",
+#endif
+#ifdef REMOVE_PPC_OPTIMIZE_CELL
+ "/lib/ppc-cell-be/",
+#endif
+#endif /* __powerpc__ */
+ LIBDIR"/tls/" };
+ int i, j;
+
+ for (i = 0; i < sizeof (remove_dir) / sizeof (remove_dir[0]); ++i)
+ for (j = 0; j < sizeof (library) / sizeof (library[0]); j++)
+ {
+ char buf[strlen (remove_dir[i]) + strlen (library[j]) + 1];
+ char readlink_buf[(strlen (remove_dir[i]) + strlen (library[j])) * 2 + 30];
+ ssize_t len;
+ char *cp;
+
+ cp = stpcpy (buf, remove_dir[i]);
+ strcpy (cp, library[j]);
+ /* This file could be a symlink to library-%{version}.so, so check
+ this and don't remove only the link, but also the library itself. */
+ cp = stpcpy (readlink_buf, remove_dir[i]);
+ if ((len = readlink (buf, cp, (sizeof (readlink_buf)
+ - (cp - readlink_buf) - 1))) > 0)
+ {
+ cp[len] = '\0';
+ if (cp[0] != '/') cp = readlink_buf;
+ unlink (cp);
+ }
+ unlink (buf);
+ }
+#endif
+
+ /* If installing bi-arch glibc, rpm sometimes doesn't unpack all files
+ before running one of the lib's %post scriptlet. /sbin/ldconfig will
+ then be run by the other arch's %post. */
+ if (access ("/sbin/ldconfig", X_OK) == 0)
+ verbose_exec (110, 0, "/sbin/ldconfig", "/sbin/ldconfig", "-X");
+
+ if (utimes (GCONV_MODULES_DIR "/gconv-modules.cache", NULL) == 0)
+ {
+#ifndef ICONVCONFIG
+#define ICONVCONFIG "/usr/sbin/iconvconfig"
+#endif
+ verbose_exec (113, 0, ICONVCONFIG, "/usr/sbin/iconvconfig",
+ "-o", GCONV_MODULES_DIR"/gconv-modules.cache",
+ "--nostdlib", GCONV_MODULES_DIR);
+ }
+
+ /* Implement %set_permissions %{_libexecdir}/pt_chown. */
+ if (access ("/usr/bin/chkstat", X_OK) == 0)
+ verbose_exec (114, 1, "/usr/bin/chkstat", "/usr/bin/chkstat",
+ "-n", "--set", "--system", "/usr/lib/pt_chown");
+
+ /* Check if telinit is available and the init fifo as well. */
+ if (access ("/sbin/telinit", X_OK) || access ("/dev/initctl", F_OK))
+ _exit (0);
+ /* Check if we are not inside of some chroot, because we'd just
+ timeout and leave /etc/initrunlvl. */
+ if (readlink ("/proc/1/exe", initpath, 256) <= 0 ||
+ readlink ("/proc/1/root", initpath, 256) <= 0 ||
+ stat ("/proc/1/root", &init_root) < 0 ||
+ stat ("/.buildenv", &init_root) < 0 || /* XEN build */
+ stat ("/", &root) < 0 ||
+ init_root.st_dev != root.st_dev || init_root.st_ino != root.st_ino)
+ _exit (0);
+
+ if (check_elf ("/proc/1/exe"))
+ verbose_exec (116, 0, "/sbin/telinit", "/sbin/telinit", "u");
+
+#if 0
+ /* Check if we can safely condrestart sshd. */
+ if (access ("/sbin/service", X_OK) == 0
+ && access ("/usr/sbin/sshd", X_OK) == 0
+ && access ("/bin/bash", X_OK) == 0)
+ {
+ if (check_elf ("/usr/sbin/sshd"))
+ verbose_exec (121, 0, "/sbin/service", "/sbin/service", "sshd", "condrestart");
+ }
+#endif
+
+ _exit(0);
+}
+
+void
+vexec (int failcode, int fail_ok, char *const path[])
+{
+ pid_t pid;
+ int status, save_errno;
+
+ pid = vfork ();
+ if (pid == 0)
+ {
+ execv (path[0], path + 1);
+ save_errno = errno;
+ message (path);
+ says (" exec failed with errno ");
+ sayn (save_errno);
+ says ("\n");
+ _exit (failcode);
+ }
+ else if (pid < 0)
+ {
+ save_errno = errno;
+ message (path);
+ says (" fork failed with errno ");
+ sayn (save_errno);
+ says ("\n");
+ _exit (failcode + 1);
+ }
+ if (waitpid (0, &status, 0) != pid || !WIFEXITED (status))
+ {
+ message (path);
+ says (" child terminated abnormally\n");
+ _exit (failcode + 2);
+ }
+ if (WEXITSTATUS (status))
+ {
+ message (path);
+ says (" child exited with exit code ");
+ sayn (WEXITSTATUS (status));
+ if (fail_ok)
+ {
+ says (" (ignored) \n");
+ }
+ else
+ {
+ says ("\n");
+ _exit (WEXITSTATUS (status));
+ }
+ }
+}
+
+void
+says (const char *str)
+{
+ write (1, str, strlen (str));
+}
+
+void
+sayn (long num)
+{
+ char string[sizeof (long) * 3 + 1];
+ char *p = string + sizeof (string) - 1;
+
+ *p = '\0';
+ if (num == 0)
+ *--p = '0';
+ else
+ while (num)
+ {
+ *--p = '0' + num % 10;
+ num = num / 10;
+ }
+
+ says (p);
+}
+
+void
+message (char *const path[])
+{
+ says ("/usr/sbin/glibc_post_upgrade: While trying to execute ");
+ says (path[0]);
+}
+
+int
+check_elf (const char *name)
+{
+ /* Play safe, if we can't open or read, assume it might be
+ ELF for the current arch. */
+ int ret = 1;
+ int fd = open (name, O_RDONLY);
+ if (fd >= 0)
+ {
+ Elf32_Ehdr ehdr;
+ if (read (fd, &ehdr, offsetof (Elf32_Ehdr, e_version))
+ == offsetof (Elf32_Ehdr, e_version))
+ {
+ ret = 0;
+ if (ehdr.e_ident[EI_CLASS]
+ == (sizeof (long) == 8 ? ELFCLASS64 : ELFCLASS32))
+ {
+#if defined __i386__
+ ret = ehdr.e_machine == EM_386;
+#elif defined __x86_64__
+ ret = ehdr.e_machine == EM_X86_64;
+#elif defined __ia64__
+ ret = ehdr.e_machine == EM_IA_64;
+#elif defined __powerpc64__
+ ret = ehdr.e_machine == EM_PPC64;
+#elif defined __powerpc__
+ ret = ehdr.e_machine == EM_PPC;
+#elif defined __s390__ || defined __s390x__
+ ret = ehdr.e_machine == EM_S390;
+#elif defined __x86_64__
+ ret = ehdr.e_machine == EM_X86_64;
+#elif defined __sparc__
+ if (sizeof (long) == 8)
+ ret = ehdr.e_machine == EM_SPARCV9;
+ else
+ ret = (ehdr.e_machine == EM_SPARC
+ || ehdr.e_machine == EM_SPARC32PLUS);
+#else
+ ret = 1;
+#endif
+ }
+ }
+ close (fd);
+ }
+ return ret;
+}
+
+#ifdef SMALL_BINARY
+
+int __libc_multiple_threads __attribute__((nocommon));
+int __libc_enable_asynccancel (void) { return 0; }
+void __libc_disable_asynccancel (int x) { }
+void __libc_csu_init (void) { }
+void __libc_csu_fini (void) { }
+pid_t __fork (void) { return -1; }
+char thr_buf[65536];
+
+#ifndef __powerpc__
+int
+__libc_start_main (int (*main) (void), int argc, char **argv,
+ void (*init) (void), void (*fini) (void),
+ void (*rtld_fini) (void), void * stack_end)
+#else
+struct startup_info
+{
+ void *sda_base;
+ int (*main) (int, char **, char **, void *);
+ int (*init) (int, char **, char **, void *);
+ void (*fini) (void);
+};
+
+int
+__libc_start_main (int argc, char **ubp_av, char **ubp_ev,
+ void *auxvec, void (*rtld_fini) (void),
+ struct startup_info *stinfo,
+ char **stack_on_entry)
+#endif
+{
+#if defined __ia64__ || defined __powerpc64__
+ register void *r13 __asm ("r13") = thr_buf + 32768;
+ __asm ("" : : "r" (r13));
+#elif defined __sparc__
+ register void *g6 __asm ("g6") = thr_buf + 32768;
+# ifdef __arch64__
+ __thread_self = thr_buf + 32768;
+# else
+ register void *__thread_self __asm ("g7") = thr_buf + 32768;
+# endif
+ __asm ("" : : "r" (g6), "r" (__thread_self));
+#elif defined __s390__ && !defined __s390x__
+ __asm ("sar %%a0,%0" : : "d" (thr_buf + 32768));
+#elif defined __s390x__
+ __asm ("sar %%a1,%0; srlg 0,%0,32; sar %%a0,0" : : "d" (thr_buf + 32768) : "0");
+#elif defined __powerpc__ && !defined __powerpc64__
+ register void *r2 __asm ("r2") = thr_buf + 32768;
+ __asm ("" : : "r" (r2));
+#endif
+ main();
+ return 0;
+}
+
+#endif
--- /dev/null
+#
+# spec file for package glibc
+#
+# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
+#
+# All modifications and additions to the file contributed by third parties
+# remain the property of their copyright owners, unless otherwise agreed
+# upon. The license for this file, and modifications and additions to the
+# file, is the same license as for the pristine package itself (unless the
+# license for the pristine package is not an Open Source License, in which
+# case the license is the MIT License). An "Open Source License" is a
+# license that conforms to the Open Source Definition (Version 1.9)
+# published by the Open Source Initiative.
+
+# This will avoid building some parts of glibc
+%bcond_with fast_build
+
+Name: glibc
+Summary: Standard Shared Libraries (from the GNU C Library)
+License: LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
+Group: Base/Libraries
+BuildRequires: fdupes
+BuildRequires: makeinfo
+BuildRequires: xz
+BuildRequires: gcc-c++
+BuildRequires: gettext-tools
+BuildRequires: libstdc++-devel
+#BuildRequires: pkgconfig(systemd)
+
+%define _filter_GLIBC_PRIVATE 1
+%if %_target_cpu == "i686"
+# For i686 let's only build what's different from i586, so
+# no need to build documentation
+%define build_profile 1
+%define build_locales 0
+%define build_html 0
+%else
+%if %{with fast_build}
+%define build_profile 0
+%define build_locales 0
+%define build_html 0
+%else
+# Default:
+%define build_profile 1
+%define build_locales 0
+%define build_html 1
+%endif
+%endif
+
+%define disable_assert 0
+%define enable_stackguard_randomization 1
+
+
+%ifarch x86_64
+%define enablekernel 2.6.16
+%else
+%define enablekernel 2.6.16
+%endif
+Conflicts: kernel < %{enablekernel}
+%ifarch armv7l armv7hl
+# The old runtime linker link gets not provided by rpm find.provides, but it exists
+Provides: ld-linux.so.3
+Provides: ld-linux.so.3(GLIBC_2.4)
+%endif
+Version: 2.24
+Release: 0
+%define glibc_major_version 2.24
+%define git_id 4e42b5b8f89f
+
+Url: http://www.gnu.org/software/libc/libc.html
+Source: glibc-%{version}.tar.xz
+Source5: nsswitch.conf
+Source7: bindresvport.blacklist
+Source8: glibc_post_upgrade.c
+Source9: glibc.rpmlintrc
+Source10: baselibs.conf
+# For systemd
+Source1001: glibc.manifest
+
+Requires(pre): filesystem
+Provides: rtld(GNU_HASH)
+
+%description
+The GNU C Library provides the most important standard libraries used
+by nearly all programs: the standard C library, the standard math
+library, and the POSIX thread library. A system is not functional
+without these libraries.
+
+%package info
+Summary: Info Files for the GNU C Library
+License: GFDL-1.1
+Group: Documentation
+BuildArch: noarch
+
+%description info
+This package contains the documentation for the GNU C library stored as
+info files. Due to a lack of resources, this documentation is not
+complete and is partially out of date.
+
+%package html
+Summary: HTML Documentation for the GNU C Library
+License: GFDL-1.1
+Group: Documentation
+BuildArch: noarch
+
+%description html
+This package contains the HTML documentation for the GNU C library. Due
+to a lack of resources, this documentation is not complete and is
+partially out of date.
+
+%package i18ndata
+Summary: Database Sources for 'locale'
+License: GPL-2.0+ and MIT
+Group: Base/Libraries
+BuildArch: noarch
+
+%description i18ndata
+This package contains the data needed to build the locale data files to
+use the internationalization features of the GNU libc. It is normally
+not necessary to install this packages, the data files are already
+created.
+
+%package locale
+Summary: Locale Data for Localized Programs
+License: GPL-2.0+ and MIT and LGPL-2.1+
+Requires(post): /usr/bin/cat
+Requires: glibc = %{version}
+
+%description locale
+Locale data for the internationalisation features of the GNU C library.
+
+%package profile
+Summary: Libc Profiling and Debugging Versions
+License: LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
+Group: Base/Utilities
+Requires: glibc = %{version}
+
+%description profile
+This package contains special versions of the GNU C library which are
+necessary for profiling and debugging.
+
+%package devel
+Summary: Include Files and Libraries Mandatory for Development
+License: BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
+Requires: glibc = %{version}
+Requires: linux-kernel-headers
+
+%description devel
+These libraries are needed to develop programs which use the standard C
+library.
+
+%package devel-static
+Summary: C library static libraries for -static linking
+License: BSD-3-Clause and LGPL-2.1+ and LGPL-2.1+-with-GCC-exception and GPL-2.0+
+Requires: %{name}-devel = %{version}
+# Provide Fedora name for package to make packaging easier
+Provides: %{name}-static = %version
+
+%description devel-static
+The glibc-devel-static package contains the C library static libraries
+for -static linking. You don't need these, unless you link statically,
+which is highly discouraged.
+
+%package devel-utils
+Summary: Development utilities from GNU C library
+License: LGPL-2.1+
+Requires: glibc = %{version}
+
+%description devel-utils
+The glibc-devel-utils package contains various binaries which can be helpful during program
+debugging.
+
+If you are unsure if you need this, don't install this package.
+
+%package extra
+Summary: Extra binaries from GNU C Library
+License: LGPL-2.1+
+Requires: glibc = %{version}
+
+%description extra
+The glibc-extra package contains some extra binaries for glibc that
+are not essential but recommend to use.
+
+makedb: A program to create a database for nss
+
+%package obsolete
+Summary: Obsolete Shared Libraries from the GNU C Library
+License: LGPL-2.0+
+Requires: glibc = %{version}
+
+%description obsolete
+This package provides some old libraries from the GNU C Library which
+are no longer supported. Additional it provides a compatibility library
+for old binaries linked against glibc 2.0.
+
+Install this package if you need one of this libraries to get old
+binaries working, but since this libraries are not supported and there
+is no gurantee that they work for you, you should try to get newer
+versions of your software.
+
+%prep
+%setup -n glibc-%{version} -q
+cp %{SOURCE1001} .
+
+%build
+if [ -x /bin/uname.bin ]; then
+ /bin/uname.bin -a
+else
+ uname -a
+fi
+uptime || :
+ulimit -a
+nice
+# We do not want configure to figure out the system its building one
+# to support a common ground and thus set build and host to the
+# target_cpu.
+%ifarch %arm
+%define target %{_target_cpu}-tizen-linux-gnueabi
+%else
+%define target %{_target_cpu}-tizen-linux
+%endif
+# Don't use as-needed, it breaks glibc assumptions
+# Before enabling it, run the testsuite and verify that it
+# passes completely
+export LD_AS_NEEDED=0
+# Adjust glibc version.h
+echo "#define CONFHOST \"%{target}\"" >> version.h
+echo "#define GITID \"%{git_id}\"" >> version.h
+#
+# Default CFLAGS and Compiler
+#
+BuildFlags=$(echo %{optflags} | sed -e "s/-Wp,-D_FORTIFY_SOURCE=2//g" | sed -e "s/-ffast-math//" | sed -e "s/atom/i686/g" | sed -e "s/-fexceptions//" )
+BuildFlags="$BuildFlags -O2 -g -U_FORTIFY_SOURCE"
+BuildFlags="$(echo $BuildFlags | sed -e 's#-fstack-protector##' -e 's#-ffortify=[0-9]*##')"
+BuildFlags="$(echo $BuildFlags | sed -e 's/-Wa,-mimplicit-it=thumb//g' | sed -e 's/-mthumb//g')"
+BuildCC="%__cc"
+BuildCCplus="%__cxx"
+add_ons=",libidn"
+
+
+BuildFlags="$BuildFlags -g"
+%if %{disable_assert}
+ BuildFlags="$BuildFlags -DNDEBUG=1"
+%endif
+%ifarch %ix86
+ add_ons=$add_ons
+%endif
+%ifarch %arm aarch64
+ add_ons=$add_ons
+%endif
+%ifarch mipsel
+ # fails to build otherwise - need to recheck and fix
+ %define enable_stackguard_randomization 0
+%endif
+
+configure_and_build_glibc() {
+ local dirname="$1"; shift
+ local cflags="$1"; shift
+ local addons="$1"; shift
+ mkdir "cc-$dirname"
+ cd "cc-$dirname"
+ conf_cflags="$cflags -funwind-tables"
+
+ profile="--disable-profile"
+%if %{build_profile}
+ if [ "$dirname" = "base" ] ; then
+ profile="--enable-profile"
+ fi
+%endif
+ CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
+ CC="$BuildCC" CXX="$BuildCCplus" ../configure \
+ --prefix=%{_prefix} \
+ --libexecdir=%{_libexecdir} --infodir=%{_infodir} \
+ --enable-add-ons=$addons \
+ $profile \
+ "$@" \
+%if %{enable_stackguard_randomization}
+ --enable-stackguard-randomization \
+%endif
+ --build=%{target} --host=%{target} \
+%ifarch %{ix86} x86_64
+ --enable-multi-arch \
+%endif
+ --enable-kernel=%{enablekernel} \
+ --enable-bind-now --enable-obsolete-rpc \
+ --disable-nscd
+ # explicitly set CFLAGS to use the full CFLAGS (not the reduced one for configure)
+ make %{?_smp_mflags} #CFLAGS="$cflags" BUILD_CFLAGS="$cflags"
+ cd ..
+}
+
+ #
+ # Build base glibc
+ #
+ configure_and_build_glibc base "$BuildFlags" "$add_ons"
+
+#
+# Build html documentation
+#
+%if %{build_html}
+make -C cc-base html
+%endif
+
+#
+# Build glibc_post_upgrade binary
+#
+$BuildCC -static %{optflags} -Os $RPM_SOURCE_DIR/glibc_post_upgrade.c -o glibc_post_upgrade \
+ -Lcc-base -Bcc-base/csu \
+ '-DREMOVE_TLS_DIRS' '-DREMOVE_PPC_OPTIMIZE_POWER5' \
+ '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'
+
+
+#######################################################################
+###
+### CHECK
+###
+#######################################################################
+
+%check
+# The testsuite will fail if asneeded is used
+export LD_AS_NEEDED=0
+# This has to pass on all platforms!
+# Exceptions:
+# None!
+make %{?_smp_mflags} -C cc-base check-abi
+
+#######################################################################
+###
+### INSTALL
+###
+#######################################################################
+
+%install
+# We don't want to strip the .symtab from our libraries in find-debuginfo.sh,
+# certainly not from libpthread.so.* because it is used by libthread_db to find
+# some non-exported symbols in order to detect if threading support
+# should be enabled. These symbols are _not_ exported, and we can't easily
+# export them retroactively without changing the ABI. So we have to
+# continue to "export" them via .symtab, instead of .dynsym :-(
+# But we also want to keep .symtab and .strtab of other libraries since some
+# debugging tools currently require these sections directly inside the main
+# files - specifically valgrind and PurifyPlus.
+export STRIP_KEEP_SYMTAB=*.so*
+
+# Make sure we will create the gconv-modules.cache
+mkdir -p %{buildroot}%{_libdir}/gconv
+touch %{buildroot}%{_libdir}/gconv/gconv-modules.cache
+
+# Install base glibc
+make %{?_smp_mflags} install_root=%{buildroot} install -C cc-base
+
+install_optimized_variant() {
+ local dirname="$1"; shift
+ local subdir="$1"; shift
+ local subdir_up="$1"; shift
+
+cd "cc-$dirname"
+destdir=$RPM_BUILD_ROOT/%{_lib}/$subdir
+mkdir -p $destdir
+# Don't run a complete make install, we know which libraries
+# we want
+for lib in libc math/libm nptl/libpthread rt/librt nptl_db/libthread_db
+do
+ libbase=${lib#*/}
+ libbaseso=$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}-*.so)
+ # Only install if different from base lib
+ if cmp -s ${lib}.so ../cc-base/${lib}.so; then
+ ln -sf $subdir_up/$libbaseso $destdir/$libbaseso
+ else
+ cp -a ${lib}.so $destdir/$libbaseso
+ fi
+ # Emulate ldconfig
+ ln -sf $libbaseso $destdir/$(basename $RPM_BUILD_ROOT/%{_lib}/${libbase}.so.*)
+done
+cd ..
+}
+
+
+# Install locales
+%if %{build_locales}
+ # XXX Do not install locales in parallel!
+ cd cc-base
+ # localedef creates hardlinks to other locales if possible
+ # this will not work if we generate them in parallel.
+ # thus we need to run fdupes on /usr/lib/locale/
+ # Still, on my system this is a speed advantage:
+ # non-parallel build for install-locales: 9:34mins
+ # parallel build with fdupes: 7:08mins
+ make %{?_smp_mflags} install_root=%{buildroot} localedata/install-locales
+ %fdupes %{buildroot}/usr/lib/locale
+ cd ..
+%endif
+# Create file list for glibc-locale package
+%{find_lang} libc
+
+# Prepare obsolete/, used only on some architectures:
+export RPM_BUILD_ROOT
+%ifarch %ix86
+mkdir -p %{buildroot}/%{_lib}/obsolete
+%endif
+
+# NPTL <bits/stdio-lock.h> is not usable outside of glibc, so include
+# the generic one (RH#162634)
+cp -av bits/stdio-lock.h %{buildroot}%{_includedir}/bits/stdio-lock.h
+
+
+# Miscelanna:
+
+install -m 0700 glibc_post_upgrade %{buildroot}%{_sbindir}
+
+install -m 644 %{SOURCE7} %{buildroot}/etc
+install -m 644 %{SOURCE5} %{buildroot}/etc
+install -m 644 posix/gai.conf %{buildroot}/etc
+
+mkdir -p %{buildroot}/etc/default
+install -m 644 nis/nss %{buildroot}/etc/default/
+
+mkdir -p %{buildroot}%{_includedir}/resolv
+install -m 0644 resolv/mapv4v6addr.h %{buildroot}%{_includedir}/resolv/
+install -m 0644 resolv/mapv4v6hostent.h %{buildroot}%{_includedir}/resolv/
+
+%if %{build_html}
+mkdir -p %{buildroot}%{_datadir}/doc/glibc
+cp -p cc-base/manual/libc/*.html %{buildroot}%{_datadir}/doc/glibc
+%endif
+
+
+#
+# Create ld.so.conf
+#
+cat > %{buildroot}/etc/ld.so.conf <<EOF
+%if "%{_lib}" == "lib64"
+/usr/local/lib64
+%endif
+/usr/local/lib
+include /etc/ld.so.conf.d/*.conf
+# /lib64, /lib, /usr/lib64 and /usr/lib gets added
+# automatically by ldconfig after parsing this file.
+# So, they do not need to be listed.
+EOF
+# Add ldconfig cache directory for directory ownership
+mkdir -p %{buildroot}/var/cache/ldconfig
+# Empty the ld.so.cache:
+rm -f %{buildroot}/etc/ld.so.cache
+touch %{buildroot}/etc/ld.so.cache
+
+# Don't look at ldd! We don't wish a /bin/sh requires
+chmod 644 %{buildroot}%{_bindir}/ldd
+
+# Remove timezone data, now coming in standalone package:
+for i in sbin/sln usr/bin/tzselect usr/sbin/zic usr/sbin/zdump etc/localtime; do
+ rm -f %{buildroot}/$i
+done
+rm -rf %{buildroot}%{_datadir}/zoneinfo
+
+%ifarch armv7hl
+# Provide compatibility link
+ln -s ld-%{glibc_major_version}.so %{buildroot}/lib/ld-linux.so.3
+%endif
+
+# Move getconf to %{_libexecdir}/getconf/ to avoid cross device link
+mv %{buildroot}%{_bindir}/getconf %{buildroot}%{_libexecdir}/getconf/getconf
+ln -s %{_libexecdir}/getconf/getconf %{buildroot}%{_bindir}/getconf
+
+#######################################################################
+###
+### ...
+###
+#######################################################################
+
+%post -p %{_sbindir}/glibc_post_upgrade
+
+%postun -p /sbin/ldconfig
+
+%post locale
+for l in /usr/share/locale/locale.alias %{_libdir}/gconv/gconv-modules; do
+ [ -d "$l.d" ] || continue
+ echo "###X# The following is autogenerated from extra files in the .d directory:" >>"$l"
+ cat "$l.d"/* >>"$l"
+done
+/usr/sbin/iconvconfig
+
+%post info
+%install_info --info-dir=%{_infodir} %{_infodir}/libc.info.gz
+
+%postun info
+%install_info_delete --info-dir=%{_infodir} %{_infodir}/libc.info.gz
+
+%files
+%manifest %{name}.manifest
+# glibc
+%defattr(-,root,root)
+%license LICENSES
+%config(noreplace) /etc/bindresvport.blacklist
+%config /etc/ld.so.conf
+%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/ld.so.cache
+%config(noreplace) /etc/rpc
+%verify(not md5 size mtime) %config(noreplace) /etc/nsswitch.conf
+%verify(not md5 size mtime) %config(noreplace) /etc/gai.conf
+%config(noreplace) /etc/default/nss
+/%{_lib}/ld-%{glibc_major_version}.so
+
+# Each architecture has a different name for the dynamic linker:
+%ifarch %arm
+%ifarch armv7hl
+/%{_lib}/ld-linux-armhf.so.3
+# Keep compatibility link
+/%{_lib}/ld-linux.so.3
+%else
+/%{_lib}/ld-linux.so.3
+%endif
+%endif
+%ifarch x86_64
+/%{_lib}/ld-linux-x86-64.so.2
+%endif
+%ifarch %ix86 %sparc
+/%{_lib}/ld-linux.so.2
+%endif
+%ifarch aarch64
+/lib/ld-linux-aarch64.so.1
+/%{_lib}/ld-linux-aarch64.so.1
+%endif
+
+/%{_lib}/libanl-%{glibc_major_version}.so
+/%{_lib}/libanl.so.1
+/%{_lib}/libc-%{glibc_major_version}.so
+/%{_lib}/libc.so.6*
+/%{_lib}/libcidn-%{glibc_major_version}.so
+/%{_lib}/libcidn.so.1
+/%{_lib}/libcrypt-%{glibc_major_version}.so
+/%{_lib}/libcrypt.so.1
+/%{_lib}/libdl-%{glibc_major_version}.so
+/%{_lib}/libdl.so.2*
+/%{_lib}/libm-%{glibc_major_version}.so
+/%{_lib}/libm.so.6*
+/%{_lib}/libnsl-%{glibc_major_version}.so
+/%{_lib}/libnsl.so.1
+/%{_lib}/libnss_compat-%{glibc_major_version}.so
+/%{_lib}/libnss_compat.so.2
+/%{_lib}/libnss_db-%{glibc_major_version}.so
+/%{_lib}/libnss_db.so.2
+/%{_lib}/libnss_dns-%{glibc_major_version}.so
+/%{_lib}/libnss_dns.so.2
+/%{_lib}/libnss_files-%{glibc_major_version}.so
+/%{_lib}/libnss_files.so.2
+/%{_lib}/libnss_hesiod-%{glibc_major_version}.so
+/%{_lib}/libnss_hesiod.so.2
+/%{_lib}/libnss_nis-%{glibc_major_version}.so
+/%{_lib}/libnss_nis.so.2
+/%{_lib}/libnss_nisplus-%{glibc_major_version}.so
+/%{_lib}/libnss_nisplus.so.2
+/%{_lib}/libpthread-%{glibc_major_version}.so
+/%{_lib}/libpthread.so.0
+/%{_lib}/libthread_db-1.0.so
+/%{_lib}/libthread_db.so.1
+/%{_lib}/libresolv-%{glibc_major_version}.so
+/%{_lib}/libresolv.so.2
+/%{_lib}/librt-%{glibc_major_version}.so
+/%{_lib}/librt.so.1
+/%{_lib}/libutil-%{glibc_major_version}.so
+/%{_lib}/libutil.so.1
+%define optimized_libs() \
+ %dir %attr(0755,root,root) /%{_lib}/%1\
+ /%{_lib}/%1/libc-%{glibc_major_version}.so\
+ /%{_lib}/%1/libc.so.6*\
+ /%{_lib}/%1/libm-%{glibc_major_version}.so\
+ /%{_lib}/%1/libm.so.6*\
+ /%{_lib}/%1/libpthread-%{glibc_major_version}.so\
+ /%{_lib}/%1/libpthread.so.0\
+ /%{_lib}/%1/librt-%{glibc_major_version}.so\
+ /%{_lib}/%1/librt.so.1\
+ /%{_lib}/%1/libthread_db-1.0.so\
+ /%{_lib}/%1/libthread_db.so.1
+
+%dir %attr(0700,root,root) /var/cache/ldconfig
+/sbin/ldconfig
+%{_bindir}/gencat
+%{_bindir}/getconf
+%{_bindir}/getent
+%{_bindir}/iconv
+%attr(755,root,root) %{_bindir}/ldd
+%ifarch %ix86 sparc sparcv9
+ %{_bindir}/lddlibc4
+%endif
+%{_bindir}/locale
+%{_bindir}/localedef
+%dir %attr(0755,root,root) %{_libexecdir}/getconf
+%{_libexecdir}/getconf/*
+%{_sbindir}/glibc_post_upgrade
+%{_sbindir}/iconvconfig
+/%{_lib}/libBrokenLocale-%{glibc_major_version}.so
+/%{_lib}/libBrokenLocale.so.1
+
+%ifarch %ix86
+
+%files obsolete
+%manifest %{name}.manifest
+%defattr (755,root,root,755)
+%dir /%{_lib}/obsolete/
+ #%dir /%{_lib}/obsolete/noversion
+ #/%{_lib}/obsolete/noversion/libNoVersion-%{glibc_major_version}.so
+ #/%{_lib}/obsolete/noversion/libNoVersion.so.1
+%endif
+
+%files locale -f libc.lang
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_datadir}/locale/locale.alias
+%if %{build_locales}
+/usr/lib/locale/*
+%endif
+%{_libdir}/gconv
+
+%files devel
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%license COPYING COPYING.LIB
+%doc NEWS README BUGS CONFORMANCE
+%{_bindir}/rpcgen
+%{_includedir}/*
+%{_libdir}/*.o
+%{_libdir}/*.so
+# These static libraries are needed even for shared builds
+%{_libdir}/libc_nonshared.a
+%{_libdir}/libg.a
+%{_libdir}/libieee.a
+%ifarch ppc ppc64 s390 s390x sparc sparcv8 sparcv9 sparcv9v
+# This is not built on sparc64.
+ %{_libdir}/libnldbl_nonshared.a
+%endif
+%{_libdir}/libmcheck.a
+%{_libdir}/libpthread_nonshared.a
+%{_libdir}/librpcsvc.a
+
+%files devel-static
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_libdir}/libBrokenLocale.a
+%{_libdir}/libanl.a
+%{_libdir}/libc.a
+%{_libdir}/libcrypt.a
+%{_libdir}/libdl.a
+%{_libdir}/libm.a
+%{_libdir}/libnsl.a
+%{_libdir}/libpthread.a
+%{_libdir}/libresolv.a
+%{_libdir}/librt.a
+%{_libdir}/libutil.a
+
+%files info
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%doc %{_infodir}/libc.info.gz
+%doc %{_infodir}/libc.info-?.gz
+%doc %{_infodir}/libc.info-??.gz
+
+%if %{build_html}
+%files html
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%doc %{_prefix}/share/doc/glibc
+%endif
+
+%files i18ndata
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_prefix}/share/i18n
+
+%if %{build_profile}
+%files profile
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_libdir}/libc_p.a
+%{_libdir}/libBrokenLocale_p.a
+%{_libdir}/libanl_p.a
+%{_libdir}/libm_p.a
+%{_libdir}/libcrypt_p.a
+%{_libdir}/libpthread_p.a
+%{_libdir}/libresolv_p.a
+%{_libdir}/libnsl_p.a
+%{_libdir}/librt_p.a
+%{_libdir}/librpcsvc_p.a
+%{_libdir}/libutil_p.a
+%{_libdir}/libdl_p.a
+%endif
+
+%files devel-utils
+%manifest %{name}.manifest
+%defattr(-,root,root)
+/%{_lib}/libmemusage.so
+/%{_lib}/libpcprofile.so
+/%{_libdir}/libBrokenLocale.so
+/%{_lib}/libSegFault.so
+/%{_lib}/libthread_db-1.0.so
+/%{_lib}/libthread_db.so.1
+/%{_libdir}/libthread_db.so
+%dir /%{_libdir}/audit
+/%{_libdir}/audit/sotruss-lib.so
+# These need gd-devel for building
+# %%{_bindir}/memusage
+# %%{_bindir}/memusagestat
+%{_bindir}/mtrace
+%{_bindir}/pcprofiledump
+%{_bindir}/sotruss
+%{_bindir}/xtrace
+%{_bindir}/pldd
+%{_bindir}/catchsegv
+%{_bindir}/sprof
+
+%files extra
+%manifest %{name}.manifest
+%defattr(-,root,root)
+%{_bindir}/makedb
+/var/db/Makefile
+
+
+%docs_package