File glibc.spec of Package glibc.18276

# spec file for package glibc
# Copyright (c) 2018 SUSE LINUX 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.

# Please submit bugfixes or comments via

# Run with osc --with=fast_build to have a shorter turnaround
# It will avoid building some parts of glibc
%bcond_with    fast_build

%define crypt_bf_version 1.3
%define build_snapshot 0
%bcond_with ringdisabled

%define flavor @BUILD_FLAVOR@%{nil}

%bcond_with build_all
%define build_main 1
%define build_utils %{with build_all}
%define build_testsuite %{with build_all}
%if "%flavor" == "utils"
%if %{with ringdisabled}
ExclusiveArch:  do_not_build
%define build_main 0
%define build_utils 1
%define build_testsuite 0
%if "%flavor" == "testsuite"
%if %{with ringdisabled}
ExclusiveArch:  do_not_build
%define build_main 0
%define build_utils 0
%define build_testsuite 1

%if %{build_main}
%define name_suffix %{nil}
%define name_suffix -%{flavor}-src

Name:           glibc%{name_suffix}
Summary:        Standard Shared Libraries (from the GNU C Library)
License:        LGPL-2.1+ AND SUSE-LGPL-2.1+-with-GCC-exception AND GPL-2.0+
Group:          System/Libraries
BuildRequires:  audit-devel
BuildRequires:  fdupes
BuildRequires:  libcap-devel
BuildRequires:  libselinux-devel
BuildRequires:  makeinfo
BuildRequires:  pwdutils
BuildRequires:  systemd-rpm-macros
BuildRequires:  systemtap-headers
BuildRequires:  xz
%if %{build_testsuite}
BuildRequires:  gcc-c++
BuildRequires:  gdb
BuildRequires:  glibc-devel-static
BuildRequires:  libstdc++-devel
BuildRequires:  python-pexpect
%if %{build_utils}
BuildRequires:  gd-devel
%if "%flavor" == "i686"
ExclusiveArch:  i586 i686
BuildArch:      i686
%global optflags %(echo "%optflags"|sed -e s/i586/i686/) -march=i686 -mtune=generic

%define __filter_GLIBC_PRIVATE 1
%ifarch 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 1
%define build_html 0
%if %{with fast_build} || %{build_utils} && %{without build_all}
%define build_profile 0
%define build_locales 0
%define build_html 0
# Default:
%define build_profile 1
%define build_locales 1
%define build_html 1

%define build_variants %{build_main}

%define disable_assert 0
%define enable_stackguard_randomization 1
%ifarch ppc ppc64
 %define optimize_power 1
 %ifarch ppc
 %define powerpc_optimize_base %{nil}
 %define powerpc_optimize_tune power3
 %define powerpc_optimize_cpu_power4 1
 %define powerpc_optimize_base %{nil}
 %define powerpc_optimize_tune power5
 %define powerpc_optimize_cpu_power4 0
 # We are not building Power CPU specific optimizations for openSUSE.
 %define powerpc_optimize_cpu_power6 0
 %define powerpc_optimize_cpu_power7 0
 %define powerpc_optimize_cpu_cell 0
 %define optimize_power 0
 %define powerpc_optimize_base %{nil}
 %define powerpc_optimize_cpu_power4 0
 %define powerpc_optimize_cpu_power6 0
 %define powerpc_optimize_cpu_power7 0
 %define powerpc_optimize_cpu_cell 0
%endif # ppc, ppc64
# glibc requires at least kernel 3.2
%define enablekernel 3.2
# some architectures need a newer kernel
%ifarch ppc64le
%define enablekernel 3.10
%ifarch aarch64
%define enablekernel 3.7
%ifarch ia64
%define enablekernel 3.2.18

Version:        2.26
Release:        0
%if !%{build_snapshot}
%define git_id 1c9a5c270d8b
%define libversion %version
%define git_id %(echo %version | sed 's/.*\.g//')
%define libversion %(echo %version | sed 's/\.[^.]*\.g.*//')
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%if !%{build_snapshot}
Source:         glibc-%{version}.tar.xz
Source4:        manpages.tar.bz2
Source5:        nsswitch.conf
Source7:        bindresvport.blacklist
Source8:        glibc_post_upgrade.c
Source9:        glibc.rpmlintrc
Source10:       baselibs.conf
# For systemd 
Source20:       nscd.conf
Source21:       nscd.service
# crypt_blowfish
# The sign key uses MD5 which is no longer accepted by gpg

%if %{build_main}
# ngpt was used in 8.1 and SLES8
Obsoletes:      ngpt < 2.2.2
Obsoletes:      ngpt-devel < 2.2.2
Provides:       ngpt = 2.2.2
Provides:       ngpt-devel = 2.2.2
Conflicts:      kernel < %{enablekernel}
# bug437293 - handle update from SLES10 on PowerPC
%ifarch ppc64
Obsoletes:      glibc-64bit
%ifarch ppc
Obsoletes:      glibc-32bit
%ifarch armv6hl armv7hl
# The old runtime linker link gets not provided by rpm find.provides, but it exists
Requires(pre):  filesystem
Recommends:     glibc-extra
Provides:       rtld(GNU_HASH)
%if %{build_utils}
Requires:       glibc = %{version}
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%ifarch i686
# We need to avoid to have only the src rpm from i686 on the media,
# since it does not work on other architectures.
NoSource:       0
%if !%{build_main}
NoSource:       0

# Patches are ordered in the following groups:
# Patches that we will never upstream or which have not been looked at: 0-999
# Patches taken from upstream: 1000-2000
# Patches that are going upstream, waiting approval: 2000-3000

# Patches that upstream will not accept

