Bill Allombert a écrit : > 2) you do not remove dependency from other OLD packages recursively. >
Hello, This fourth version of "popcon-nodependency" is closer to deborphan: . the "-e" option accepts a list of packets to exclude, separated by commas . it manages a list of files to keep "/var/lib/deborphan/keep" (do one have to do something else specific?) I also propose "popcon-retirement", which recursively calls "popcon-largest-unused|popcon-nodependency", a bit like "orphaner" calls "deborphan". Note that the code of "popcon-retirement" is mostly a syntactic rearrangement of "orphaner" (i.e. I don't understand details of the code!) Therefore it would be nice if someone (with motivation, skills, and time) could have a look to this code. Volunteers? ;-) Regards, Christophe.
#!/bin/sh # # Author: Christophe Lohr <cl...@users.sourceforge.net> # License: GPL # v0.4 - Sun, 10 May 2009 14:57:09 +0200 RECOMMENDS=' ${Recommends}' SUGGESTS=' ${Suggests}' EXCLUDE_LIST="" EXCLUDE_DEPS=cat KEEP_FILE="/var/lib/deborphan/keep" while test $# -gt 0 ; do case $1 in '-r') RECOMMENDS='' shift ;; '-s') SUGGESTS='' shift ;; '-e') shift EXCLUDE_LIST="`echo $1 | tr ',' ' '`" EXCLUDE_DEPS="grep -v" for PKG in $EXCLUDE_LIST; do EXCLUDE_DEPS="$EXCLUDE_DEPS -e ^$PKG:" done shift ;; '-k') shift KEEP_FILE=$1 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> ...]" ] [-k <file>] -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 comma separated list) i.e. work as these packets were not installed on the system -k <file> Use <file> to store the list of packages (one per line) which are never to be reported, regardless of their state. Default: "/var/lib/deborphan/keep" (Use "deborphan" ok "keepedit" to manage it) EOF exit 1 fi DEPENDS=`tempfile` trap "rm -f $DEPENDS" EXIT INT 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' \ | sed -e "1r$KEEP_FILE" \ | sort | uniq > $DEPENDS while read SIZE PACKAGE ; do if ! grep -q "^$PACKAGE\$" $DEPENDS; then echo $SIZE $PACKAGE fi done
popcon-retirement.sh
Description: application/shellscript