From 700394c8ed3c3db06fe2c3b4667a33896d3b1e74 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Sun, 27 Jun 2021 15:06:13 +0200 Subject: [PATCH] Add automatic requires if building against glibc development snapshots --- glibc.attr | 3 +++ glibc.req.in | 40 ++++++++++++++++++++++++++++++++++++++++ glibc.spec | 37 +++++++++++++++++++++++++++++++++++-- 3 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 glibc.attr create mode 100644 glibc.req.in diff --git a/glibc.attr b/glibc.attr new file mode 100644 index 0000000..fddfd91 --- /dev/null +++ b/glibc.attr @@ -0,0 +1,3 @@ +%__glibc_requires %{_rpmconfigdir}/glibc.req +%__glibc_magic ELF +%__glibc_flags exeonly diff --git a/glibc.req.in b/glibc.req.in new file mode 100644 index 0000000..3f922d1 --- /dev/null +++ b/glibc.req.in @@ -0,0 +1,40 @@ +#!/bin/bash +# Auto-generating dependencies for glibc development snapshots. +# +# A glibc development snapshot (say version 2.33.9000) may define +# symbols in its under-development symbol version (GLIBC_2.34). RPM +# automatically derives RPM dependencies such as +# libc.so.6(GLIBC_2.34)(64bit) from that. While the GLIBC_2.34 +# version is under development, these dependencies may be inaccurate +# and could be satisfied by glibc RPM package versions that lack the +# symbols because they were created from an earlier development +# snapshot that had some other GLIBC_2.34 symbols. Therefore, if the +# latest, under-development ELF symbol version is detected, this +# dependency generator adds an explicit RPM dependencies on the glibc +# packaging version against which an RPM package is built. +# +# This script runs for the glibc build itself. In this case, it may +# produce a >= dependency on the build-time glibc, but there will also +# be an (potentially indirect) = dependency, which takes precedence. + +set -e +set -o pipefail + +searching=true +# Pre-filter using eu-elfclassify, to skip kernel modules. +eu-elfclassify --loadable --file --stdin --print | while read path; do + # Assume that all dynamically linked objects depend on glibc in + # some way. + if $searching; then + # Undefined symbols within latest, under-development + # (changing) symbol versions trigger the versioned RPM + # dependency. + if eu-readelf -s "$path" | egrep -q '\sUNDEF\s.*@''@SYMVER@(\s|$)' + then + echo 'glibc >= @VERSION@-@RELEASE@' + # Stop searching after the first match, but keep reading from + # the pipe. + searching=false + fi + fi +done diff --git a/glibc.spec b/glibc.spec index 07018c4..5568230 100644 --- a/glibc.spec +++ b/glibc.spec @@ -8,8 +8,22 @@ # gzip -9 $(git describe --match 'glibc-*').tar # # glibc_release_url is only defined when we have a release tarball. +# Conversly, glibc_autorequires is set for development snapshots, where +# dependencies based on symbol versions are inaccurate. %{lua: if string.match(rpm.expand("%glibcsrcdir"), "^glibc%-[0-9.]+$") then - rpm.define("glibc_release_url https://ftp.gnu.org/gnu/glibc/") end} + rpm.define("glibc_release_url https://ftp.gnu.org/gnu/glibc/") + end + local major, minor = string.match(rpm.expand("%glibcversion"), + "^([0-9]+)%.([0-9]+)%.9000$") + if major and minor then + rpm.define("glibc_autorequires 1") + -- The minor version in a .9000 development version lags the actual + -- symbol version by one. + local symver = "GLIBC_" .. major .. "." .. (minor + 1) + rpm.define("glibc_autorequires_symver " .. symver) + else + rpm.define("glibc_autorequires 0") + end} ############################################################################## # We support the following options: # --with/--without, @@ -97,7 +111,7 @@ Summary: The GNU libc libraries Name: glibc Version: %{glibcversion} -Release: 25%{?dist} +Release: 26%{?dist} # In general, GPLv2+ is used by programs, LGPLv2+ is used for # libraries. @@ -131,6 +145,8 @@ Source0: %{?glibc_release_url}%{glibcsrcdir}.tar.xz Source1: nscd.conf Source2: bench.mk Source3: glibc-bench-compare +Source4: glibc.req.in +Source5: glibc.attr Source10: wrap-find-debuginfo.sh Source11: parse-SUPPORTED.py # Include in the source RPM for reference. @@ -1660,6 +1676,16 @@ sed -i -e '\,libmemusage.so,d' \ -e '\,/libnss_[a-z]*\.so$,d' \ devel.filelist +%if %{glibc_autorequires} +mkdir -p %{glibc_sysroot}/%{_rpmconfigdir} %{glibc_sysroot}/%{_fileattrsdir} +sed < %{SOURCE4} \ + -e s/@VERSION@/%{version}/ \ + -e s/@RELEASE@/%{release}/ \ + -e s/@SYMVER@/%{glibc_autorequires_symver}/ \ + > %{glibc_sysroot}/%{_rpmconfigdir}/glibc.req +cp %{SOURCE5} %{glibc_sysroot}/%{_fileattrsdir}/glibc.attr +%endif + ############################################################################### # glibc-doc ############################################################################### @@ -2133,6 +2159,10 @@ fi %{_prefix}/share/i18n/charmaps/* %files -f devel.filelist devel +%if %{glibc_autorequires} +%attr(0755,root,root) %{_rpmconfigdir}/glibc.req +%{_fileattrsdir}/glibc.attr +%endif %if %{with docs} %files -f doc.filelist doc @@ -2183,6 +2213,9 @@ fi %files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared %changelog +* Sun Jun 27 2021 Florian Weimer - 2.33.9000-26 +- Add automatic requires if building against glibc development snapshots + * Thu Jun 24 2021 Carlos O'Donell - 2.33.9000-25 - Fix thread local storage corruption (#1974970)