Tuesday, June 22, 2010

pkginfo

#!/bin/sh
# stuart powers

# list the files installed from a specific package or all
# packages which match /pattern/ # one line of output per file:
# [exe|dir|pipe|etc] $PACKAGE $FILE

#to see all the executable files from libwww-perl:
#stu@sente ~ $ pkginfo.sh libwww-perl | grep ^x | cut -f3
# /usr/bin/lwp-download
# /usr/bin/lwp-mirror
# /usr/bin/lwp-rget
# /usr/bin/lwp-request
# /usr/bin/GET
# /usr/bin/POST
# /usr/bin/HEAD

#list installed apache packages:
#stu@sente ~ $ pkginfo.sh apache | cut -f2 | uniq
# apache2
# apache2-utils
# apache2.2-common
# libapache2-reload-perl

#show which packages have the most executables:
#stu@sente ~ $ pkginfo.sh | grep ^x | cut -f2 | uniq -c | sort -nr |head -5
# 131 git-core
# 96 coreutils
# 87 mailman
# 82 hal
# 70 texlive-base-bin


parm=$1
test -z $1 && parm=.



dpkg --list |
grep '^ii' |
grep -E "$parm" |
awk '{print $2}' |
while read package; do
dpkg -L $package |
while read file; do

#skips directories -- we only want files
# test -f "$file" || continue;

#if the file is executable, 'x', else 'f'
dest=
flag=

if [ -d "$file" ]; then
flag="dir"
elif [ -x "$file" ]; then
flag="exe"
fi

if [ -L "$file" ];
then flag="lnk"
fi;

if [ -L "$file" ];
then flag="lnk"
dest=$(readlink -e "$file")
fi;

if [ -L "$file" ];
then flag="pipe"
fi;

echo -e "$flag\t$package\t$file\t$dest";
done;
done


No comments:

Post a Comment