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

Re: interpreting Status field in dpkg status/available file



On Tue, Feb 27, 2001 at 01:31:00PM +0000, Julian Gilbey wrote:
> > a big part of the point of dlocate is speed. it's a LOT faster to
> > run grep-dctrl or just 'cat /var/lib/dpkg/status' and parse the
> > output than it is to run "dpkg -l".
>
> But if you only do it once per cron job, it doesn't really matter.

true. but it's the principle of the thing :), and sometimes i run
update-dlocatedb by hand and i'm just impatient.

> > also, i want to know how to do it - and submit the result as a
> > subroutine for dpkg-perl (if it's still being maintained) and/or
> > grep-dctrl.
>
> Cool!

i ended up looking at the dpkg source code. i think i got it right, but
it's hard to tell because dpkg's source isn't exactly easy to read :)


%statusinfos = (
    "not-installed"     =>  "n",
    "unpacked"          =>  "U",
    "half-configured"   =>  "C",
    "installed"         =>  "i",
    "half-installed"    =>  "I",
    "config-files"      =>  "c",
    # These are additional entries for backwards-compat. 
    "postinst-failed"   =>  "C",
    "removal-failed"    =>  "I"
);

%eflaginfos = (
    "ok"                =>  " ",
    "reinstreq"         =>  "R",
    # the next two may be obsolete.  hold is now a want, not an error flag
    "hold"              =>  "h",  
    "hold-reinstreq"    =>  "X"
);

%wantinfos = (
    "unknown"   =>  "u",
    "install"   =>  "i",
    "hold"      =>  "h",
    "deinstall" =>  "r",
    "purge"     =>  "p"
);

.
.
.

        } elsif ($key eq "Status") {
            ($want,$eflag,$stat) = split /\s+/, $val;
            $status{$package} = $wantinfos{$want} .
                                $statusinfos{$stat} .
                                $eflaginfos{$eflag} ;
        }


i thought grep-dctrl was perl but it's C, so i probably won't make a
patch for it unless i get seriously bored. i'll come up with a patch for
dpkg-perl (although i don't think it's being actively maintained and
isn't terribly useful now that grep-dctrl is here).

craig

--
craig sanders <cas@taz.net.au>

      GnuPG Key: 1024D/CD5626F0 
Key fingerprint: 9674 7EE2 4AC6 F5EF 3C57  52C3 EC32 6810 CD56 26F0



Reply to: