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

Re: Cleaning /var/lib/dpkg/available



On Wednesday 14 June 2006 14:34, Jérôme Warnier wrote:
> Hi,
>
> I've been upgrading my machines since Woody to Sarge, then to Etch. Now,
> my /var/lib/dpkg/available are huge (15MB), and it seems they never get
> cleaned.
> How am I supposed to clean them? Isn't there any automated tools in
> Debian to do that?

In case you are interested to clear your /var/lib/dpkg/status, here is what I 
use sometimes. For instance, if you want to purge package section with 
'Status: purge ok not-installed', ./this_script > /tmp/status.cleated, and 
then see what have been removed from it diff'ing against your 
current /var/lib/dpkg/status. Remember to make a backup before actually 
replacing the file ;-)


#!/usr/bin/perl

use warnings;
use strict;

my $filename='/var/lib/dpkg/status';

open FILE, $filename or
die "Failed to open $filename\n";

while (my $line=<FILE>) {

    chomp($line);
    my @section=();

    while ($line ne "") {
        push(@section,$line);
        $line=<FILE>;
        chomp($line);
    }

    if ($section[1] ne 'Status: purge ok not-installed') {

        foreach (@section) {
            $_ = $_ . "\n";
            print;
        }

        print"\n";
    }
}

-- 
pub 4096R/0E4BD0AB 2003-03-18 <people.fccf.net/danchev/key pgp.mit.edu>
fingerprint 1AE7 7C66 0A26 5BFF DF22 5D55 1C57 0C89 0E4B D0AB 



Reply to: