# hangs on aarch64 %define dont_check_elf_files 1 # :- tags for glibc main package %define glibcversion 2.40 %define __glibcrelease 1 %define glibcepoch 6 %define source_package glibc-%{glibcversion} %define source_dir glibc-%{glibcversion} %define _glibcrelease %{__glibcrelease} %define glibcrelease %mkrel %{_glibcrelease} # Define "cross" to an architecture to which glibc is to be # cross-compiled %define build_cross 0 %{expand: %{?cross: %%global build_cross 1}} %if %{build_cross} %define target_cpu %{cross} %define cross_prefix cross-%{target_cpu}- %define _prefix /usr/%{target_cpu}-%{_real_vendor}-linux%{gnuext} %define cross_program_prefix %{target_cpu}-%{_real_vendor}-linux%{gnuext}- %define _exec_prefix %{_prefix} # brain damage alert: should not be needed imho # overriding _prefix and _exec_prefix should be enough %define _bindir %{_exec_prefix}/bin %define _sbindir %{_exec_prefix}/sbin %define _libexecdir %{_exec_prefix}/libexec %define _datadir %{_prefix}/share %define _sharedstatedir %{_prefix}/com %define _localstatedir %{_prefix}/var %define _lib lib %define _libdir %{_exec_prefix}/%{_lib} %define _slibdir %{_exec_prefix}/%{_lib} %define _slibdir32 %{_exec_prefix}/lib %define _includedir %{_prefix}/include %else %define gnuext %{_gnu} %define target_cpu %{_target_cpu} %define cross_prefix %{nil} %define cross_program_prefix %{nil} %define _slibdir /%{_lib} %define _slibdir32 /lib %endif # Define target (base) architecture %define arch %(echo %{target_cpu}|sed -e "s/\\(i.86\\|athlon\\)/i386/" -e "s/amd64/x86_64/") %define isarch() %(case " %* " in (*" %{arch} "*) echo 1;; (*) echo 0;; esac) %if %{build_cross} %if %isarch %arm %define gnuext -gnueabi %else %define gnuext -gnu %endif %endif # Define Xen arches to build with -mno-tls-direct-direct-seg-refs %define xenarches %{ix86} x86_64 # arches which requires glibc-port %define ports_arch %arm # Define to build nscd with selinux support %define build_selinux 0 # Flag for build_pdf_doc: # 1 build glibc with PDF documentation # 0 don't build PDF glibc documentation (e.g. for bootstrap build) %define build_pdf_doc 0 # Enable checking by default for arches where we know tests all pass %define build_check 0 # Allow make check to fail only when running kernels where we know # tests must pass (no missing features or bugs in the kernel) %define check_min_kver 2.6.32 # Define to build a biarch package %define build_biarch 0 %if %isarch x86_64 %define build_biarch 1 %endif # build debug packages %define build_debug 1 # Define to bootstrap new glibc %define build_bootstrap 0 %{expand: %{!?build_cross_bootstrap: %global build_cross_bootstrap 0}} %define build_profile 1 %define build_nscd 1 %define build_doc 1 %define build_utils 1 %define build_i18ndata 1 %define build_timezone 0 # Disable a few defaults when cross-compiling a glibc %if %{build_cross} %define build_doc 0 %define build_pdf_doc 0 %define build_biarch 0 %define build_check 0 %define build_nscd 0 %define build_profile 0 %define build_utils 0 %define build_i18ndata 0 %define build_timezone 0 %endif # Allow --with[out] at rpm command line build %{expand: %{?_without_PDF: %%global build_pdf_doc 0}} %{expand: %{?_without_CHECK: %%global build_check 0}} %{expand: %{?_without_UTILS: %%global build_utils 0}} %{expand: %{?_without_BOOTSTRAP:%%global build_bootstrap 0}} %{expand: %{?_with_PDF: %%global build_pdf_doc 1}} %{expand: %{?_with_CHECK: %%global build_check 1}} %{expand: %{?_with_UTILS: %%global build_utils 1}} %{expand: %{?_with_BOOTSTRAP: %%global build_bootstrap 1}} ############################################################################## # Utility functions for pre/post scripts. Stick them at the beginning of # any lua %pre, %post, %postun, etc. sections to have them expand into # those scripts. It only works in lua sections and not anywhere else. %define glibc_post_funcs() \ -- We use lua posix.exec because there may be no shell that we can \ -- run during glibc upgrade. We used to implement much of %%post as a \ -- C program, but from an overall maintenance perspective the lua in \ -- the spec file was simpler and safer given the operations required. \ -- All lua code will be ignored by rpm-ostree; see: \ -- https://github.com/projectatomic/rpm-ostree/pull/1869 \ -- If we add new lua actions to the %%post code we should coordinate \ -- with rpm-ostree and ensure that their glibc install is functional. \ \ function post_exec (program, ...) \ local pid = posix.fork () \ if pid == 0 then \ posix.exec (program, ...) \ assert (nil) \ elseif pid > 0 then \ posix.wait (pid) \ end \ end \ \ function update_gconv_modules_cache () \ local iconv_dir = "%{_libdir}/gconv" \ local iconv_cache = iconv_dir .. "/gconv-modules.cache" \ local iconv_modules = iconv_dir .. "/gconv-modules" \ if (posix.utime (iconv_modules) == 0) then \ if (posix.utime (iconv_cache) == 0) then \ post_exec ("%{_prefix}/sbin/iconvconfig", \ "-o", iconv_cache, \ "--nostdlib", \ iconv_dir) \ else \ io.stdout:write ("Error: Missing " .. iconv_cache .. " file.\n") \ end \ end \ end \ %{nil} Summary: The GNU libc libraries Name: %{cross_prefix}glibc Version: %{glibcversion} Release: %{glibcrelease} Epoch: %{glibcepoch} License: LGPL Group: System/Libraries Url: https://www.gnu.org/software/libc/ # FSF source Source0: https://ftpmirror.gnu.org/libc/%{source_package}.tar.xz Source1: https://ftpmirror.gnu.org/libc/%{source_package}.tar.xz.sig Source2: glibc-git.sh Source4: glibc-find-requires.sh Source5: glibc-check.sh Source6: nscd.service Source7: nscd.socket Source8: nsswitch.conf Source9: nscd.conf # filter out libc_malloc_debug provides %global __provides_exclude ^libc_malloc_debug\\.so.*$ %if %{build_cross} Autoreq: false Autoprov: false %else Provides: should-restart = system %if %isarch %{xenarches} Obsoletes: %{name}-xen Provides: %{name}-xen %endif # The dynamic linker supports DT_GNU_HASH Provides: rtld(GNU_HASH) Autoreq: false %endif BuildRequires: bison >= 3.3.1-1 BuildRequires: patch BuildRequires: git BuildRequires: gettext BuildRequires: perl BuildRequires: kernel-userspace-headers BuildRequires: libstdc++-static-devel BuildRequires: hardlink %if %{build_selinux} BuildRequires: pkgconfig(libselinux) >= 1.17.10 BuildRequires: pkgconfig(libpcre) >= 8.44 %endif # (wally) force new gcc 14 BuildRequires: %{cross_prefix}gcc >= 14.0.1-0.20240317.1 # (wally) force latest binutils 2.42 BuildRequires: %{cross_prefix}binutils >= 1:2.42-9 # we need the static dash %define ash_bin /usr/bin/dash.static Requires(post): dash-static Requires(post): grep Requires: filesystem >= 2.1.9-18 # ensure libxcrypt is installed as glibc crypt is disabled / being obsoleted Requires: libxcrypt%{?_isa} >= 4.4.36-3 BuildRequires: systemtap-sdt-devel BuildRequires: texinfo BuildRequires: texinfo-tex %if %{build_pdf_doc} BuildRequires: texlive %endif %if %{build_utils} BuildRequires: pkgconfig(gdlib) %endif BuildRequires: autoconf2.5 BuildRequires: pkgconfig(libcap) BuildRequires: rpm-mageia-setup-build >= 1.147 BuildRequires: spec-helper >= 0.31.2 ### ### upstream release/2.40/master branch ### git format-patch --start-number 100 glibc-2.40..origin/release/2.40/master ### ### ### upstream master branch ### starts from number 400 ### ### ### Mageia patches ### # various path fix, according to usrmove Patch01: glibc-2.17-fhs-usrmove.patch Patch06: glibc-2.26-share-locale.patch # use xvt instead of xterm in xtrace.sh # cannot be pushed upstream as xvt is Ma* specific Patch09: glibc-2.2.4-xterm-xvt.patch # add transliteration for "COLON SIGN" # ( used for the money of money of san salvador ) Patch11: glibc-2.19-compat-EUR-currencies.patch # fix the chkconfig header, should be sent upstream Patch13: glibc-2.3.3-nscd-enable.patch # disable cache for hosts on nscd, as this is seen as insecure # if the system relie on reverse dns for security Patch14: glibc-2.9-nscd-no-host-cache.patch # add some new timezone for various cities # Halifax, Montreal, Johannesburg # should be sent upstream ( I guess ) Patch23: glibc-2.3.4-timezone.patch Patch24: glibc-2.10.1-biarch-cpp-defines.patch Patch29: glibc-2.3.5-biarch-utils.patch # translation fixes, need to be checked with some i18n team member # should be safe to send upstream once checked Patch35: glibc-2.16.0-force-gb18030-for-zh_CN.patch # check for libcap, even if selinux is disabled # should be sent upstream Patch44: glibc-2.39-dont-tie-libcap-with-selinux.patch # Install only C.UTF-8 locale files Patch45: 0001-Install-only-C.UTF-8-locale-files.patch # Determine minium kernel versions %define enablekernel 3.2 Conflicts: kernel < %{enablekernel} # People changed location of rpm scripts... %define rpmscripts /usr/lib/rpm/%{_real_vendor} # Don't try to explicitly provide GLIBC_PRIVATE versioned libraries %define __find_provides %{_builddir}/%{source_dir}/find_provides.sh %define __find_requires %{_builddir}/%{source_dir}/find_requires.sh %if !%{build_cross} Obsoletes: ld.so Provides: ld.so %endif %if !%{build_cross} Conflicts: locales < 2.39-4 %endif Obsoletes: ldconfig Provides: ldconfig = %{glibcepoch}:%{glibcversion}-%{glibcrelease} /sbin/ldconfig # obsolete nss_db as it got merged again in 2.15 Obsoletes: nss_db <= 2.2.3-0.pre1.9 %description The glibc package contains standard libraries which are used by multiple programs on the system. In order to save disk space and memory, as well as to make upgrading easier, common system code is kept in one place and shared between programs. This particular package contains the most important sets of shared libraries: the standard C library and the standard math library. Without these two libraries, a Linux system will not function. The glibc package also contains national language (locale) support. This package now also provides ldconfig which was packaged separately in the past. Ldconfig is a basic system program which determines run-time link bindings between ld.so and shared libraries. Ldconfig scans a running system and sets up the symbolic links that are used to load shared libraries properly. It also creates a cache (/etc/ld.so.cache) which speeds the loading of programs which use shared libraries. %package devel Summary: Header and object files for development using standard C libraries Group: Development/C Requires(post): coreutils Requires(postun): coreutils, awk # ensure libxcrypt is installed as glibc crypt is disabled / being obsoleted Requires: libxcrypt-devel%{?_isa} >= 4.4.36-3 # (tmb) filter out requires on self-provides %global __requires_exclude devel\\(libm.*\\)|devel\\(libnss_files.*\\) # (tmb) add virtual provides for old libm to ease builds... from glibc-2.22 libmvec is preferred %ifarch x86_64 aarch64 Provides: devel(libm(64bit)) %endif # glibc 2.33 -> 2.34 virtual provides upgrade helpers Provides: devel(libdl) Provides: devel(libutil) %ifarch x86_64 aarch64 Provides: devel(libdl(64bit)) Provides: devel(libutil(64bit)) %endif # (tmb) for glibc 2.34 empty archives (libanl.a, libdl.a, libpthread.a, librt.a, libutil.a) # are moved from static-devel to keep matching linker options working Conflicts: glibc-static-devel < 6:2.34-5 Requires: %{name} = %{glibcepoch}:%{glibcversion}-%{glibcrelease} %if !%{build_cross} Requires: linux-userspace-headers %endif %if %{build_cross} Autoreq: false Autoprov: false %else Autoreq: true %endif %description devel The glibc-devel package contains the header and object files necessary for developing programs which use the standard C libraries (which are used by nearly all programs). If you are developing programs which will use the standard C libraries, your system needs to have these standard header and object files available in order to create the executables. This package also includes the C header files for the Linux kernel. The header files define structures and constants that are needed for building most standard programs. The header files are also needed for rebuilding the kernel. Install glibc-devel if you are going to develop programs which will use the standard C libraries. %package static-devel Summary: Static libraries for GNU C library Group: Development/C Requires: %{name}-devel = %{glibcepoch}:%{glibcversion}-%{glibcrelease} # ensure libxcrypt is installed as glibc crypt is disabled / being obsoleted Requires: libxcrypt-static-devel%{?_isa} >= 4.4.36-3 %description static-devel The glibc-static-devel package contains the static libraries necessary for developing programs which use the standard C libraries. Install glibc-static-devel if you need to statically link your program or library. %package profile Summary: The GNU libc libraries, including support for gprof profiling Group: Development/C Obsoletes: libc-profile Provides: libc-profile = %{glibcversion}-%{glibcrelease} Autoreq: true %description profile The glibc-profile package includes the GNU libc libraries and support for profiling using the gprof program. Profiling is analyzing a program's functions to see how much CPU time they use and determining which functions are calling other functions during execution. To use gprof to profile a program, your program needs to use the GNU libc libraries included in glibc-profile (instead of the standard GNU libc libraries included in the glibc package). If you are going to use the gprof program to profile a program, you'll need to install the glibc-profile program. %package -n nscd Summary: A Name Service Caching Daemon (nscd) Group: System/Servers Requires(post): systemd >= %{systemd_required_version} Requires(post): rpm-helper >= 0.24.8-1 Requires(preun): rpm-helper >= 0.24.8-1 Autoreq: true %description -n nscd Nscd caches name service lookups and can dramatically improve performance with NIS+, and may help with DNS as well. Install nscd if you need a name service lookup caching daemon. %package utils Summary: Development utilities from GNU C library Group: Development/Other Requires: %{name} = %{glibcepoch}:%{glibcversion}-%{glibcrelease} %description utils The glibc-utils package contains memusage, a memory usage profiler, mtrace, a memory leak tracer and xtrace, a function call tracer which can be helpful during program debugging. If unsure if you need this, don't install this package. %if %{build_i18ndata} %package i18ndata Summary: Database sources for 'locale' Group: System/Libraries %description i18ndata This package contains the data needed to build the locale data files to use the internationalization features of the GNU libc. %endif %if %{build_timezone} %package -n timezone Summary: Time zone descriptions Group: System/Base %description -n timezone These are configuration files that describe possible time zones. %endif ### glibc core "debuginfo and debugsource" sub-packages %if %{build_debug} %define debug_package %{nil} %define __debug_install_post %{nil} %global __debug_package 1 # Disable thew new features that glibc packages don't use. %undefine _debugsource_packages %undefine _debuginfo_subpackages %undefine _unique_debug_names %undefine _unique_debug_srcs %package debuginfo Summary: Debug information for package %{name} Group: Development/Debug AutoReqProv: no %description debuginfo This package provides debug information for package %{name}. Debug information is useful when developing applications that use this package or when debugging this package. %package debugsource Summary: Debug source for package %{name} Group: Development/Debug AutoReqProv: no %description debugsource This package provides debug source for %{name} %endif %package doc Summary: GNU C library documentation Group: Development/Other BuildArch: noarch %description doc The glibc-doc package contains documentation for the GNU C library in info format. %if %{build_pdf_doc} %package doc-pdf Summary: GNU C library documentation Group: Development/Other BuildArch: noarch %description doc-pdf The glibc-doc-pdf package contains the printable documentation for the GNU C library in PDF format. %endif %prep %setup -q -n %{source_dir} %autopatch -p1 %if %{build_selinux} # XXX kludge to build nscd with selinux support as it added -nostdinc # so /usr/include/selinux is not found ln -s %{_includedir}/selinux selinux %endif find . -type f -size 0 -o -name "*.orig" -exec rm -f {} \; # \\(Anssi 03/2008\\) FIXME: use __provides_exclude cat > find_provides.sh << EOF #!/bin/sh %{rpmscripts}/find-provides | grep -v GLIBC_PRIVATE exit 0 EOF chmod +x find_provides.sh cat > find_requires.bootstrap.sh << EOF /bin/sh %{SOURCE4} %{buildroot} %{_target_cpu} | grep -v "\(GLIBC_PRIVATE\|linux-gate\|linux-vdso\)" exit 0 EOF chmod +x find_requires.bootstrap.sh # XXX: use better way later to avoid LD_LIBRARY_PATH issue cat %{rpmscripts}/find-requires | sed '/.*LD_LIBRARY_PATH.*/d;' > find_requires chmod +x find_requires # \\(Anssi 03/2008\\) FIXME: use __requires_exclude cat > find_requires.noprivate.sh << EOF %{_builddir}/%{source_dir}/find_requires %{buildroot} %{_target_cpu} | \ grep -v GLIBC_PRIVATE exit 0 EOF chmod +x find_requires.noprivate.sh # FIXME: fix system rpm find-requires to use the prefix cross version %if %{build_bootstrap} || "%{_target_cpu}" != "%{target_cpu}" ln -s find_requires.bootstrap.sh find_requires.sh %else ln -s find_requires.noprivate.sh find_requires.sh %endif # Remove patch backups from files we ship in glibc packages rm -fr ChangeLog.old rm -f localedata/locales/{???_??,??_??}.* rm -f localedata/locales/[a-z_]*.* %build # Prepare test matrix in the next function CheckList=$PWD/Check.list rm -f $CheckList touch $CheckList # # CompareKver # function to compare the desired kernel version with running kernel # version (package releases not taken into account in comparison). The # function returns: # -1 = is lesser than current running kernel # 0 = is equal to the current running kernel # 1 = is greater than current running kernel # function CompareKver() { v1=`echo $1 | sed 's/\.\?$/./'` v2=`uname -r | sed 's/[^.0-9].*//' | sed 's/\.\?$/./'` n=1 s=0 while true; do c1=`echo "$v1" | cut -d "." -f $n` c2=`echo "$v2" | cut -d "." -f $n` if [ -z "$c1" -a -z "$c2" ]; then break elif [ -z "$c1" ]; then s=-1 break elif [ -z "$c2" ]; then s=1 break elif [ "$c1" -gt "$c2" ]; then s=1 break elif [ "$c2" -gt "$c1" ]; then s=-1 break fi n=$((n + 1)) done echo $s } # # BuildGlibc [+] # function BuildGlibc() { arch="$1" shift 1 # PowerPC CPU add-on case $arch in cpu-addon,*) cpu=` echo "$arch" | sed -n "/.*,\([^,]*\),.*$/s//\1/p"` arch=`echo "$arch" | sed -n "/.*,.*,\([^,]*\)$/s//\1/p"` ;; *) cpu=$arch ;; esac # Select optimization flags and compiler to use BuildAltArch="no" BuildCompFlags="" BuildFlags="" case $arch in i[3456]86 | athlon) BuildFlags="-march=$arch -mtune=generic" if [[ "`uname -m`" = "x86_64" ]]; then BuildAltArch="yes" BuildCompFlags="-m32" fi ;; x86_64) BuildFlags="-mtune=generic" ;; armv4t*) BuildFlags="-march=armv4t" BuildCompFlags="-march=armv4t" ;; armv5t*) BuildFlags="-march=armv5t" BuildCompFlags="-march=armv5t" ;; # to check armv7h*) BuildFlags="-march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard" BuildCompFlags="-march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard" ;; esac # Choose multiarch support MultiArchFlags= case $arch in i686 | x86_64) MultiArchFlags="--enable-multi-arch" ;; esac # Determine C & C++ compilers BuildCC="%{__cc} $BuildCompFlags" BuildCXX="%{__cxx} $BuildCompFlags" # Are we supposed to cross-compile? if [[ "%{target_cpu}" != "%{_target_cpu}" ]]; then # Can't use BuildCC anymore with previous changes. BuildCC="%{cross_program_prefix}gcc $BuildCompFlags" BuildCXX="%{cross_program_prefix}g++ $BuildCompFlags" BuildCross="--build=%{_target_platform}" export libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes fi BuildFlags="$BuildFlags -DNDEBUG=1 -O2 -finline-functions -g" # Do not use direct references against %gs when accessing tls data # XXX make it the default in GCC? (for other non glibc specific usage) case $arch in i[3456]86 | x86_64) BuildFlags="$BuildFlags -mno-tls-direct-seg-refs" ;; esac # Arch specific compilation flags if [[ "$arch" = "ppc64" ]]; then BuildFlags="$BuildFlags -fno-inline-functions -mno-minimal-toc" fi # Extra configure flags ExtraFlags= if [[ "%{build_profile}" != "0" ]]; then ExtraFlags="$ExtraFlags --enable-profile" fi # Enable CET if [[ "$arch" = "x86_64" ]]; then ExtraFlags="$ExtraFlags --enable-cet" fi # NPTL+TLS are now the default # check for other arches %if %isarch %ports_arch Pthreads="ports nptl" %else Pthreads="nptl" %endif # Add-ons AddOns="libidn" if [[ "$cpu" != "$arch" ]]; then AddOns="$AddOns,powerpc-cpu" BuildFlags="$BuildFlags -mcpu=$cpu" ExtraFlags="$ExtraFlags --with-cpu=$cpu" fi # Build with selinux support? %if %{build_selinux} SElinuxFlags="--with-selinux" %else SElinuxFlags="--without-selinux" %endif # Kernel headers directory KernelHeaders=%{_includedir} # Determine library name glibc_cv_cc_64bit_output=no if echo ".text" | $BuildCC -c -o test.o -xassembler -; then case `/usr/bin/file test.o` in *"ELF 64"*) glibc_cv_cc_64bit_output=yes ;; esac fi rm -f test.o # Force a separate and clean object dir rm -rf build-$cpu-linux mkdir build-$cpu-linux pushd build-$cpu-linux [[ "$BuildAltArch" = "yes" ]] && touch ".alt" || touch ".main" CC="$BuildCC" CXX="$BuildCXX" CFLAGS="$BuildFlags -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-function -Wno-maybe-uninitialized" ../configure \ $arch-%{_real_vendor}-linux%{gnuext} $BuildCross \ --prefix=%{_prefix} \ --libexecdir=%{_prefix}/libexec \ --infodir=%{_infodir} \ --enable-add-ons="$AddOns" --without-cvs \ $ExtraFlags $MultiArchFlags $SElinuxFlags \ --enable-bind-now \ --enable-stack-protector=strong \ --enable-fortify-source=%{_fortify_level} \ --enable-kernel=%{enablekernel} \ --with-headers=$KernelHeaders ${1+"$@"} \ --enable-systemtap \ --disable-crypt %make_build -r popd # All tests are expected to pass on certain platforms, depending also # on the version of the kernel running case $arch in athlon | ia64 | ppc | ppc64) if [ "`CompareKver %{check_min_kver}`" -lt 0 ]; then check_flags="" else check_flags="-k" fi ;; *) check_flags="-k" ;; esac # Generate test matrix [[ -d "build-$arch-linux" ]] || { echo "ERROR: PrepareGlibcTest: build-$arch-linux does not exist!" return 1 } local BuildJobs="-j`getconf _NPROCESSORS_ONLN`" echo "$BuildJobs -d build-$arch-linux $check_flags" >> $CheckList case $cpu in i686|athlon) base_arch=i686;; power*) base_arch=$arch;; *) base_arch=none;; esac [[ -d "build-$base_arch-linux" ]] && { check_flags="$check_flags -l build-$base_arch-linux/elf/ld.so" echo "$BuildJobs -d build-$arch-linux $check_flags" >> $CheckList } return 0 } # Build main glibc BuildGlibc %{target_cpu} %if %{build_biarch} %if %isarch x86_64 BuildGlibc i686 %endif %endif # Build i686 libraries if not already building for i686/athlon case %{target_cpu} in i686 | athlon) ;; i[3-6]86) # BuildGlibc i686 --disable-profile ;; esac %if %{build_check} export TMPDIR=/tmp export TIMEOUTFACTOR=16 Check="$PWD/glibc-check.sh" cat %{SOURCE5} > $Check chmod +x $Check while read arglist; do $Check $arglist || exit 1 done < $CheckList %endif %install # force use of _NPROCESSORS_ONLN jobs since RPM_BUILD_NCPUS could be # greater for icecream BuildJobs="-j`getconf _NPROCESSORS_ONLN`" make install_root=%{buildroot} install -C build-%{target_cpu}-linux %if %{build_i18ndata} (cd build-%{target_cpu}-linux; make $BuildJobs -C ../localedata objdir=`pwd` \ install_root=%{buildroot} \ install-C.UTF-8-locale-files ) install -pm 0644 localedata/SUPPORTED %{buildroot}/%{_datadir}/i18n/ %endif # Empty filelist for non i686/athlon targets > extralibs.filelist # Install biarch libraries %if %{build_biarch} %if %isarch x86_64 ALT_ARCHES=i686-linux %endif for ALT_ARCH in $ALT_ARCHES; do mkdir -p %{buildroot}/$ALT_ARCH make install_root=%{buildroot}/$ALT_ARCH install -C build-$ALT_ARCH # Dispatch */lib only LIB=/lib %if !%{build_cross} mv %{buildroot}/$ALT_ARCH/$LIB %{buildroot}/$LIB mv %{buildroot}/$ALT_ARCH%{_prefix}/libexec/getconf/* \ %{buildroot}%{_prefix}/libexec/getconf/ [ ! -d %{buildroot}/%{_prefix}/$LIB/ ] && mkdir -p %{buildroot}/%{_prefix}/$LIB/ mv %{buildroot}/$ALT_ARCH/%{_prefix}/$LIB/* %{buildroot}/%{_prefix}/$LIB/ %else mv %{buildroot}/$ALT_ARCH/%{_prefix}/lib %{buildroot}/$LIB sed -i %{buildroot}/$LIB/libc.so -e "s!%{_slibdir}!$LIB!g" %endif rm -rf %{buildroot}/$ALT_ARCH # XXX Dispatch 32-bit stubs (sed '/^@/d' include/stubs-prologue.h; LC_ALL=C sort $(find build-$ALT_ARCH -name stubs)) \ > %{buildroot}%{_includedir}/gnu/stubs-32.h done %endif # Install extra glibc libraries function InstallGlibc() { local BuildDir="$1" local SubDir="$2" local LibDir="$3" case $BuildDir in *) Pthreads=nptl ;; esac [[ -z "$LibDir" ]] && LibDir="%{_slibdir}" pushd $BuildDir mkdir -p %{buildroot}$LibDir/$SubDir/ install -m755 libc.so %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libc-*.so` ln -sf `basename %{buildroot}$LibDir/libc-*.so` %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libc.so.*` install -m755 math/libm.so %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libm-*.so` ln -sf `basename %{buildroot}$LibDir/libm-*.so` %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libm.so.*` install -m755 $Pthreads/libpthread.so %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libpthread-*.so` ln -sf `basename %{buildroot}$LibDir/libpthread-*.so` %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libpthread.so.*` install -m755 ${Pthreads}_db/libthread_db.so %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libthread_db-*.so` ln -sf `basename %{buildroot}$LibDir/libthread_db-*.so` %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/libthread_db.so.*` install -m755 rt/librt.so %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/librt-*.so` ln -sf `basename %{buildroot}$LibDir/librt-*.so` %{buildroot}$LibDir/$SubDir/`basename %{buildroot}$LibDir/librt.so.*` echo "%dir $LibDir/$SubDir" >> ../extralibs.filelist find %{buildroot}$LibDir/$SubDir -maxdepth 1 -type f -o -type l | sed -e "s|%{buildroot}||" >> ../extralibs.filelist popd } # Install arch-specific optimized libraries %if %isarch %{ix86} case %{target_cpu} in i[3-5]86) # InstallGlibc build-i686-linux i686 ;; esac %endif # Remove the files we don't want to distribute rm -f %{buildroot}%{_libdir}/libNoVersion* rm -f %{buildroot}%{_slibdir}/libNoVersion* %if "%{name}" == "glibc" install -m 644 %{SOURCE8} %{buildroot}%{_sysconfdir}/nsswitch.conf %endif # This is for ncsd - in glibc 2.2 %if %{build_nscd} install -m 644 nscd/nscd.conf %{buildroot}%{_sysconfdir} install -d -m 755 %{buildroot}%{_unitdir} install -m 644 %{SOURCE6} %{buildroot}%{_unitdir}/nscd.service install -m 644 %{SOURCE7} %{buildroot}%{_unitdir}/nscd.socket install -D -m 644 %{SOURCE9} %{buildroot}%{_tmpfilesdir}/nscd.conf install -d -m 755 %{buildroot}%{_var}/db/nscd %endif # Useless and takes place rm -rf %buildroot/%{_datadir}/zoneinfo/{posix,right} # Include ld.so.conf %if "%{name}" == "glibc" echo "include /etc/ld.so.conf.d/*.conf" > %{buildroot}%{_sysconfdir}/ld.so.conf chmod 644 %{buildroot}%{_sysconfdir}/ld.so.conf mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d # ldconfig cache mkdir -p %{buildroot}%{_var}/cache/ldconfig touch %{buildroot}%{_var}/cache/ldconfig/aux-cache %endif # Include %{_libdir}/gconv/gconv-modules.cache > %{buildroot}%{_libdir}/gconv/gconv-modules.cache chmod 644 %{buildroot}%{_libdir}/gconv/gconv-modules.cache %if "%{name}" == "glibc" touch %{buildroot}%{_sysconfdir}/ld.so.cache %endif # Are we cross-compiling? Strip="strip" if [[ "%{_target_cpu}" != "%{target_cpu}" ]]; then Strip="%{cross_program_prefix}$Strip" fi # Strip debugging info from all static libraries pushd %{buildroot}%{_slibdir} for i in *.a; do if [ -f "$i" ]; then case "$i" in *_p.a) ;; *) $Strip -g -R .comment $i ;; esac fi done popd pushd %{buildroot}%{_libdir} for i in libc_nonshared.a; do if [ -f "$i" ]; then $Strip -g -R .comment $i fi done popd # rquota.x and rquota.h are now provided by quota rm -f %{buildroot}%{_includedir}/rpcsvc/rquota.[hx] # Hardlink identical locale files together %if %{build_i18ndata} %{_bindir}/hardlink -vc %{buildroot}%{_datadir}/locale %endif rm -rf %{buildroot}%{_includedir}/netatalk/ # nuke libc_malloc_debug %if %{build_biarch} rm -f %{buildroot}%{_prefix}/lib/libc_malloc_debug.so %endif rm -f %{buildroot}%{_libdir}/libc_malloc_debug.so # Build file list for devel package find %{buildroot}%{_includedir} -type f -or -type l > devel.filelist find %{buildroot}%{_includedir} -type d | sed "s/^/%dir /" | \ grep -v "%{_libdir}/libnss1.*.so$" | \ grep -v "%{_includedir}$" | >> devel.filelist find %{buildroot}%{_libdir} -maxdepth 1 -name "*.so" -o -name "*.o" | egrep -v "(libmemusage.so|libpcprofile.so)" >> devel.filelist # biarch libs %if %{build_biarch} find %{buildroot}%{_prefix}/lib -maxdepth 1 -name "*.so" -o -name "*.o" | egrep -v "(libmemusage.so|libpcprofile.so)" >> devel.filelist %endif perl -pi -e "s|%{buildroot}||" devel.filelist # /etc/localtime - we're proud of our timezone #Well we may put Paris %if %{build_timezone} rm -f %{buildroot}%{_sysconfdir}/localtime cp -f %{buildroot}%{_datadir}/zoneinfo/US/Eastern %{buildroot}%{_sysconfdir}/localtime #ln -sf ..%{_datadir}/zoneinfo/US/Eastern %{buildroot}%{_sysconfdir}/localtime %endif # [gg] build PDF documentation %if %{build_pdf_doc} (cd manual; texi2dvi -p -t @afourpaper -t @finalout libc.texinfo) %endif # Leave a compatibility symlink for the dynamic loader on armhfp targets, # at least until the world gets rebuilt %ifarch armv7hl ln -sf %{_slibdir}/ld-linux-armhf.so.3 %{buildroot}%{_slibdir}/ld-linux.so.3 %endif # Generate final rpm filelist, with localized libc.mo files rm -f rpm.filelist %if "%{name}" == "glibc" %find_lang libc perl -ne '/^\s*$/ or print' libc.lang > rpm.filelist %endif cat extralibs.filelist >> rpm.filelist # Remove unpackaged files rm -f %{buildroot}%{_infodir}/dir.old* rm -rf %{buildroot}%{_includedir}/asm-*/mach-*/ rm -f %{buildroot}%{_datadir}/locale/locale-archive* rm -f %{buildroot}%{_var}/db/Makefile %if !%{build_utils} %if %{build_biarch} rm -f %{buildroot}%{_slibdir32}/libmemusage.so rm -f %{buildroot}%{_slibdir32}/libpcprofile.so %endif rm -f %{buildroot}%{_slibdir}/libmemusage.so rm -f %{buildroot}%{_slibdir}/libpcprofile.so rm -f %{buildroot}%{_bindir}/memusage rm -f %{buildroot}%{_bindir}/memusagestat rm -f %{buildroot}%{_bindir}/mtrace rm -f %{buildroot}%{_bindir}/pcprofiledump rm -f %{buildroot}%{_bindir}/xtrace %endif %if !%{build_timezone} rm -f %{buildroot}%{_sysconfdir}/localtime rm -f %{buildroot}%{_bindir}/zdump rm -f %{buildroot}%{_sbindir}/zic rm -rf %{buildroot}%{_datadir}/zoneinfo %endif %if !%{build_i18ndata} rm -rf %{buildroot}%{_datadir}/i18n %endif %if "%{name}" != "glibc" rm -rf %{buildroot}/boot rm -rf %{buildroot}/sbin rm -rf %{buildroot}/usr/share rm -rf %{buildroot}%{_bindir} rm -rf %{buildroot}%{_sbindir} rm -rf %{buildroot}%{_datadir} rm -rf %{buildroot}%{_infodir} rm -rf %{buildroot}%{_prefix}/etc rm -rf %{buildroot}%{_libdir}/gconv %endif # In case we are cross-compiling, don't bother to remake symlinks and # fool spec-helper when stripping files %if "%{name}" != "glibc" export DONT_SYMLINK_LIBS=1 export PATH=%{_bindir}:$PATH %endif # This will make the '-g' argument to be passed to eu-strip for these # libraries, so that only debug symbols are stripped and gdb/valgrind continue # to work without needing glibc-debug package to be installed. export EXCLUDE_FROM_FULL_STRIP="ld-%{glibcversion}.so libpthread libc-%{glibcversion}.so" # If we are building a debug package then copy all of the static archives # into the debug directory to keep them as unstripped copies. %if %{build_debug} mkdir -p %{buildroot}%{_prefix}/lib/debug%{_libdir} cp -a %{buildroot}%{_libdir}/*.a \ %{buildroot}%{_prefix}/lib/debug%{_libdir}/ rm -f %{buildroot}%{_prefix}/lib/debug%{_libdir}/*_p.a %endif # Strip all of the installed object files. strip -g %{buildroot}%{_libdir}/*.o find_debuginfo_args='--strict-build-id -g -i' /usr/bin/find-debuginfo.sh $find_debuginfo_args -o debuginfo.filelist # List all of the *.a archives in the debug directory. list_debug_archives() { local dir=%{_prefix}/lib/debug%{_libdir} find %{buildroot}$dir -name "*.a" -printf "$dir/%%P\n" } # Remove some common directories from the common package debuginfo so that we # don't end up owning them. exclude_common_dirs() { exclude_dirs="%{_prefix}/src/debug" exclude_dirs="$exclude_dirs $(echo %{_prefix}/lib/debug{,/%{_lib},/bin,/sbin})" exclude_dirs="$exclude_dirs $(echo %{_prefix}/lib/debug%{_prefix}{,/%{_lib},/libexec,/bin,/sbin})" for d in $(echo $exclude_dirs | sed 's/ /\n/g'); do sed -i "\|^%%dir $d/\?$|d" $1 done } exclude_common_dirs debuginfo.filelist # remove debug source dir sed -i 's/\%{_prefix}\/src\/debug\/%{name}-%{version}//' debuginfo.filelist %if "%{name}" == "glibc" %post -p %glibc_post_funcs -- (1) Remove multilib libraries from previous installs. -- In order to support in-place upgrades, we must immediately remove -- obsolete platform directories after installing a new glibc -- version. RPM only deletes files removed by updates near the end -- of the transaction. If we did not remove the obsolete platform -- directories here, they may be preferred by the dynamic linker -- during the execution of subsequent RPM scriptlets, likely -- resulting in process startup failures. -- Full set of libraries glibc may install. install_libs = { "anl", "BrokenLocale", "c", "dl", "m", "mvec", "nss_compat", "nss_db", "nss_dns", "nss_files", "nss_hesiod", "pthread", "resolv", "rt", "SegFault", "thread_db", "util" } -- We are going to remove these libraries. Generally speaking we remove -- all core libraries in the multilib directory. -- For the versioned install names, the version are [2.0,9.9*], so we -- match "libc-2.0.so" and so on up to "libc-9.9*". -- For the unversioned install names, we match the library plus ".so." -- followed by digests. remove_regexps = {} for i = 1, #install_libs do -- Versioned install name. remove_regexps[#remove_regexps + 1] = ("lib" .. install_libs[i] .. "%%-[2-9]%%.[0-9]+%%.so$") -- Unversioned install name. remove_regexps[#remove_regexps + 1] = ("lib" .. install_libs[i] .. "%%.so%%.[0-9]+$") end -- Two exceptions: remove_regexps[#install_libs + 1] = "libthread_db%%-1%%.0%%.so" remove_regexps[#install_libs + 2] = "libSegFault%%.so" -- We are going to search these directories. local remove_dirs = { "%{_libdir}/i686", } -- Add all the subdirectories of the glibc-hwcaps subdirectory. repeat local iter = posix.files("%{_libdir}/glibc-hwcaps") if iter ~= nil then for entry in iter do if entry ~= "." and entry ~= ".." then local path = "%{_libdir}/glibc-hwcaps/" .. entry if posix.access(path .. "/.", "x") then remove_dirs[#remove_dirs + 1] = path end end end end until true -- Walk all the directories with files we need to remove... for _, rdir in ipairs (remove_dirs) do if posix.access (rdir) then -- If the directory exists we look at all the files... local remove_files = posix.files (rdir) for rfile in remove_files do for _, rregexp in ipairs (remove_regexps) do -- Does it match the regexp? local dso = string.match (rfile, rregexp) if (dso ~= nil) then -- Removing file... os.remove (rdir .. '/' .. rfile) end end end end end -- (2) Update /etc/ld.so.conf -- Next we update /etc/ld.so.conf to ensure that it starts with -- a literal "include ld.so.conf.d/*.conf". local ldsoconf = "/etc/ld.so.conf" local ldsoconf_tmp = "/etc/glibc_post_upgrade.ld.so.conf" if posix.access (ldsoconf) then -- We must have a "include ld.so.conf.d/*.conf" line. local have_include = false for line in io.lines (ldsoconf) do -- This must match, and we don't ignore whitespace. if string.match (line, "^include ld.so.conf.d/%%*%%.conf$") ~= nil then have_include = true end end if not have_include then -- Insert "include ld.so.conf.d/*.conf" line at the start of the -- file. We only support one of these post upgrades running at -- a time (temporary file name is fixed). local tmp_fd = io.open (ldsoconf_tmp, "w") if tmp_fd ~= nil then tmp_fd:write ("include ld.so.conf.d/*.conf\n") for line in io.lines (ldsoconf) do tmp_fd:write (line .. "\n") end tmp_fd:close () local res = os.rename (ldsoconf_tmp, ldsoconf) if res == nil then io.stdout:write ("Error: Unable to update configuration file (rename).\n") end else io.stdout:write ("Error: Unable to update configuration file (open).\n") end end end -- (3) Rebuild ld.so.cache early. -- If the format of the cache changes then we need to rebuild -- the cache early to avoid any problems running binaries with -- the new glibc. -- Note: We use _prefix because Fedora's UsrMove says so. post_exec ("%{_prefix}/sbin/ldconfig") -- (4) Update gconv modules cache. -- If the /usr/lib/gconv/gconv-modules.cache exists, then update it -- with the latest set of modules that were just installed. -- We assume that the cache is in _libdir/gconv and called -- "gconv-modules.cache". update_gconv_modules_cache() -- (5) On upgrades, restart systemd if installed. "systemctl -q" does -- not suppress the error message (which is common in chroots), so -- open-code post_exec with standard error suppressed. if tonumber(arg[2]) >= 2 and posix.access("%{_prefix}/bin/systemctl", "x") then local pid = posix.fork() if pid == 0 then posix.redirect2null(2) assert(posix.exec("%{_prefix}/bin/systemctl", "daemon-reexec")) elseif pid > 0 then posix.wait(pid) end end %transfiletriggerin -p %{ash_bin} -P 2000000 -- /lib /usr/lib /lib64 /usr/lib64 ldconfig -X %transfiletriggerin -p %{ash_bin} -P 2000000 -- /etc/ld.so.conf.d/ ldconfig -X %transfiletriggerpostun -p %{ash_bin} -P 2000000 -- /lib /usr/lib /lib64 /usr/lib64 ldconfig -X %endif %if %{build_nscd} %pre -n nscd %_pre_useradd nscd / /bin/false %post -n nscd %_tmpfilescreate nscd %_post_service nscd %preun -n nscd %_preun_service nscd %postun -n nscd %_postun_userdel nscd if [ "$1" -ge "1" ]; then /sbin/service nscd condrestart > /dev/null 2>&1 || : fi %endif # # glibc # %files -f rpm.filelist %if "%{name}" == "glibc" %if %{build_timezone} %verify(not md5 size mtime) %config(noreplace) %{_sysconfdir}/localtime %endif %verify(not md5 size mtime) %config(noreplace) %{_sysconfdir}/nsswitch.conf %verify(not md5 size mtime) %config(noreplace) %{_sysconfdir}/ld.so.conf %dir %{_sysconfdir}/ld.so.conf.d %config(noreplace) %{_sysconfdir}/rpc #doc nis/nss %doc posix/gai.conf %{_datadir}/locale/C.UTF-8/ %{_datadir}/locale/locale.alias /sbin/sln %dir %{_prefix}/libexec/getconf %{_prefix}/libexec/getconf/* %endif %if %isarch i386 %{_slibdir}/ld-linux.so.2 %endif %if %isarch %arm %if %isarch armv7hl %{_slibdir}/ld-linux-armhf.so.3 %endif %{_slibdir}/ld-linux.so.3 %endif %if %isarch x86_64 %{_slibdir}/ld-linux-x86-64.so.2 %endif %{_slibdir}/lib*.so.[0-9]* %if "%{name}" == "glibc" %dir %{_libdir}/audit %{_libdir}/audit/sotruss-lib.so %dir %{_libdir}/gconv %dir %{_libdir}/gconv/gconv-modules.d %{_libdir}/gconv/gconv-modules.d/gconv-modules-extra.conf %{_libdir}/gconv/*.so %{_libdir}/gconv/gconv-modules %ghost %{_libdir}/gconv/gconv-modules.cache %{_bindir}/gencat %{_bindir}/getconf %{_bindir}/getent %{_bindir}/iconv %{_bindir}/ld.so %{_bindir}/ldd %if %isarch i386 #%%{_bindir}/lddlibc4 %endif %{_bindir}/locale %{_bindir}/localedef %{_bindir}/makedb %{_bindir}/pldd %{_bindir}/sotruss %{_bindir}/sprof %{_bindir}/tzselect %{_sbindir}/iconvconfig %endif %if %isarch aarch64 %{_slibdir32}/ld-linux-aarch64.so.1 %endif %if %{build_biarch} %{_slibdir32}/ld-linux*.so.2 %{_slibdir32}/lib*.so.[0-9]* %dir %{_prefix}/lib/audit %{_prefix}/lib/audit/sotruss-lib.so %dir %{_prefix}/lib/gconv %{_prefix}/lib/gconv/* %endif # # ldconfig # %if "%{name}" == "glibc" /sbin/ldconfig %ghost %{_sysconfdir}/ld.so.cache %dir %{_var}/cache/ldconfig %ghost %{_var}/cache/ldconfig/aux-cache %endif # # glibc-devel # %files devel -f devel.filelist %doc README NEWS INSTALL # (tmb) FIXME, figure out rpm doc breakage/change #doc COPYING COPYING.LIB #doc documentation/* #doc hesiod/README.hesiod #doc crypt/README.ufc-crypt %{_libdir}/libanl.a %{_libdir}/libc_nonshared.a %{_libdir}/libdl.a %{_libdir}/libg.a %{_libdir}/libmcheck.a %{_libdir}/libpthread.a %{_libdir}/librt.a %{_libdir}/libutil.a %if %isarch x86_64 %{arm64} %{_libdir}/libm-%{glibcversion}.a %{_libdir}/libmvec.a %endif %if %{build_biarch} %{_prefix}/lib/libanl.a %{_prefix}/lib/libc_nonshared.a %{_prefix}/lib/libdl.a %{_prefix}/lib/libg.a %{_prefix}/lib/libmcheck.a %{_prefix}/lib/libpthread.a %{_prefix}/lib/librt.a %{_prefix}/lib/libutil.a %endif # # glibc-static-devel # %files static-devel %doc COPYING COPYING.LIB %{_libdir}/libBrokenLocale.a %{_libdir}/libc.a %{_libdir}/libm.a %{_libdir}/libresolv.a %if %{build_biarch} %{_prefix}/lib/libBrokenLocale.a %{_prefix}/lib/libc.a %{_prefix}/lib/libm.a %{_prefix}/lib/libresolv.a %endif # # glibc-doc # %if %{build_doc} %files doc %{_infodir}/libc.info* %endif # # glibc-doc-pdf # %if %{build_pdf_doc} %files doc-pdf %doc manual/libc.pdf %endif # # glibc-profile # %if %{build_profile} %files profile %{_libdir}/lib*_p.a %if %{build_biarch} %{_prefix}/lib/lib*_p.a %endif %endif # # glibc-utils # %if %{build_utils} %files utils %if %{build_biarch} %{_slibdir32}/libmemusage.so %{_slibdir32}/libpcprofile.so %endif %{_slibdir}/libmemusage.so %{_slibdir}/libpcprofile.so %{_bindir}/memusage %{_bindir}/memusagestat %{_bindir}/mtrace %{_bindir}/pcprofiledump %{_bindir}/xtrace %endif # # nscd # %if %{build_nscd} %files -n nscd %config(noreplace) %{_sysconfdir}/nscd.conf %{_sbindir}/nscd %{_unitdir}/nscd.service %{_unitdir}/nscd.socket %{_tmpfilesdir}/nscd.conf %dir %{_var}/db/nscd %endif # # timezone # %if %{build_timezone} %files -n timezone %{_sbindir}/zdump %{_sbindir}/zic %dir %{_datadir}/zoneinfo %{_datadir}/zoneinfo/* %endif # # glibc-i18ndata # %if %{build_i18ndata} %files i18ndata %dir %{_datadir}/i18n %dir %{_datadir}/i18n/charmaps %{_datadir}/i18n/charmaps/* %dir %{_datadir}/i18n/locales %{_datadir}/i18n/locales/* %{_datadir}/i18n/SUPPORTED %endif %if %{build_debug} %files debuginfo -f debuginfo.filelist %files debugsource %dir %{_prefix}/src/debug/%{name}-%{version} %{_prefix}/src/debug/%{name}-%{version}/* %endif