filesystem/filesystem.req
Zbigniew Jędrzejewski-Szmek 232e0e19db Make sure that the generator is only active on merged systems
There are rpms which have files in /usr/bin which would trigger the
condition in the generator, even when building on an unmerged system,
and the package would have Requires:filesystem(unmerged-sbin-symlinks).
The corresponding Provides is actually only generated when filesystem
itself is built with the merge, so effectively the package with the
Requires would become uninstallable.
2024-09-15 16:57:47 +02:00

23 lines
661 B
Bash
Executable File

#!/usr/bin/bash
# Generate Requires: filesystem(unmerged-sbin-symlinks) if any
# of the filenames were known to reside in /usr/sbin.
# When the package with the files is being built, it's possible that
# %_sbindir==/usr/bin, so we cannot rely on the location to figure
# this out and we need a hardcoded list.
sbin_filenames=${1:?}
# Do nothing if the build system is not merged.
test -L /usr/sbin || exit 0
declare -A "filenames=($(sed 's/.*/["\0"]=1/' <"${sbin_filenames}"))"
while read -r path; do
filename="$(basename "$path")"
if [ -n "${filenames[$filename]}" ]; then
echo ";$path"
echo "filesystem(unmerged-sbin-symlinks)"
fi
done