diff --git a/findunusedbd.sh b/findunusedbd.sh index ea47c35..952bab2 100755 --- a/findunusedbd.sh +++ b/findunusedbd.sh @@ -15,25 +15,28 @@ get_metaset() { if apt-cache show --no-all-versions "${name}=${ver}" \ | grep-dctrl -P "" -s Tag -n \ | sed 's/, /\n/g; s/[, ]//g;' \ - | egrep '^(role::metapackage|role::dummy)$'; then + | egrep '^(role::metapackage|role::dummy)$' \ + > /dev/null; then ismeta="yes" fi fi # check if there is any regular file in the package besides /usr/share/doc if [ $ismeta = "no" ]; then apt-get download "${name}=${ver}" > /dev/null - mkdir "$name" + # strip off architecture qualifier + pkgname=`echo $name | cut -d ':' -f 1` + mkdir "$pkgname" # we cannot include the version here because apt urlencodes the : character - dpkg --extract ${name}_*.deb $name - if [ -d ${name}/usr/share/doc ]; then - rm -r ${name}/usr/share/doc + dpkg --extract ${pkgname}_*.deb $pkgname + if [ -d ${pkgname}/usr/share/doc ]; then + rm -r ${pkgname}/usr/share/doc fi # check if besides /usr/share/doc there is any regular file # in this package (symlinks do not count) - if [ `find $name -type f | wc -l` -eq 0 ]; then + if [ `find $pkgname -type f | wc -l` -eq 0 ]; then ismeta="yes" fi - rm -r ${name}_${ver}_*.deb $name + rm -r ${pkgname}_*.deb $pkgname fi if [ $ismeta = "yes" ]; then # retrieve all its unversioned dependencies @@ -93,9 +96,12 @@ elif [ "$#" -eq 2 ]; then # output the files belonging to all packages dpkg --list | awk '$1 == "ii" { print $2, $3 }' | while read namever; do set -- $namever - # strip off architecture qualifier - name=`echo $1 | cut -d ':' -f 1` + name=$1 ver=$2 + # skip all sbuild dummy packages + case $name in + sbuild-build-depends*) continue;; + esac if grep --line-regexp "${name}=${ver}" "${tmpdir}/bdselection.list"; then # if the package contains no other files than in /usr/share/doc # or if all the other files are symlinks