diff --git a/glibc.spec b/glibc.spec index 24c9a3e..c7bda41 100644 --- a/glibc.spec +++ b/glibc.spec @@ -148,7 +148,7 @@ end \ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 51%{?dist} +Release: 52%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -203,6 +203,19 @@ rpm.define("__debug_install_post bash " .. wrapper .. " " .. sysroot .. " " .. original) } +# sysroot package support. These contain arch-specific packages, so +# turn off the rpmbuild check. +%global _binaries_in_noarch_packages_terminate_build 0 +# Variant of %%dist that contains just the distribution release, no affixes. +%{?fedora:%global sysroot_dist fc%{fedora}} +%{?rhel:%global sysroot_dist el%{rhel}} +%{?!sysroot_dist:%global sysroot_dist root} +# The name of the sysroot package. +%global sysroot_package_arch sysroot-%{_arch}-%{sysroot_dist}-%{name} +# Installed path for the sysroot tree. Must contain /sys-root/, which +# triggers filtering. +%global sysroot_prefix /usr/%{_arch}-redhat-linux/sys-root/%{sysroot_dist} + # The wrapper script relies on the fact that debugedit does not change # build IDs. %define _no_recompute_build_ids 1 @@ -1456,6 +1469,21 @@ libpthread_nonshared.a which is no longer used. The static library libpthread_nonshared.a is an internal implementation detail of the C runtime and should not be expected to exist. +%if %{without bootstrap} +%package -n %sysroot_package_arch +Summary: Sysroot package for glibc, %{_arch} architecture +BuildArch: noarch +Provides: sysroot-%{_arch}-%{name} +# The files are not usable for execution, so do not provide nor +# require anything. +AutoReqProv: no + +%description -n %sysroot_package_arch +This package contains development files for the glibc package +that can be installed across architectures. +%dnl %%{without bootstrap} +%endif + ############################################################################## # Prepare for the build. ############################################################################## @@ -1961,6 +1989,53 @@ done ############################################################################## ar cr %{glibc_sysroot}%{_prefix}/%{_lib}/libpthread_nonshared.a +############################################################################### +# Sysroot package creation. +############################################################################### + +%if %{without bootstrap} +mkdir -p %{glibc_sysroot}/%{sysroot_prefix} +pushd %{glibc_sysroot}/%{sysroot_prefix} +mkdir -p usr/lib usr/lib64 + +cp -a %{glibc_sysroot}/%{_prefix}/include usr/. +for lib in lib lib64; do + for pfx in "" %{_prefix}/; do + if test -d %{glibc_sysroot}/$pfx$lib ; then + # Implement UsrMove: everything goes into usr/$lib. Only + # copy files directly in $lib. + find %{glibc_sysroot}/$pfx$lib -maxdepth 1 -type f \ + | xargs -I '{}' cp '{}' usr/$lib/. + # Symbolic links need to be adjusted for UsrMove: They + # need to stay within the same directory. + for sl in `find %{glibc_sysroot}/$pfx$lib -maxdepth 1 -type l`; do + set +x + slbase=$(basename $sl) + sltarget=$(basename $(readlink $sl)) + if ! test -r usr/$lib/$sltarget; then + echo "$sl: inferred $sltarget ($(readlink $sl)) missing" + exit 1 + fi + set -x + ln -s $sltarget usr/$lib/$slbase + done + fi + done +done + +# Remove the executable bit from files in the sysroot. This prevents +# debuginfo extraction. +find -type f | xargs chmod a-x + +# Use sysroot-relative paths in linker script. Ignore symbolic links. +sed -e 's,\([^0-9a-zA-Z=*]/lib\),=/usr/lib,g' \ + -e 's,\([^0-9a-zA-Z=*]\)/,\1=/,g' \ + -i $(find -type f -name 'lib[cm].so') + +popd +%dnl %%{without bootstrap} +%endif + ############################################################################## # Beyond this point in the install process we no longer modify the set of # installed files. @@ -2049,13 +2124,14 @@ touch compat-libpthread-nonshared.filelist # language specific sub-packages. # libnss_ files go into subpackages related to NSS modules. # and .*/share/i18n/charmaps/.*), they go into the sub-package - # "locale-source": + # "locale-source". /sys-root/ files are put into the sysroot package. sed -e '\,.*/share/locale/\([^/_]\+\).*/LC_MESSAGES/.*\.mo,d' \ -e '\,.*/share/i18n/locales/.*,d' \ -e '\,.*/share/i18n/charmaps/.*,d' \ -e '\,.*/etc/\(localtime\|nsswitch.conf\|ld\.so\.conf\|ld\.so\.cache\|default\|rpc\|gai\.conf\),d' \ -e '\,.*/%{_libdir}/lib\(pcprofile\|memusage\)\.so,d' \ - -e '\,.*/bin/\(memusage\|mtrace\|xtrace\|pcprofiledump\),d' + -e '\,.*/bin/\(memusage\|mtrace\|xtrace\|pcprofiledump\),d' \ + -e '\,.*/sys-root,d' } | sort > master.filelist # The master file list is now used by each subpackage to list their own @@ -2390,8 +2466,9 @@ echo ====================PLT RELOCS END================== # Obtain a way to run the dynamic loader. Avoid matching the symbolic # link and then pick the first loader (although there should be only -# one). See wrap-find-debuginfo.sh. -ldso_path="$(find %{glibc_sysroot}/ -regextype posix-extended \ +# one). Use -maxdepth 2 to avoid descending into the /sys-root/ +# sub-tree. See wrap-find-debuginfo.sh. +ldso_path="$(find %{glibc_sysroot}/ -maxdepth 2 -regextype posix-extended \ -regex '.*/ld(-.*|64|)\.so\.[0-9]+$' -type f | LC_ALL=C sort | head -n1)" run_ldso="$ldso_path --library-path %{glibc_sysroot}/%{_lib}" @@ -2710,7 +2787,15 @@ fi %files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared +%if %{without bootstrap} +%files -n sysroot-%{_arch}-%{sysroot_dist}-glibc +%{sysroot_prefix} +%endif + %changelog +* Wed Nov 30 2022 Florian Weimer - 2.34-52 +- Add noarch sysroot subpackages (#2149644) + * Tue Nov 29 2022 Florian Weimer - 2.34-51 - Prepare for integration of GCC 8 compatible _Static_assert (#2149102) diff --git a/wrap-find-debuginfo.sh b/wrap-find-debuginfo.sh index 38c27d0..f48c1cf 100644 --- a/wrap-find-debuginfo.sh +++ b/wrap-find-debuginfo.sh @@ -39,8 +39,8 @@ shift # See ldso_path setting in glibc.spec. ldso_path= -for ldso_candidate in `find "$sysroot_path" -regextype posix-extended \ - -regex '.*/ld(-.*|64|)\.so\.[0-9]+$' -type f` ; do +for ldso_candidate in `find "$sysroot_path" -maxdepth 2 \ + -regextype posix-extended -regex '.*/ld(-.*|64|)\.so\.[0-9]+$' -type f` ; do if test -z "$ldso_path" ; then ldso_path="$ldso_candidate" else @@ -51,7 +51,7 @@ done # libc.so.6 always uses this name, so it is simpler to locate. libc_path= -for libc_candidate in `find "$sysroot_path" -name libc.so.6`; do +for libc_candidate in `find "$sysroot_path" -maxdepth 2 -name libc.so.6`; do if test -z "$libc_path" ; then libc_path="$libc_candidate" else @@ -86,7 +86,8 @@ objcopy --add-section .gnu_debuglink="$libc_tmp.debuglink" "$libc_path" # ld.so does not have separated debuginfo and so the debuginfo file # generated by find-debuginfo is redundant. Therefore, remove it. ldso_debug= -for ldso_debug_candidate in `find "$sysroot_path" -regextype posix-extended \ +for ldso_debug_candidate in `find "$sysroot_path" -maxdepth 2 \ + -regextype posix-extended \ -regex '.*/ld(-.*|64|)\.so\.[0-9]+.*debug$' -type f` ; do if test -z "$ldso_debug" ; then ldso_debug="$ldso_debug_candidate"