Hello,

Bill Allombert a écrit :
> 2) you do not remove dependency from other OLD packages recursively.
>   
This third version accepts a list of packets to exclude (option -e).
These packets are considered as not installed on the system (ignore
dependency clamed by these packets, and remove them from the list of
<old> packets).
It allows us to simulate the fact that these packets are removed by the
administrator.
The idea is to be called recursively, but in an interactive way (with
the administrator) by a higher level tool (to develop), just like
orphaner recursively calls deborphan.

I hope this proposal goes in the right directions (?).

Regards
Christophe
#!/bin/sh
#
# Author: Christophe Lohr <cl...@users.sourceforge.net>
# License: GPL
# v0.3 - Fri, 08 May 2009 15:21:46 +0200

RECOMMENDS=' ${Recommends}'
SUGGESTS=' ${Suggests}'
EXCLUDE_LIST=""
EXCLUDE_DEPS=cat
while test $# -gt 0 ; do
  case $1 in 
  '-r') RECOMMENDS=''
        shift ;;
  '-s') SUGGESTS=''
        shift ;;
  '-e') shift
        EXCLUDE_LIST=$1
        EXCLUDE_DEPS="grep -v"
        for PKG in $1; do
          EXCLUDE_DEPS="$EXCLUDE_DEPS -e ^$PKG:"
        done
        shift ;;
  *) echo "Unknown option $1"
     ERROR=true
  esac
done

# Note: 
# "EXCLUDE_DEPS" is used to filter out dependencies clamed by these packets
# "EXCLUDE_LIST" is added to the final list of packets to ignore


if [ "$ERROR" = true ]; then
  cat << EOF >&2
Usage: $0 [-r] [-s] [-e "<package> [<package> ...]" ]
 -r             Also displays packages that are recommended by other
 -s             Also displays packages that are suggested by other
 -e <packages>  List of packets to exclude (a quoted list of package names 
                separated by blanks)
                i.e. work as these packets were not installed on the system
EOF
  exit 1
fi 

DEPENDS=`tempfile`

dpkg-query -W -f="\${Package}:\${Status}:\${Depends}${RECOMMENDS}${SUGGESTS}\n" 
\
        | $EXCLUDE_DEPS | grep 'ok installed:' | cut -d: -f3 \
        | sed -e "1i$EXCLUDE_LIST" | tr ', ' '\012' | sort | uniq > $DEPENDS

while read SIZE PACKAGE ; do
  if ! grep -q "^$PACKAGE\$" $DEPENDS; then
    echo $SIZE $PACKAGE
  fi 
done

rm -f $DEPENDS

Reply via email to