# openSUSE specific patches - won't go upstream
### openSUSE extensions, configuration
# PATCH-FEATURE-OPENSUSE -- add crypt_blowfish support - bnc#700876
Patch1:         glibc-2.14-crypt.diff
# PATCH-FEATURE-OPENSUSE constify crypt_blowfish
Patch2:         crypt_blowfish-const.patch
# PATCH-FEATURE-OPENSUSE -- add sha support to crypt_blowfish
Patch3:         crypt_blowfish-1.2-sha.diff
# PATCH-FEATURE-OPENSUSE Move crypt_gensalt_rn to separate library
Patch4:         crypt_blowfish-gensalt.patch
# PATCH-FEATURE-OPENSUSE Avoid build failure on noexecstack marker on ARM
Patch5:         crypt_blowfish-1.2-hack_around_arm.diff
# PATCH-FIX-OPENSUSE Fix path for nscd databases
Patch6:         glibc-2.3.3-nscd-db-path.diff
# PATCH-FIX-OPENSUSE Fix path for nss_db (bnc#753657) -
Patch7:         nss-db-path.patch
# PATCH-FIX-OPENSUSE adjust nscd.conf
Patch8:         glibc-nscd.conf.patch
# PATCH-FIX-OPENSUSE do not use compile time in binaries
Patch9:         glibc-nodate.patch
# PATCH-FIX-OPENSUSE -- add some extra information to version output -
Patch10:        glibc-version.diff
# PATCH-FIX-OPENSUSE -- Make --no-archive default for localedef -
Patch13:        glibc-2.3.2.no_archive.diff
# PATCH-FIX-OPENSUSE -- add blacklist for bindresvport
Patch14:        glibc-bindresvport-blacklist.diff
# PATCH-FIX-OPENSUSE prefer -lang rpm packages
Patch15:        glibc-2.3.90-langpackdir.diff
# PATCH-FEATURE-SLE Use nscd user for nscd
Patch19:        nscd-server-user.patch
# PATCH-FEATURE-SLE powerpc: enable TLE only if GLIBC_ELISION_ENABLE=yes is defined
Patch21:        powerpc-elision-enable-envvar.patch
# PATCH-FEATURE-SLE s390: enable TLE only if GLIBC_ELISION_ENABLE=yes is defined
Patch22:        s390-elision-enable-envvar.patch
# PATCH-FIX-SLE Don't compress debug sections in crt*.o files
Patch23:        crt-nocompress-debug-sections.patch

### Locale related patches
# PATCH-FIX-OPENSUSE Add additional locales
Patch100:       add-locales.patch
# PATCH-FIX-OPENSUSE -- Add no_NO back (XXX: Still needed?)
Patch102:       glibc-2.4.90-no_NO.diff
# PATCH-FIX-OPENSUSE -- Renames for China
Patch103:       glibc-2.4-china.diff
# PATCH-FIX-OPENSUSE -- Add C.UTF-8 locale
Patch104:       glibc-c-utf8-locale.patch
# PATCH-FIX-OPENSUSE -- Disable gettext for C.UTF-8 locale
Patch105:       glibc-disable-gettext-for-c-utf8.patch

### Broken patches in glibc that we revert for now:

### Network related patches
# PATCH-FIX-OPENSUSE Warn about usage of mdns in resolv.conv
Patch304:       glibc-resolv-mdnshint.diff
# PATCH-FIX-OPENSUSE disable rewriting ::1 to for /etc/hosts bnc#684534, bnc#706719
Patch306:       glibc-fix-double-loopback.diff

