Created
November 11, 2021 09:19
-
-
Save N0rbert/423d9b5c8718c45a699e9d3bd406ffc6 to your computer and use it in GitHub Desktop.
Find wrong or local libraries using apt-file and output of ldd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Program purpose: | |
# analyze output of `ldd some-program` to find relevant packages in the configured APT repositories. | |
# To ease the analysis one can run it with filter `$0 ldd_output | grep Warning` to get only missed libraries/packages. | |
# | |
# Note: having `linux-vdso.so.1` in the output is normal, it belong C library on the linker level. | |
if [ "$#" -ne 1 ]; then | |
echo "This program should be run with one argument - '$0 ldd_output', where ldd_output is output of 'ldd' command for some executable." | |
exit 1 | |
else | |
LDD_FILE="$1" | |
fi | |
while read lib | |
do | |
echo "Analyzing '$lib' line:" | |
# not found at all | |
not_found=$(echo $lib | grep "=> not found" | awk '{print $1}') | |
if [ ! -z $not_found ] | |
then | |
apt-file search -F $not_found || echo " Warning: configured repositories does not contain '$not_found' library." | |
fi | |
# first level without path | |
first_level=$(echo $lib | grep -v "=> not found" | grep -v "=>" | awk '{print $1}') | |
if [ ! -z $first_level ] | |
then | |
apt-file search $first_level | grep -E "$first_level\$" || echo " Warning: configured repositories does not contain '$first_level' library." | |
fi | |
# second level with full path | |
second_level=$(echo $lib | grep -v "=> not found" | grep "=>" | awk '{print $3}') | |
if [ ! -z $second_level ] | |
then | |
apt-file search $second_level | grep -E "$second_level\$" || echo " Warning: configured repositories does not contain '$second_level' library." | |
fi | |
echo "- - -" | |
done < $LDD_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment