#!/usr/bin/perl -w # $Id: package-release,v 1.3 2008/01/14 16:33:12 lkundrak Exp $ # Script for querying which release we ship a package in, and what the # version of said package is. # # This script was originally writeen by Jason L Tibbitts III # TODO: Use getopt (add options at that time) # TODO: Allow for fuzzy matching (partial searching) use LWP::Simple; use Net::FTP; use strict; # Global variables my ($owner_file, $mirror_host, $mirror_path, @releases); $owner_file='http://cvs.fedora.redhat.com/viewcvs/*checkout*/owners/owners.list?root=extras'; $mirror_host='download.fedora.redhat.com'; $mirror_path='/pub/fedora/linux/releases/%s/Everything/source/SRPMS'; @releases=qw( 7 ); sub get_owner_content { my $match = pop; my ($distro, $package, $desc, $owner, $qa, $cc); my %owner; my $owner_content = get($owner_file) or die "Couldn't get $owner_file"; foreach (split(/\n/, $owner_content)) { next if /^#/; chomp; ($distro, $package, $desc, $owner, $qa, $cc) = split(/\|/, $_); next if ( $package !~ m/$match/i); $owner{$package} = {}; $owner{$package}->{'product'} = $distro; $owner{$package}->{'package'} = $package; $owner{$package}->{'description'} = $desc; $owner{$package}->{'owner'} = $owner; $owner{$package}->{'qacontact'} = $qa; $owner{$package}->{'cclist'} = $cc; } return %owner; } my $package = $ARGV[0]; my %owner = get_owner_content($package); if (!keys(%owner) or $package eq '') { print "Could not find package \"$package\" in $owner_file\n"; exit 1; } foreach (keys(%owner)) { print "Found package $_ in owners.list:\n"; } my $ftp = Net::FTP->new($mirror_host, Debug => 0) or die "Cannot connect to $mirror_host: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->message; foreach my $release (@releases) { my ($f, $dir, $files, $rev, $ver, $name); $dir = sprintf($mirror_path, $release); $release eq "development" && ($release = "dev"); $files = $ftp->ls($dir) or die "Cannot list directory ", $ftp->message; foreach my $f (@$files) { chomp($f); $f =~ s/$dir\///; next unless $f =~ /^(.*$package.*)-([^\-]*)-([^\-]*)\.src\.rpm$/i; $name = $1; $ver = $2; $rev = $3; print " $release\t$name\t$ver\t$rev\t$f\n"; } } $ftp->quit;