Last updated: Sep 9, 2007
I noticed that after a few months of use, my /var/lib/dpkg/status file contained a lot of useless information about the packages I had installed and then purged - those packages have a status called “purge ok not-installed” (this is typically the case for kernel images built with make-kpkg and installed with dpkg -i). The grep-dctrl package is able to count/show these packages:
# Shows the packages with "purge ok not-installed" status /usr/bin/grep-status "purge ok not-installed" /var/lib/dpkg/status
or
# Just counts these packages /usr/bin/grep-status "purge ok not-installed" -c /var/lib/dpkg/status
However, I was unable to find something to purge the status file (equivalent to dpkg --forget-old-unavail). I have thus written this small script together with people from the debian-user-french mailing-list. It makes backups of your current status file, and keeps compressed backups from the last 7 times the script is launched - this should not prevent you from keeping your own backup of this precious file!
#! /bin/bash # # clear-dpkg-status - (c) 2005-2007 Julien Valroff # # Clears dpkg status file marked as "purge ok not-installed" # if [ $UID != 0 ]; then echo "This script requires to be root" exit 1; fi rep=/var/lib/dpkg cp $rep/status $rep/status.backup savelog -p -q -c 7 $rep/status.backup && rm -f $rep/status.backup > /dev/null 2>&1 sed -i -e '/./,$!d' -e ':a;N;/\n$/!{$!b a};/\nStatus: purge ok not-installed\n/d' $rep/status if [ $? = 0 ] then echo "Done." else echo "Script exited with code $?." fi
Use at your own risk!
You will find here some information about me and my different projects. I am involved in several open source projects, and try to promote Free software. This site is thus mainly dedicated to Free Software use on GNU/Linux systems. Please do not hesitate to contact me for any comments on this site.