# Patches from upstream
# PATCH-FIX-UPSTREAM Fix leaks of resolver contexts (BZ #21885, BZ #21932)
Patch1000:      resolv-context-leak.patch
# PATCH-FIX-UPSTREAM Use _dl_runtime_resolve_opt only with AVX512F (BZ #21871)
Patch1001:      dl-runtime-resolve-opt-avx512f.patch
# PATCH-FIX-UPSTREAM Don't use IFUNC resolver for longjmp or system in libpthread (BZ #21041)
Patch1002:      libpthread-compat-wrappers.patch
# PATCH-FIX-UPSTREAM Do not use __builtin_types_compatible_p in C++ mode (BZ #21930, BZ #22146, BZ #22235, BZ #22296)
Patch1003:      math-c++-compat.patch
# PATCH-FIX-UPSTREAM Remove nis and compat from default NSS configs
Patch1004:      remove-nss-nis-compat.patch
# PATCH-FIX-UPSTREAM Properly terminate .eh_frame (BZ #22051)
Patch1005:      eh-frame-zero-terminator.patch
# PATCH-FIX-UPSTREAM x86: Add x86_64 to x86-64 HWCAP (BZ #22093)
Patch1006:      ld-so-hwcap-x86-64.patch
# PATCH-FIX-UPSTREAM assert: Suppress pedantic warning caused by statement expression (BZ #21242, BZ #21972)
Patch1007:      assert-pedantic.patch
# PATCH-FIX-UPSTREAM Fix errno and h_errno handling in getaddrinfo (BZ #21915, BZ #21922)
Patch1008:      getaddrinfo-errno.patch
# PATCH-FIX-UPSTREAM Fix memory handling in OOM situation during resolv.conf parsing (BZ #22095, BZ #22096)
Patch1009:      resolv-conf-oom.patch
# PATCH-FIX-UPSTREAM Fix initial size of dynarray allocation and set errno on overflow error
Patch1010:      dynarray-allocation.patch
# PATCH-FIX-UPSTREAM Avoid spurious inexact in nearbyint (BZ #22225)
Patch1011:      nearbyint-inexact.patch
# PATCH-FIX-UPSTREAM Move nss_compat from nis to nss subdir and install it unconditionally
Patch1012:      nss-compat.patch
# PATCH-FIX-UPSTREAM Remove reference to libnsl from nscd
Patch1013:      nscd-libnsl.patch
# PATCH-FIX-UPSTREAM malloc: Fix tcache leak after thread destruction (BZ #22111)
Patch1014:      malloc-tcache-leak.patch
# PATCH-FIX-UPSTREAM aarch64: Optimized implementation of memcpy/memmove for Qualcomm Falkor
Patch1015:      falkor-memcpy-memmove.patch
# PATCH-FIX-UPSTREAM aarch64: Fix glibc.tune.cpu tunable handling
Patch1016:      aarch64-cpu-features.patch
# PATCH-FIX-UPSTREAM nss_files: Avoid large buffers with many host addresses (BZ #22078)
Patch1017:      nss-files-large-buffers.patch
# PATCH-FIX-UPSTREAM sysconf: Fix missing definition of UIO_MAXIOV on Linux (BZ #22321)
Patch1018:      sysconf-uio-maxiov.patch
# PATCH-FIX-UPSTREAM glob: Fix buffer overflows (CVE-2017-15670, CVE-2017-15671, CVE-2017-15804, BZ #22320, BZ #22325, BZ #22332)
Patch1019:      glob-tilde-overflow.patch
# PATCH-FIX-UPSTREAM x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve (BZ #21265)
Patch1020:      dl-runtime-resolve-xsave.patch
# PATCH-FIX-UPSTREAM posix: Fix improper assert in Linux posix_spawn (BZ #22273)
Patch1021:      spawni-assert.patch
# PATCH-FIX-UPSTREAM x86-64: Don't set GLRO(dl_platform) to NULL (BZ #22299)
Patch1022:      x86-64-dl-platform.patch
# PATCH-FIX-UPSTREAM no compat glob64 on s390
Patch1023:      glob64-s390.patch
# PATCH-FIX-UPSTREAM tst-tlsopt-powerpc as a shared lib
Patch1024:      tst-tlsopt-powerpc.patch
# PATCH-FIX-UPSTREAM Update HWCAP for powerpc
Patch1025:      powerpc-hwcap-bits.patch
# PATCH-FIX-UPSTREAM Fix integer overflow in malloc when tcache is enabled (CVE-2017-17426, BZ #22375)
Patch1026:      malloc-tcache-check-overflow.patch
# PATCH-FIX-UPSTREAM Count components of the expanded path in _dl_init_path (CVE-2017-1000408, CVE-2017-1000409, bsc#1071319, BZ #22607, BZ #22627)
Patch1027:      dl-init-paths-overflow.patch
# PATCH-FIX-UPSTREAM Check for empty tokens before dynamic string token expansion (CVE-2017-16997, bsc#1073231, BZ #22625)
Patch1028:      fillin-rpath-empty-tokens.patch
# PATCH-FIX-UPSTREAM make getcwd(3) fail if it cannot obtain an absolute path (CVE-2018-1000001, BZ #22679)
Patch1029:      getcwd-absolute.patch
# PATCH-FIX-UPSTREAM Fix integer overflows in internal memalign and malloc functions (CVE-2018-6485, CVE-2018-6551, BZ #22343, BZ #22774)
Patch1030:      memalign-overflow.patch
# PATCH-FIX-UPSTREAM Fix stack guard size accounting (BZ #22637)
Patch1031:      stack-guard-size-accounting.patch
# PATCH-FIX-UPSTREAM nptl: Open with RTLD_NOW during pthread_cancel (BZ #22636)
Patch1032:      libgcc-rtld-now.patch
# PATCH-FIX-UPSTREAM Fix crash in resolver on memory allocation failure (BZ #23005)
Patch1033:      res-send-enomem.patch
# PATCH-FIX-UPSTREAM __mempcpy_avx512_no_vzeroupper mishandles large copies (CVE-2018-11237, BZ #23196)
Patch1034:      glibc-fix-avx512-mempcpy.patch
# PATCH-FIX-UPSTREAM memmove-sse2-unaligned on 32bit x86 produces garbage when crossing 2GB threshold (CVE-2017-18269, BZ #22644)
Patch1035:      i386-memmove-sse2-unaligned.patch
# PATCH-FIX-UPSTREAM realpath-ssize-max-overflow.patch: Fix overflow in path length computation (CVE-2018-11236, BZ #22786)
Patch1036:      realpath-ssize-max-overflow.patch
# PATCH-FIX-UPSTREAM Fix year 2039 bug for localtime with 64-bit time_t (bsc#1102526, BZ #22639)
Patch1037:      localtime-2039.patch
# PATCH-FIX-UPSTREAM Remove slow paths from math routines
Patch1038:      math-remove-slow-path.patch
Patch1039:      aarch64-hwcap-atomics.patch
# PATCH-FIX-UPSTREAM Fix build on aarch64 with binutils newer than 2.30
Patch1040:      glibc-fix-aarch64-build.diff
# PATCH-FIX-UPSTREAM Correct absolute (SHN_ABS) symbol run-time calculation (BZ #19818)
Patch1041:      absolute-symbols.patch
# PATCH-FIX-UPSTREAM x86: Fix Haswell CPU string flags (BZ #23709)
Patch1042:      x86-haswell-string-flags.patch
# PATCH-FIX-UPSTREAM pthread_cond_broadcast: Fix waiters-after-spinning case (BZ #23538)
Patch1043:      pthread-cond-broadcast-waiters-after-spinning.patch
Patch1044:      mman-map-sync.patch
Patch1045:      mman-linux-map-shared-validate.patch
# PATCH-FIX-UPSTREAM nptl: Preserve error in setxid thread broadcast in coredumps (BZ #22153)
Patch1046:      nptl-setxid-error.patch
# PATCH-FIX-UPSTREAM pthread_mutex_trylock does not use the correct order of instructions while maintaining the robust mutex list due to missing compiler barriers (BZ #24180)
Patch1047:      pthread-mutex-trylock-barrier.patch
# PATCH-FIX-UPSTREAM getaddrinfo: Fully parse IPv4 address strings (CVE-2016-10739, BZ #20018)
Patch1048:      getaddrinfo-parse-ipv4-address.patch
# PATCH-FIX-UPSTREAM ja_JP locale: Add entry for the new Japanese era (BZ #22964)
Patch1049:      japanese-era-name-may-2019.patch
# PATCH-FIX-UPSTREAM Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP (BZ #23275)
Patch1050:      force-elision-race.patch
# PATCH-FIX-UPSTREAM regex: fix read overrun (CVE-2019-9169, BZ #24114)
Patch1051:      regex-read-overrun.patch
# PATCH-FIX-UPSTREAM ERE '0|()0|\1|0' causes regexec undefined behavior (CVE-2009-5155, BZ #18986)
Patch1052:      regex-parse-reg-exp.patch
# PATCH-FIX-UPSTREAM GNU1815 - Hardware support in toolchain
Patch1053:      0001-S390-Add-configure-check-to-detect-z10-as-mininum-ar.patch
Patch1054:      0002-S390-Use-hwcap-instead-of-dl_hwcap-in-ifunc-resolver.patch
Patch1055:      0003-S390-Unify-31-64bit-memcpy.patch
Patch1056:      0004-S390-Refactor-memcpy-mempcpy-ifunc-handling.patch
Patch1057:      0005-S390-Remove-s390-specific-implementation-of-bcopy.patch
Patch1058:      0006-S390-Use-memcpy-for-forward-cases-in-memmove.patch
Patch1059:      0007-S390-Add-configure-check-to-detect-z13-as-mininum-ar.patch
Patch1060:      0008-S390-Add-z13-memmove-ifunc-variant.patch
Patch1061:      0009-S390-Add-z13-strstr-ifunc-variant.patch
Patch1062:      0010-S390-Add-z13-memmem-ifunc-variant.patch
Patch1063:      0011-S390-Cleanup-ifunc-resolve.h.patch
Patch1064:      0012-S390-Mark-vx-and-vxe-as-important-hwcap.patch
Patch1065:      0013-S390-Add-new-hwcap-values-for-new-cpu-architecture-a.patch
Patch1066:      0014-S390-Add-configure-check-to-detect-support-for-arch1.patch
Patch1067:      0015-S390-Add-arch13-memmove-ifunc-variant.patch
Patch1068:      0016-S390-Add-arch13-strstr-ifunc-variant.patch
Patch1069:      0017-S390-Add-arch13-memmem-ifunc-variant.patch
# PATCH-FIX-UPSTREAM rtld: Check __libc_enable_secure before honoring LD_PREFER_MAP_32BIT_EXEC (CVE-2019-19126, BZ #25204)
Patch1070:      prefer-map-32bit-exec.patch
# PATCH-FIX-UPSTREAM S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant (BZ #25226)
Patch1071:      s390-strstr-page-boundary.patch
# PATCH-FIX-UPSTREAM powerpc: Fix syscalls during early process initialization (BZ #22685)
Patch1072:      ppc-tle-htm-nosc.patch
# PATCH-FIX-UPSTREAM Use posix_spawn on popen (BZ #22834)
Patch1073:      posix-Add-internal-symbols-for-posix_spawn-interface.patch
Patch1074:      glibc-2.29-posix-Use-posix_spawn-on-popen.patch
# PATCH-FIX-UPSTREAM Fix array overflow in backtrace on PowerPC (CVE-2020-1751, BZ #25423)
Patch1075:      backtrace-powerpc.patch
Patch1076:      pthread-rwlock-pwn.patch
# PATCH-FIX-UPSTREAM manual: Document mprotect and introduce section on memory protection
Patch1077:      manual-memory-protection.patch
# PATCH-FIX-UPSTREAM Avoid ldbl-96 stack corruption from range reduction of pseudo-zero (CVE-2020-10029, BZ #25487)
Patch1078:      ldbl-96-rem-pio2l.patch
# PATCH-FIX-UPSTREAM elf: Allow dlopen of filter object to work (BZ #16272)
Patch1079:      dl-sort-maps.patch
Patch1080:      dlopen-filter-object.patch
# PATCH-FIX-UPSTREAM Fix use-after-free in glob when expanding ~user (CVE-2020-1752, BZ #25414)
Patch1081:      glob-use-after-free.patch
# PATCH-FIX-UPSTREAM nptl: wait for pending setxid request also in detached thread (BZ #25942)
Patch1082:      nptl-setxid-race.patch
# PATCH-FIX-UPSTREAM Fix concurrent changes on nscd aware files (BZ #23178)
Patch1083:      nscd-senfile.patch
# PATCH-FIX-UPSTREAM Fix iconv buffer handling with IGNORE error handler (BZ #18830)
Patch1084:      iconv-reset-input-buffer.patch
# PATCH-FIX-UPSTREAM iconv: Accept redundant shift sequences in IBM1364 (CVE-2020-27618, BZ #26224)
Patch1085:      iconv-redundant-shift.patch
# PATCH-FIX-UPSTREAM iconv: Fix incorrect UCS4 inner loop bounds (CVE-2020-29562, BZ#26923)
Patch1086:      iconv-ucs4-loop-bounds.patch
# PATCH-FIX-UPSTREAM x86: Harden printf against non-normal long double values (CVE-2020-29573, BZ #26649)
Patch1087:      printf-long-double-non-normal.patch
# PATCH-FIX-UPSTREAM Fix parsing of /sys/devices/system/cpu/online (BZ #25859)
Patch1088:      get-nprocs-cpu-online-parsing.patch
# PATCH-FIX-UPSTREAM gconv: Fix assertion failure in ISO-2022-JP-3 module (CVE-2021-3326, BZ #27256)
Patch1089:      gconv-assertion-iso-2022-jp.patch
# PATCH-FIX-UPSTREAM Fix buffer overrun in EUC-KR conversion module (CVE-2019-25013, BZ #24973)
Patch1090:      euc-kr-overrun.patch

