[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

listing packages in order of size



Is there a utility which lets you know what Debian packages you have
installed and what their size is?   I couldn't find any such
capability in the standard tools - dpkg, dselect or apt. 
'dpkg --get-selections lists the packages, but not their size.  This strikes
me as most surprising, since removing the largest unwanted packages
seems to me the most efficient way of trimming down a Debian
installation.

So, I did the proper thing and wrote my own utility.

It's a simple script mostly using perl to read all the packages in
/var/lib/dpkg/status which are listed as properly "installed",
printing off the names of packages with their size, and then sorting the
list largest first.  It pays no attention to dependencies.

So, (if I have mutt working properly) I'll attach the file to this
mail, for your use and edification. I called it "debsize", which is a
bit lame, but I couldn't think of anything better. If you think it's
useful, feel free to let the people on the debian users mailing list know about
it. (I don't subscribe there because the bandwidth is too large).

Drew Parsons




#!/bin/sh
# lists installed Debian packages, sorting by package size

# This could just be a perl script extracting the install package info.
# but I made it a sh script to allow for sort manipulation afterwards.

# Installed packages read from /var/lib/dpkg/status

echo '
open(FILE,"/var/lib/dpkg/status");
$_=<FILE>;
while ($_)
{
	if ( /Package:/ )
	{
		@package = split(" ",$_);
		$_=<FILE>; 
		if ( /install ok installed/ )
		{		
			do 
			{ 
				$_=<FILE>; 
			}
			until ( /Size:/ );
			@size = split(" ",$_);
	
			print("$package[1]   $size[1]\n");
		}
	}
	$_=<FILE>;
}
' | perl  | sort -nr -k2

Reply to: