#!/usr/bin/perl -w
#
# Joshua D. Abraham (jabra@spl0it.org)
# Mon Oct 20 20:00:48 EDT 2008
#
# extract repository information and print it in CSV format
#
use strict;
use LWP::UserAgent;
use Data::Dumper;
my $lwp = LWP::UserAgent->new();
my $r   = $lwp->get(
    'http://repo.offensive-security.com/dist/bt4/binary/Packages');
my @ary = split( "\n", $r->content );
my ( $package, $version, $section, $maintainer );

foreach (@ary) {
    if (/Package: (.*)/) {
        if (    defined($package)
            and defined($version)
            and defined($section)
            and defined($maintainer) )
        {
            print
                join( ',', $package, $version, $section, $maintainer, "\n" );
            $package    = undef;
            $version    = undef;
            $section    = undef;
            $maintainer = undef;
        }
        $package = $1;
    }
    elsif (/Version: (.*)/) {
        $version = $1;
    }
    elsif (/Section: (.*)/) {
        $section = $1;
    }
    elsif (/Maintainer: (.*)/) {
        $maintainer = $1;
    }
    else { }
}

