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

Re: VerPriority usage with libapt-pkg-perl



On Wed, Jul 16, 2003 at 11:50:36PM -0700, Eric Wong wrote:
>Hi, I'm trying to understand how to use the priority constants
>("AptPkg::State::Important", "AptPkg::State::Required",
>"AptPkg::State::Standard", "AptPkg::State::Optional" and
>"AptPkg::State::Extra") mentioned at the end of the AptPkg(3) man page.
>section to find the priority of a package.
>
>I couldn't find any examples of their usage in perl in the supplied
>documentation, Google, nor packages that use libapt-pkg-perl, so I'm
>wondering if someone could help me out.

An oversight.  I've added a "Priority" entry to AptPkg::Cache::Version
objects and uploaded as version 0.1.10.

An example:

  #!/usr/bin/perl

  # print overrides for all installed packages

  use AptPkg::Cache;

  my $cache = AptPkg::Cache->new;
  for my $pack (sort keys %$cache)
  {
    my $c = $cache->{$pack}{CurrentVer} or next;
    printf "%-34s %-10s %s\n", $pack, $c->{Priority}, $c->{ParentPkg}{Section};
  }

You can interpret the value either as a string or as a numeric to
compare with the constants:

  $c->{Priority} eq 'optional'
  $c->{Priority} == AptPkg::State::Optional

--bod



Reply to: