#!/usr/bin/perl
use warnings;
use strict;

my $ubmirror='http://ftp.uninett.no/ubuntu';
my $suite='utopic';
my $arch='i386';
for my $section ('main', 'restricted', 'multiverse', 'universe') {
    my $url = sprintf('%s/dists/%s/%s/binary-%s/Packages.bz2',
                      $ubmirror, $suite, $section, $arch);
#    print "$url\n";
    open(my $fh, "GET $url |bunzip2 |") || die "unable to fetch $url";
    my $pkg;
    while (<$fh>) {
        chomp;
        my ($header, $rest) = split(/: /, $_, 2);
        next unless defined $header;
        $pkg = $rest if ("Package" eq $header);
        if ("Modaliases" eq $header)  {
            print "Package: ", $pkg, "\n";
            print $header, ": ", $rest, "\n\n";
        }
    }
}
