#!/usr/bin/perl -w
#
#  Display all the packages of priority "base" or "required".
#
#  Essential packages which must exist on all systems.
#

use strict;

my $input = "/var/lib/dpkg/available";
my @BASE  = ();

open( INPUT, "<$input" )
	or die "Cannot open $input - $!";

my $package  = "";
my $priority = "";

while( my $line = <INPUT> )
{
    if ( $line =~ /^Package: (.*)/ )
    {
	$package = $1;
    }
    if ( $line =~ /^Priority: (.*)/ )
    {
	$priority = $1;
    }

    if ( length( $package ) &&
	 length( $priority ) )
    {

	if ( $priority =~ /^required$/i )
	{
	    push @BASE, $package;
	}
	$package  = "";
	$priority = "";
    }
}
close( INPUT );


foreach my $p ( sort @BASE )
{
    print $p . "\n";
}