# Patches awaiting upstream approval
# PATCH-FIX-UPSTREAM Always to locking when accessing streams (BZ #15142)
Patch2000:      fix-locking-in-_IO_cleanup.patch
# PATCH-FIX-UPSTREAM Never try to execute the file in ldd (BZ #16750)
Patch2001:      ldd-system-interp.patch
# PATCH-FIX-UPSTREAM Don't close or flush stdio streams on abort (BZ #15436)
Patch2002:      abort-no-flush.patch
# PATCH-FIX-UPSTREAM Fix fnmatch handling of collating elements (BZ #17396, BZ #16976)
Patch2004:      fnmatch-collating-elements.patch
# PATCH-FIX-UPSTREAM Properly reread entry after failure in nss_files getent function (BZ #18991)
Patch2005:      nss-files-long-lines-2.patch
# PATCH-FIX-UPSTREAM Avoid concurrency problem in ldconfig (BZ #23973)
Patch2007:      ldconfig-concurrency.patch
# PATCH-FIX-UPSTREAM nscd: bump GC cycle during cache pruning (BZ #26130)
Patch2008:      nscd-prune.patch
# PATCH-FIX-UPSTREAM Correct locking and cancellation cleanup in syslog functions (BZ #26100)
Patch2009:      syslog-locking.patch

# Non-glibc patches
# PATCH-FIX-OPENSUSE Remove debianisms from manpages
Patch3000:      manpages.patch

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 -n glibc-utils
Summary:        Development utilities from the GNU C Library
License:        LGPL-2.1+
Group:          Development/Languages/C and C++
Requires:       glibc = %{version}

