find-provides: clean up

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2024-11-28 08:15:04 +01:00
parent 50eacae8a7
commit bef045eaf5

View File

@ -3,48 +3,52 @@
# This script reads filenames from STDIN and outputs any relevant provides # This script reads filenames from STDIN and outputs any relevant provides
# information that needs to be included in the package. # information that needs to be included in the package.
if [ "$1" ] unset package_name
then if [ "$1" ]; then
package_name="$1" package_name="$1"
fi fi
# Read stdin, backslash-quoting ' and "
filelist=`sed "s/['\"]/\\\&/g"` filelist=`sed "s/['\"]/\\\&/g"`
[ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] && [ -x /usr/lib/rpm/rpmdeps -a -n "$filelist" ] &&
echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --provides echo $filelist | tr '[:blank:]' \\n | /usr/lib/rpm/rpmdeps --provides
# (maybe use printf "%s\n" "$filelist" instead?)
# (why are we replacing witespace with newlines?)
# # Run any other extra find-provides scripts
# --- any other extra find-provides scripts for i in /usr/lib/rpm/redhat/find-provides.d/*.prov; do
for i in /usr/lib/rpm/redhat/find-provides.d/*.prov
do
[ -x $i ] && [ -x $i ] &&
(echo $filelist | tr '[:blank:]' \\n | $i | sort -u) (echo $filelist | tr '[:blank:]' \\n | $i | sort -u)
done done
# # Find symbols provided by the kernel or modules
# --- Kernel module imported symbols
# #
# Since we don't (yet) get passed the name of the package being built, we # Since we don't (yet) get passed the name of the package being built, we
# cheat a little here by looking first for a kernel, then for a kmod. # cheat a little here by looking first for a kernel, then for a kmod.
#
# the logic is broken, see comments:
unset is_kernel
# assume it's external modules
is_kmod=1 is_kmod=1
for f in $filelist; do for f in $filelist; do
if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*).ko$:\2:p') ] # If it is a /lib/modules/*/*.ko, it is from a kernel package
then if [ $(echo "$f" | sed -r -ne 's:^.*/lib/modules/(.*)/(.*).ko$:\2:p') ]; then
is_kernel=1; is_kernel=1
fi fi
if [ $(echo "$f" | sed -r -ne 's:^.*/boot/(.*):\1:p') ] # If it is a /boot/*, it is the kernel image itself (not an external module)
then if [ $(echo "$f" | sed -r -ne 's:^.*/boot/(.*):\1:p') ]; then
unset is_kmod; unset is_kmod
fi fi
done done
if [ ! "$is_kernel" ] || [ "$package_name" == "kernel" ] # if it is not /lib/modules/*/*.ko, or if not "kernel", then... it is not an external module???
then if [ ! "$is_kernel" ] || [ "$package_name" == "kernel" ]; then
unset is_kmod unset is_kmod
fi fi
# run find-provides.ksyms only if SOME files were external modules???
[ -x /usr/lib/rpm/redhat/find-provides.ksyms ] && [ "$is_kmod" ] && [ -x /usr/lib/rpm/redhat/find-provides.ksyms ] && [ "$is_kmod" ] &&
printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/redhat/find-provides.ksyms printf "%s\n" "${filelist[@]}" | /usr/lib/rpm/redhat/find-provides.ksyms
# (er? why "${filelist[@]}"? it is not even an array!?)
exit 0 exit 0