Wednesday, December 16, 2009

ldd package finder (APT)

I wrote a bash shell script for getting package names from ldd output.
apt-file, awk, basename, egrep, sort, uniq are needed.
it will list lib64 packages if arg2 = 64. e.g.:
# ./lddpkgs.sh /bin/bash 64

an example for using in checkinstall:
# checkinstall --requires=`lddpkgs.sh src/mysoft|xargs|sed -e 's/ /,/g'` (...)

for executable with multiple libraries, you can append all libraries' lddpkgs.sh output to one file, sort and uniq that file and you will get the package dependency of those binaries.

one line is a bit long so please ensure you selected all things between Start of File and End Of File.
-Start of File-
#!/bin/bash
if [ "$2" = "64" ];then
EGR='libc|libdl|dbg'
else
EGR='libc|libdl|dbg|lib64'
fi

ldd $1|awk '{tmp ="basename "$1; tmp|getline bnso;system("apt-file find "bnso);close(tmp)}'|egrep -v $EGR|awk -F':' '{print $1}'|sort|uniq
-End Of File-

No comments:

Post a Comment