%description -n glibc-utils
The glibc-utils package contains mtrace, a memory leak tracer and
xtrace, a function call tracer which can be helpful during program

If you are unsure if you need this, do not install this package.

%package -n glibc-testsuite
Summary:        Testsuite results from the GNU C Library
License:        LGPL-2.1+
Group:          Development/Languages/C and C++

%description -n glibc-testsuite
This package contains the testsuite results from the GNU C Library.

%if %{build_main}
%package info
Summary:        Info Files for the GNU C Library
License:        GFDL-1.1
Group:          Documentation/Other
Requires(post): %{install_info_prereq}
Requires(preun): %{install_info_prereq}
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/HTML
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:          System/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

%package locale-base
Summary:        Locale Data for Localized Programs
License:        GPL-2.0+ AND MIT AND LGPL-2.1+
Group:          System/Libraries
Requires(post): /bin/cat
Requires:       glibc = %{version}

%description locale-base
Locale data for the internationalisation features of the GNU C library.
This package contains only the US-english locales.

%package locale
Summary:        Locale Data for Localized Programs
License:        GPL-2.0+ AND MIT AND LGPL-2.1+
Group:          System/Libraries
Requires:       glibc-locale-base = %{version}
# bug437293
%ifarch ppc64
Obsoletes:      glibc-locale-64bit
%ifarch ppc
Obsoletes:      glibc-locale-32bit

%description locale
Locale data for the internationalisation features of the GNU C library.

%package -n nscd
Summary:        Name Service Caching Daemon
License:        GPL-2.0+
Group:          System/Daemons
Provides:       glibc:/usr/sbin/nscd
Requires:       glibc = %{version}
Obsoletes:      unscd <= 0.48
Requires(pre):  pwdutils

%description -n nscd
Nscd caches name service lookups and can dramatically improve
performance with NIS, NIS+, and LDAP.

%package profile
Summary:        Libc Profiling and Debugging Versions
License:        LGPL-2.1+ AND SUSE-LGPL-2.1+-with-GCC-exception AND GPL-2.0+
Group:          Development/Libraries/C and C++
Requires:       glibc = %{version}
# bug437293
%ifarch ppc64
Obsoletes:      glibc-profile-64bit
%ifarch ppc
Obsoletes:      glibc-profile-32bit

%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 SUSE-LGPL-2.1+-with-GCC-exception AND GPL-2.0+
Group:          Development/Libraries/C and C++
Obsoletes:      epoll = 1.0
Provides:       epoll < 1.0
# bug437293
%ifarch ppc64
Obsoletes:      glibc-devel-64bit
%ifarch ppc
Obsoletes:      glibc-devel-32bit
Requires:       glibc = %{version}
Requires:       linux-kernel-headers

%description devel
These libraries are needed to develop programs which use the standard C

%package devel-static
Summary:        C library static libraries for -static linking
License:        BSD-3-Clause AND LGPL-2.1+ AND SUSE-LGPL-2.1+-with-GCC-exception AND GPL-2.0+
Group:          Development/Libraries/C and C++
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.

# makedb requires libselinux. We add this program in a separate
# package so that glibc does not require libselinux.
%package extra
Summary:        Extra binaries from GNU C Library
License:        LGPL-2.1+
Group:          Development/Libraries/C and C++
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
%endif # main

%setup -n glibc-%{version} -q -a 4
# Owl crypt_blowfish
tar -xzf %SOURCE50
pushd crypt_blowfish-%{crypt_bf_version}
%patch2 -p1
%patch3 -p1
%patch4 -p1
mv crypt/{crypt.h,gnu-crypt.h}
mv crypt_blowfish-%crypt_bf_version/*.[chS] crypt/
%patch1 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
# avoid changing nscd_stat.c mtime to avoid code generation
# differences on each rebuild
touch -r nscd/nscd_stat.c nscd/s-stamp
%patch9 -p1
touch -r nscd/s-stamp nscd/nscd_stat.c
rm nscd/s-stamp
%patch10 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch19 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1

%patch100 -p1
%patch102 -p1
%patch103 -p1
%patch104 -p1
%patch105 -p1

%patch304 -p1
%patch306 -p1

%patch1000 -p1
%patch1001 -p1
%patch1002 -p1
%patch1003 -p1
%patch1004 -p1
%patch1005 -p1
%patch1006 -p1
%patch1007 -p1
%patch1008 -p1
%patch1009 -p1
%patch1010 -p1
%patch1011 -p1
%patch1012 -p1
%patch1013 -p1
%patch1014 -p1
%patch1015 -p1
%patch1016 -p1
%patch1017 -p1
%patch1018 -p1
%patch1019 -p1
%patch1020 -p1
%patch1021 -p1
%patch1022 -p1
%patch1023 -p1
%patch1024 -p1
%patch1025 -p1
%patch1026 -p1
%patch1027 -p1
%patch1028 -p1
%patch1029 -p1
%patch1030 -p1
%patch1031 -p1
%patch1032 -p1
%patch1033 -p1
%patch1034 -p1
%patch1035 -p1
%patch1036 -p1
%patch1037 -p1
%patch1038 -p1
%patch1039 -p1
%patch1040 -p1
%patch1041 -p1
%patch1042 -p1
%patch1043 -p1
%patch1044 -p1
%patch1045 -p1
%patch1046 -p1
%patch1047 -p1
%patch1048 -p1
%patch1049 -p1
%patch1050 -p1
%patch1051 -p1
%patch1052 -p1
%patch1053 -p1
%patch1054 -p1
%patch1055 -p1
%patch1056 -p1
%patch1057 -p1
%patch1058 -p1
%patch1059 -p1
%patch1060 -p1
%patch1061 -p1
%patch1062 -p1
%patch1063 -p1
%patch1064 -p1
%patch1065 -p1
%patch1066 -p1
%patch1067 -p1
%patch1068 -p1
%patch1069 -p1
%patch1070 -p1
%patch1071 -p1
%patch1072 -p1
%patch1073 -p1
%patch1074 -p1
%patch1075 -p1
%patch1076 -p1
%patch1077 -p1
%patch1078 -p1
%patch1079 -p1
%patch1080 -p1
%patch1081 -p1
%patch1082 -p1
%patch1083 -p1
%patch1084 -p1
%patch1085 -p1
%patch1086 -p1
%patch1087 -p1
%patch1088 -p1
%patch1089 -p1
%patch1090 -p1

%patch2000 -p1
%patch2001 -p1
%patch2002 -p1
%patch2004 -p1
%patch2005 -p1
%patch2007 -p1
%patch2008 -p1
%patch2009 -p1


# Inconsistency detected by dl-close.c: 719: _dl_close: Assertion `map->l_init_called' failed!
# Glibc 2.8 introduced the HP_TIMING element to the rtld_global_ro struct # definition.
# If the base is built without power4 the loader won't have this element in
# the struct whereas the power4/5/6/... libc will, so there will be a disconnect
# between the size of the rtld_global_ro struct between the two and dl_close
# ends up getting called incorrectly when it's actually attempting to call a
# resolver function.  This is because the GLRO() macro simply attempts to
# compute an offset and gets the wrong one.
# Building the base glibc with --with-cpu=power4 solves this problem.
# But: ppc32 can not default to -mcpu=power4 because it would emit instructions
# which are not available on G3, G4 etc.
# We simply remove the power4 files, and build the base glibc for a generic powerpc cpu
# Additional cputuned libs can now be used on powerpc32
rm -fv sysdeps/powerpc/powerpc32/power4/hp-timing.c sysdeps/powerpc/powerpc32/power4/hp-timing.h
find . -name configure | xargs touch

if [ -x /bin/uname.bin ]; then
	/bin/uname.bin -a
	uname -a
uptime || :
ulimit -a
# 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}-suse-linux-gnueabi
%define target %{_target_cpu}-suse-linux
# Don't use as-needed, it breaks glibc assumptions
# Before enabling it, run the testsuite and verify that it
# passes completely
# Adjust glibc version.h
echo "#define CONFHOST \"%{target}\"" >> version.h
echo "#define GITID \"%{git_id}\"" >> version.h
# Default CFLAGS and Compiler
BuildFlags="%{optflags} -U_FORTIFY_SOURCE"
for opt in $BuildFlags; do
  case $opt in
    -fstack-protector-strong) enable_stack_protector=strong ;;
    -fstack-protector-all) enable_stack_protector=all ;;
    -fstack-protector) enable_stack_protector=yes ;;
BuildFlags=$(echo $BuildFlags | sed -e 's#-fstack-protector[^ ]*##' -e 's#-ffortify=[0-9]*##')
#now overwrite for some architectures
%ifarch sparc64
	BuildFlags="-O2 -mcpu=ultrasparc -mvis -fcall-used-g6"
	BuildCC="gcc -m64"
	BuildCCplus="$BuildCCplus -m64"
%ifarch sparc
	BuildFlags="$BuildFlags -fcall-used-g6"
	BuildCC="gcc -m32"
	BuildCCplus="$BuildCCplus -m32"
%ifarch sparcv9
	BuildFlags="$BuildFlags -mcpu=ultrasparc -fcall-used-g6"
	BuildCC="gcc -m32"
	BuildCCplus="$BuildCCplus -m32"
%ifarch alphaev6
%ifarch ppc ppc64
	BuildFlags="$(echo $BuildFlags | sed 's#-mminimal-toc##')"
%ifarch ppc64
	BuildCC="$BuildCC -m64"
	BuildCCplus="$BuildCCplus -m64"
%ifarch hppa
	BuildFlags="$BuildFlags -mpa-risc-1-1 -fstrict-aliasing"
# Add flags for all plattforms except AXP
%ifnarch alpha
	BuildFlags="$BuildFlags -g"
%if %{disable_assert}
	BuildFlags="$BuildFlags -DNDEBUG=1"
%ifarch mipsel
	# fails to build otherwise - need to recheck and fix
	%define enable_stackguard_randomization 0

configure_and_build_glibc() {
	local dirname="$1"; shift
	local cflags="$1"; shift
	mkdir "cc-$dirname"
	cd "cc-$dirname"
%ifarch %arm aarch64
	# remove asynchronous-unwind-tables during configure as it causes
	# some checks to fail spuriously on arm

%if %{build_profile}
        if [ "$dirname" = "base" ] ; then
	if [ "$dirname" = "noelision" ]; then
	../configure \
		CFLAGS="$conf_cflags" BUILD_CFLAGS="$conf_cflags" \
		CC="$BuildCC" CXX="$BuildCCplus" \
		--prefix=%{_prefix} \
		--libexecdir=%{_libexecdir} --infodir=%{_infodir} \
		--enable-add-ons=$add_ons \
	        $profile $elision \
		"$@" \
		--build=%{target} --host=%{target} \
%ifarch armv7hl ppc ppc64 ppc64le i686 x86_64 sparc sparc64 s390 s390x
		--enable-multi-arch \
%ifarch mipsel
		--without-fp \
%ifarch ppc64p7
		--with-cpu=power7 \
%if %{enable_stackguard_randomization}
		--enable-stackguard-randomization \
		${enable_stack_protector:+--enable-stack-protector=$enable_stack_protector} \
		--enable-tunables \
		--enable-kernel=%{enablekernel} \
		--with-bugurl= \
		--enable-bind-now \
		--enable-obsolete-rpc \
		--enable-systemtap \
# Should we enable --enable-nss-crypt to build use freebl3 hash functions?
	# explicitly set CFLAGS to use the full CFLAGS (not the reduced one for configure)
	make %{?_smp_mflags} CFLAGS="$cflags" BUILD_CFLAGS="$cflags"
	cd ..

%if !%{optimize_power}
	# Build base glibc
	configure_and_build_glibc base "$BuildFlags"
	# Build POWER-optimized glibc
	# First, base build:
	pBuildFlags="$BuildFlags -mtune=%{powerpc_optimize_tune}"
	%if "%{powerpc_optimize_base}" != ""
	pBuildFlags+=" -mcpu=%{powerpc_optimize_base}"
	%if "%{powerpc_optimize_base}" != ""
	configure_and_build_glibc base "$pBuildFlags" --with-cpu=%{powerpc_optimize_base}
	# Use no default CPU
	configure_and_build_glibc base "$pBuildFlags"
	%if %{build_variants}
	# Then other power variants:
	for pcpu in \
	%if %{powerpc_optimize_cpu_power4}
		power4 \
	%if %{powerpc_optimize_cpu_power6}
		power6 \
	%if %{powerpc_optimize_cpu_power7}
		power7 \
	; do
		configure_and_build_glibc $pcpu "$BuildFlags -mcpu=$pcpu" \
	# Eventually, special Cell variant:
	%if %{powerpc_optimize_cpu_cell}
		configure_and_build_glibc ppc-cell-be "$BuildFlags -mcpu=cell"
	%endif # %{build_variants}
%endif # optimize_power

%if %{build_variants}
%ifarch i686 x86_64
configure_and_build_glibc noelision "$BuildFlags"

# Build html documentation
%if %{build_html}
make -C cc-base html

# 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 \
%ifarch ppc ppc64
 %if !%{powerpc_optimize_cpu_power4}
 %if !%{powerpc_optimize_cpu_power6}
 %if !%{powerpc_optimize_cpu_power7}
 %if !%{powerpc_optimize_cpu_cell}
    '-DLIBDIR="/%{_lib}"' '-DGCONV_MODULES_DIR="%{_libdir}/gconv"'

# crypt_blowfish man pages
pushd crypt_blowfish-%{crypt_bf_version}
make man

%if %{build_testsuite}
# The testsuite will fail if asneeded is used
# Increase timeout
# The testsuite does its own malloc checking
make -C cc-base -k check || {
  cd cc-base
  set +x
  for sum in subdir-tests.sum */subdir-tests.sum; do
    while read s t; do
      case $s in
	  echo ++++++ $s $t ++++++
	*) # X?FAIL:
	  echo ------ $s $t ------
	  test ! -f $t.out || cat $t.out
    done < $sum
  set -$o
  # Fail build if there where compilation errors during testsuite run
  test -f tests.sum
