[Slackbuilds-users] tracking down SBo "dependencies"
Shahab Vahedi
list+sbo at vahedi.org
Mon Mar 4 11:54:05 UTC 2024
Jim,
Would a script like the one at the bottom of this email point you
toward the right package(s)?
I have to warn you it roughly took 11 minutes to finish on my laptop
with 1680 packages installed:
$ time ./depcheck libacl.so
acl-2.3.2-x86_64-1: /usr/bin/chacl
cdrtools-3.02a09-x86_64-1: /usr/bin/isoinfo
coreutils-9.4-x86_64-1: /bin/cp
...
vim-gvim-9.1.0136-x86_64-1: /usr/bin/gvim
xorriso-1.5.6.pl02-x86_64-1: /usr/bin/xorriso
real 11m16.558s
...
----------------------------------8<------------------------------------
#! /bin/bash -
# depcheck -- List Slackware packages that directly rely on a library.
# shellcheck disable=SC2312
readonly lib="$1"
sanity_check()
{
if test -z "${lib}"
then
echo -e "\nProvide one library name as an argument. Example:\n"
echo " $ $0 libacl.so"
exit 1
fi
if ! command -v "parallel" > /dev/null 2>&1
then
echo "GNU Parallel is necessary for this tool."
exit 1
fi
}
process_package()
{
_lib="$1"
_pkg="$2"
grep -e '^[^ ]\+/.\+' "${_pkg}" | while read -r fl
do
fl="/${fl}"
if test -f "${fl}" && file --brief --mime-type "${fl}" |
grep -q "x-executable\|x-sharedlib"
then
if readelf -d "${fl}" 2>/dev/null |
grep -i -q "shared library: \[${_lib}"
then
echo "${_pkg##*/}: ${fl}"
# no need to go through other files of this package
break
fi
fi
done
}
export -f process_package
sanity_check
SHELL=$(type -p bash)
find /var/lib/pkgtools/packages -type f | sort |
parallel process_package "${lib}"
----------------------------------8<------------------------------------
Cheers,
Shahab
More information about the SlackBuilds-users
mailing list