700394c
#!/bin/bash
700394c
# Auto-generating dependencies for glibc development snapshots.
700394c
#
700394c
# A glibc development snapshot (say version 2.33.9000) may define
700394c
# symbols in its under-development symbol version (GLIBC_2.34).  RPM
700394c
# automatically derives RPM dependencies such as
700394c
# libc.so.6(GLIBC_2.34)(64bit) from that.  While the GLIBC_2.34
700394c
# version is under development, these dependencies may be inaccurate
700394c
# and could be satisfied by glibc RPM package versions that lack the
700394c
# symbols because they were created from an earlier development
700394c
# snapshot that had some other GLIBC_2.34 symbols.  Therefore, if the
700394c
# latest, under-development ELF symbol version is detected, this
700394c
# dependency generator adds an explicit RPM dependencies on the glibc
700394c
# packaging version against which an RPM package is built.
700394c
#
700394c
# This script runs for the glibc build itself.  In this case, it may
700394c
# produce a >= dependency on the build-time glibc, but there will also
700394c
# be an (potentially indirect) = dependency, which takes precedence.
700394c
700394c
set -e
700394c
set -o pipefail
700394c
700394c
searching=true
700394c
# Pre-filter using eu-elfclassify, to skip kernel modules.
700394c
eu-elfclassify --loadable --file --stdin --print | while read path; do
700394c
    # Assume that all dynamically linked objects depend on glibc in
700394c
    # some way.
700394c
    if $searching; then
700394c
	# Undefined symbols within latest, under-development
700394c
	# (changing) symbol versions trigger the versioned RPM
5c27a70
	# dependency.  Do not use "grep -Eq" to keep reading from the
8142038
	# pipe, avoiding a spurious EPIPE error in eu-readelf.
8142038
	if eu-readelf -s "$path" \
5c27a70
		| grep -E '\sUNDEF\s.*@''@SYMVER@(\s|$)' >/dev/null
700394c
	then
700394c
	    echo 'glibc >= @VERSION@-@RELEASE@'
700394c
	    # Stop searching after the first match, but keep reading from
700394c
	    # the pipe.
700394c
	    searching=false
700394c
	fi
700394c
    fi
700394c
done