# This has to pass on all platforms!
# Exceptions:
# None!
make %{?_smp_mflags} -C cc-base check-abi

%if %{build_main}
# We don't want to strip the .symtab from our libraries in,
# certainly not from* 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"
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
  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
    cp -a ${lib}.so $destdir/$libbaseso
cd ..
cc-base/elf/ldconfig -vn $destdir

# Install power-optimized glibc
%if %{optimize_power}
	%if %{powerpc_optimize_cpu_power4}
	install_optimized_variant power4 power4 ".."
	%if %{powerpc_optimize_cpu_power6}
	install_optimized_variant power6 power6 ".."
	%if %{powerpc_optimize_cpu_power7}
	install_optimized_variant power7 power7 ".."
	%if %{powerpc_optimize_cpu_cell}
	install_optimized_variant ppc-cell-be ppc-cell-be ".."
	%if %{powerpc_optimize_cpu_power6}
	# power6 is compatible with power6x
	# doing a directory symlink doesnt work, ldconfig follows them and accepts only the first real dir
	if test -d %{buildroot}/%{_lib}/power6; then
	    mkdir -p %{buildroot}/%{_lib}/power6x
	    for i in %{buildroot}/%{_lib}/power6/*.so; do
		b=$(basename $i)
		ln -vs ../power6/$b %{buildroot}/%{_lib}/power6x/$b
	    cc-base/elf/ldconfig -vn %{buildroot}/%{_lib}/power6x
%endif # optimize_power

%ifarch i686 x86_64
cd cc-noelision
mkdir -p $destdir
install -m 755 nptl/ $destdir/libpthread-%{libversion}.so
cd ..
cc-base/elf/ldconfig -vn $destdir

# 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
	# Avoid hardlinks across subpackages
	mv %{buildroot}/usr/lib/locale/{en_US,C}.utf8 .
	%fdupes %{buildroot}/usr/lib/locale
	mv {en_US,C}.utf8 %{buildroot}/usr/lib/locale/
	cd ..
# Create file list for glibc-locale package
%{find_lang} libc

# remove nsl compat library
rm -f %{buildroot}%{_libdir}/libnsl*
# part of libnsl-devel
rm -f %{buildroot}%{_includedir}/rpcsvc/yppasswd.*

# 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

cd manpages; make install_root=%{buildroot} install; cd ..

# crypt_blowfish man pages
pushd crypt_blowfish-%{crypt_bf_version}
install -m755 -d %{buildroot}%{_mandir}/man3
install -m644 *.3 %{buildroot}%{_mandir}/man3

# nscd tools:

%ifnarch i686
cp nscd/nscd.conf %{buildroot}/etc
mkdir -p %{buildroot}/etc/init.d
ln -sf /sbin/service %{buildroot}/usr/sbin/rcnscd
mkdir -p %{buildroot}/run/nscd
mkdir -p %{buildroot}/var/lib/nscd

# Create
cat > %{buildroot}/etc/ <<EOF
%if "%{_lib}" != "lib"
%ifarch ppc
include /etc/*.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.
# Add ldconfig cache directory for directory ownership
mkdir -p %{buildroot}/var/cache/ldconfig
# Empty the
rm -f %{buildroot}/etc/
touch %{buildroot}/etc/

# Don't look at ldd! We don't wish a /bin/sh requires
chmod 644 %{buildroot}%{_bindir}/ldd

rm -f %{buildroot}/sbin/sln

# Remove the buildflags tracking section and the build-id
for o in %{buildroot}/%{_libdir}/crt[1in].o %{buildroot}/%{_libdir}/lib*_nonshared.a; do
	objcopy -R ".comment.SUSE.OPTs" -R "" $o

%ifnarch i686
mkdir -p %{buildroot}/usr/lib/tmpfiles.d/
install -m 644 %{SOURCE20} %{buildroot}/usr/lib/tmpfiles.d/
mkdir -p %{buildroot}/usr/lib/systemd/system
install -m 644 %{SOURCE21} %{buildroot}/usr/lib/systemd/system

%ifarch armv6hl armv7hl
# Provide compatibility link
ln -s ld-%{libversion}.so %{buildroot}/lib/

# 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

%if !%{build_utils}
# Remove unwanted files (packaged in glibc-utils)
rm -f %{buildroot}/%{_lib}/libmemusage*
rm -f %{buildroot}/%{_lib}/libpcprofile*
rm -f %{buildroot}%{_bindir}/memusage*
rm -f %{buildroot}%{_bindir}/mtrace
rm -f %{buildroot}%{_bindir}/pcprofiledump
rm -f %{buildroot}%{_bindir}/sotruss
rm -f %{buildroot}%{_bindir}/xtrace
rm -f %{buildroot}%{_bindir}/pldd
rm -rf %{buildroot}%{_libdir}/audit

%ifarch i686
# Remove files from glibc-{extra,info,i18ndata} and nscd
rm -rf %{buildroot}%{_infodir} %{buildroot}%{_prefix}/share/i18n
rm -f %{buildroot}%{_bindir}/makedb %{buildroot}/var/lib/misc/Makefile
rm -f %{buildroot}%{_sbindir}/nscd
%endif # i686
%endif # !utils

%ifarch %ix86
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/
%ifarch x86_64
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/
%ifarch ppc
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/
%ifarch ppc64
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/
%ifarch s390
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/
%ifarch s390x
ln -sf /%{_lib}/ $RPM_BUILD_ROOT/%{_lib}/

%else # !main

%if %{build_utils}

make %{?_smp_mflags} install_root=%{buildroot} install -C cc-base \
  subdirs='malloc debug elf'
cd manpages; make install_root=%{buildroot} install; cd ..
# Remove unwanted files
rm -f %{buildroot}/%{_lib}/ld*.so* %{buildroot}/%{_lib}/lib[!mp]*
rm -f %{buildroot}/lib/ld*.so*
rm -f %{buildroot}%{_libdir}/lib*
rm -f %{buildroot}%{_bindir}/{catchsegv,ldd*,sprof}
rm -rf %{buildroot}%{_mandir}/man*
rm -rf %{buildroot}/sbin %{buildroot}%{_includedir}

%endif # utils

%endif # !main

%if %{build_main}

%post -p %{_sbindir}/glibc_post_upgrade
%postun -p /sbin/ldconfig

%post locale-base
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"

%post info
%install_info --info-dir=%{_infodir} %{_infodir}/

%preun info
%install_info_delete --info-dir=%{_infodir} %{_infodir}/

%pre -n nscd
getent group nscd >/dev/null || %{_sbindir}/groupadd -r nscd
getent passwd nscd >/dev/null || %{_sbindir}/useradd -r -g nscd -c "User for nscd" -s /sbin/nologin -d /run/nscd nscd
%service_add_pre nscd.service

%preun -n nscd
%service_del_preun nscd.service

%post -n nscd
%service_add_post nscd.service
%tmpfiles_create /usr/lib/tmpfiles.d/nscd.conf
# Previously we had nscd.socket, remove it
test -x /usr/bin/systemctl && /usr/bin/systemctl stop nscd.socket 2>/dev/null || :
test -x /usr/bin/systemctl && /usr/bin/systemctl disable nscd.socket 2>/dev/null  || :
# Hard removal in case the above did not work
rm -f /etc/systemd/system/
exit 0

%postun -n nscd
%service_del_postun nscd.service
exit 0

# glibc
%license LICENSES
%config(noreplace) /etc/bindresvport.blacklist
%config /etc/
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /etc/
%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
%doc %{_mandir}/man1/gencat.1.gz
%doc %{_mandir}/man1/getconf.1.gz
%doc %{_mandir}/man5/*

# Each architecture has a different name for the dynamic linker:
%ifarch %arm
%ifarch armv6hl armv7hl
# Keep compatibility link
%ifarch ia64
%ifarch ppc s390 mips hppa m68k
%ifarch ppc64
%ifarch ppc64le
%ifarch s390x
%ifarch x86_64
%ifarch %ix86 %sparc
%ifarch aarch64
%ifarch %ix86 x86_64 ppc ppc64 s390 s390x

%ifarch x86_64
%define optimized_libs() \
	%dir %attr(0755,root,root) /%{_lib}/%1\

%if %{optimize_power}
	%if %{powerpc_optimize_cpu_power4}
		%{optimized_libs power4}
	%if %{powerpc_optimize_cpu_power6}
		%{optimized_libs power6}
		%{optimized_libs power6x}
	%if %{powerpc_optimize_cpu_power7}
		%{optimized_libs power7}
	%if %{powerpc_optimize_cpu_cell}
		%{optimized_libs ppc-cell-be}
%endif # optimize_power
%ifarch i686 x86_64
%dir %attr(0700,root,root) /var/cache/ldconfig
%attr(755,root,root) %{_bindir}/ldd
%ifarch %ix86 sparc sparcv9 m68k
%dir %attr(0755,root,root) %{_libexecdir}/getconf

%files locale-base -f libc.lang
%if %{build_locales}
%dir %{_prefix}/lib/locale

%files locale
%if %{build_locales}
%exclude %{_prefix}/lib/locale/C.utf8
%exclude %{_prefix}/lib/locale/en_US.utf8

%files devel
%doc %{_mandir}/man1/catchsegv.1.gz
%doc %{_mandir}/man1/rpcgen.1.gz
%doc %{_mandir}/man3/*
# These static libraries are needed even for shared builds
%ifarch ppc ppc64 ppc64le s390 s390x sparc sparcv8 sparcv9 sparcv9v
# This is not built on sparc64.
%ifarch x86_64

%files devel-static
%ifarch x86_64

%ifnarch i686
%files info
%doc %{_infodir}/
%doc %{_infodir}/
%doc %{_infodir}/

%if %{build_html}
%files html
%doc %{_prefix}/share/doc/glibc

%files i18ndata

%files -n nscd
%config(noreplace) /etc/nscd.conf
%dir /usr/lib/tmpfiles.d
%dir %attr(0755,root,root) %ghost /run/nscd
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/
%attr(0666,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /run/nscd/socket
%dir %attr(0755,root,root) /var/lib/nscd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/passwd
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/group
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/hosts
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/services
%attr(0600,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) /var/lib/nscd/netgroup
%endif # !i686

%if %{build_profile}
%files profile
%ifarch x86_64

%ifnarch i686
%files extra
%endif # !i686

%endif # main

%if %{build_utils}
%files -n glibc-utils
%dir %{_libdir}/audit
%endif # utils

openSUSE Build Service is sponsored by