r1836 - in
packages/libmodule-packaged-perl/branches/upstream/current: .
lib/Module lib/Module/Packaged t
Krzysztof Krzyzaniak
eloy at costa.debian.org
Mon Jan 2 22:38:49 UTC 2006
Author: eloy
Date: 2006-01-02 22:38:48 +0000 (Mon, 02 Jan 2006)
New Revision: 1836
Added:
packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged/
packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged/Generate.pm
packages/libmodule-packaged-perl/branches/upstream/current/t/pod.t
packages/libmodule-packaged-perl/branches/upstream/current/t/pod_coverage.t
Removed:
packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP
Modified:
packages/libmodule-packaged-perl/branches/upstream/current/Build.PL
packages/libmodule-packaged-perl/branches/upstream/current/CHANGES
packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST
packages/libmodule-packaged-perl/branches/upstream/current/META.yml
packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL
packages/libmodule-packaged-perl/branches/upstream/current/README
packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm
packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t
Log:
Load /tmp/tmp.0uqAao/libmodule-packaged-perl-0.84 into
packages/libmodule-packaged-perl/branches/upstream/current.
Modified: packages/libmodule-packaged-perl/branches/upstream/current/Build.PL
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/Build.PL 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/Build.PL 2006-01-02 22:38:48 UTC (rev 1836)
@@ -3,15 +3,20 @@
my $build = Module::Build->new(
create_makefile_pl => 'traditional',
- license => 'perl',
- module_name => 'Module::Packaged',
- requires => {
- 'IO::File' => '1.08',
- 'IO::Zlib' => '1.01',
- 'LWP::Simple' => '1.38',
- 'Sort::Versions' => '1.50',
- 'Test::More' => '0.47',
- 'Parse::CPAN::Packages' => '2.20',
+ license => 'perl',
+ module_name => 'Module::Packaged',
+ requires => {
+ 'App::Cache' => '0',
+ 'Compress::Zlib' => '0',
+ 'Class::Accessor::Chained::Fast' => '0',
+ 'Storable' => '0',
+ 'IO::File' => '1.08',
+ 'IO::String' => '0',
+ 'IO::Zlib' => '1.01',
+ 'LWP::Simple' => '1.38',
+ 'Sort::Versions' => '1.50',
+ 'Test::More' => '0.47',
+ 'Parse::CPAN::Packages' => '2.20',
'Parse::Debian::Packages' => '0.01',
},
);
Modified: packages/libmodule-packaged-perl/branches/upstream/current/CHANGES
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/CHANGES 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/CHANGES 2006-01-02 22:38:48 UTC (rev 1836)
@@ -1,5 +1,36 @@
-Revision history for Perl module Module::Packaged.
+Revision history for Perl module Module::Packaged:
+0.84 Fri Aug 5 19:04:55 PDT 2005
+ - rewrite the generator to use App::Cache and update Mandriva name
+ - fix Debian perl-tk misreporting (patch by Andreas Koenig)
+
+0.83 Thu Aug 4 09:30:04 PDT 2005
+ - 0.82 wasn't quite uploaded to CPAN, pesky wireless
+
+0.82 Thu Aug 4 09:16:13 PDT 2005
+ - updated the tests (thanks Andreas)
+
+0.81 Mon Jul 4 23:24:32 BST 2005
+ - we now cache the data for an hour using App::Cache
+ - added a pod coverage test
+ - updated the tests
+
+0.80 Sat Mar 26 09:33:04 CST 2005
+ - fixed tiny typo in pod (spotted by mcummings)
+ - updated the tests
+ - seperated into a generator and a client (so now faster for you!)
+
+0.79 Sun Feb 6 17:42:47 GMT 2005
+ - include Mandrake contrib (oops)
+
+0.78 Sat Feb 5 17:20:48 GMT 2005
+ - updated the tests
+ - fixed brokenness with Fedora, Mandrake, SUSE
+
+0.77 Thu Sep 23 11:45:51 BST 2004
+ - slightly more documentation
+ - renamed private methods to start with underscore
+
0.76 Tue Aug 24 16:14:25 BST 2004
- removed dependency on Cache::Cache
- updated the tests (maybe I should fix the test suite, eh?)
Modified: packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST 2006-01-02 22:38:48 UTC (rev 1836)
@@ -1,10 +1,12 @@
Build.PL
CHANGES
+lib/Module/Packaged.pm
+lib/Module/Packaged/Generate.pm
Makefile.PL
MANIFEST This list of files
-MANIFEST.SKIP
META.yml
NINJA
README
-lib/Module/Packaged.pm
+t/pod.t
+t/pod_coverage.t
t/simple.t
Deleted: packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP 2006-01-02 22:38:48 UTC (rev 1836)
@@ -1,31 +0,0 @@
-_build
-Build$
-blib
-~$
-\.bak$
-^MANIFEST\.SKIP$
-CVS
-^Makefile$
-^MakeMaker-\d
-\.old$
-^#.*#$
-^\.#
-\.#
-#$
-\B\.svn\b
-
-\.bs$
-\.c$
-\.o$
-pm_to_blib
-unpacked
-
-# our store
-cpants.store
-testers.db
-
-# autogenerated
-testers.db
-testers.sqldb
-testers.sqldb-journal
-SIGNATURE
Modified: packages/libmodule-packaged-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/META.yml 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/META.yml 2006-01-02 22:38:48 UTC (rev 1836)
@@ -1,20 +1,27 @@
---- #YAML:1.0
+---
name: Module-Packaged
-version: 0.76
+version: 0.84
author:
- - Leon Brocard, leon at astray.com
+ - 'Leon Brocard, leon at astray.com'
abstract: Report upon packages of CPAN distributions
license: perl
requires:
+ App::Cache: 0
+ Class::Accessor::Chained::Fast: 0
+ Compress::Zlib: 0
IO::File: 1.08
+ IO::String: 0
IO::Zlib: 1.01
LWP::Simple: 1.38
Parse::CPAN::Packages: 2.20
Parse::Debian::Packages: 0.01
Sort::Versions: 1.50
+ Storable: 0
Test::More: 0.47
provides:
Module::Packaged:
file: lib/Module/Packaged.pm
- version: 0.76
-generated_by: Module::Build version 0.25
+ version: 0.84
+ Module::Packaged::Generate:
+ file: lib/Module/Packaged/Generate.pm
+generated_by: Module::Build version 0.2611
Modified: packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL 2006-01-02 22:38:48 UTC (rev 1836)
@@ -7,10 +7,15 @@
'NAME' => 'Module::Packaged',
'VERSION_FROM' => 'lib/Module/Packaged.pm',
'PREREQ_PM' => {
- 'Test::More' => '0.47',
'Parse::CPAN::Packages' => '2.20',
'IO::Zlib' => '1.01',
'IO::File' => '1.08',
+ 'Compress::Zlib' => '0',
+ 'IO::String' => '0',
+ 'Storable' => '0',
+ 'App::Cache' => '0',
+ 'Test::More' => '0.47',
+ 'Class::Accessor::Chained::Fast' => '0',
'Parse::Debian::Packages' => '0.01',
'Sort::Versions' => '1.50',
'LWP::Simple' => '1.38'
Modified: packages/libmodule-packaged-perl/branches/upstream/current/README
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/README 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/README 2006-01-02 22:38:48 UTC (rev 1836)
@@ -2,7 +2,7 @@
Module::Packaged - Report upon packages of CPAN distributions
SYNOPSIS
- use Module::Packages;
+ use Module::Packaged;
my $p = Module::Packaged->new();
my $dists = $p->check('Archive-Tar');
@@ -10,14 +10,16 @@
# {
# cpan => '1.08',
# debian => '1.03',
+ # fedora => '0.22',
# freebsd => '1.07',
- # gentoo => '1.03',
+ # gentoo => '1.05',
# openbsd => '0.22',
+ # suse => '0.23',
# }
# meaning that Archive-Tar is at version 1.08 on CPAN but only at
- # version 1.07 on FreeBSD, version 1.03 on Debian Gentoo and 0.22 on
- # OpenBSD
+ # version 1.07 on FreeBSD, version 1.05 on Gentoo, version 1.03 on
+ # Debian, version 0.23 on SUSE and version 0.22 on OpenBSD
DESCRIPTION
CPAN consists of distributions. However, CPAN is not an isolated system
@@ -25,12 +27,26 @@
systems. This module reports whether CPAN distributions are packaged for
various operating systems, and which version they have.
- Note: only CPAN, Debian, FreeBSD, Gentoo, and OpenBSD are currently
- supported. I want to support versions of PPM, and Redhat. Patches are
- welcome.
+ Only CPAN, Debian, Fedora (Core 2), FreeBSD, Gentoo, Mandrake (10.1),
+ OpenBSD (3.6) and SUSE (9.2) are currently supported. I want to support
+ everything else. Patches are welcome.
+ The data is fetched from the net and cached for an hour.
+
+METHODS
+ new()
+ The new() method is a constructor:
+
+ my $p = Module::Packaged->new();
+
+ check()
+ The check() method returns a hash reference. The keys are various
+ distributions, the values the version number included:
+
+ my $dists = $p->check('Archive-Tar');
+
COPYRIGHT
- Copyright (c) 2003 Leon Brocard. All rights reserved. This program is
+ Copyright (c) 2003-5 Leon Brocard. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
Added: packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged/Generate.pm
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged/Generate.pm 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged/Generate.pm 2006-01-02 22:38:48 UTC (rev 1836)
@@ -0,0 +1,289 @@
+package Module::Packaged::Generate;
+use strict;
+use App::Cache;
+use IO::File;
+use Compress::Zlib;
+use IO::String;
+use IO::Zlib;
+use File::Spec::Functions qw(catdir catfile tmpdir);
+use LWP::Simple qw(mirror);
+use Parse::CPAN::Packages;
+use Parse::Debian::Packages;
+use Sort::Versions;
+use Storable qw(store retrieve);
+use base 'Class::Accessor::Chained::Fast';
+__PACKAGE__->mk_accessors(qw(cache data));
+
+sub new {
+ my $class = shift;
+ my $self = {};
+ bless $self, $class;
+
+ $self->cache(App::Cache->new({ ttl => 60 * 60 }));
+
+ $self->{data} = $self->cache->get_code(
+ "data",
+ sub {
+ $self->_fetch_cpan;
+ $self->_fetch_debian;
+ $self->_fetch_fedora;
+ $self->_fetch_freebsd;
+ $self->_fetch_gentoo;
+ $self->_fetch_mandrake;
+ $self->_fetch_openbsd;
+ $self->_fetch_suse;
+ $self->{data};
+ }
+ );
+
+ return $self;
+}
+
+sub _fetch_cpan {
+ my $self = shift;
+ my $details =
+ $self->cache->get_url(
+ "http://www.cpan.org/modules/02packages.details.txt.gz",
+ "02packages.gz");
+
+ $details = Compress::Zlib::memGunzip($details);
+
+ my $p = Parse::CPAN::Packages->new($details);
+
+ foreach my $dist ($p->latest_distributions) {
+ $self->{data}->{ $dist->dist }->{cpan} = $dist->version;
+ }
+}
+
+sub _fetch_gentoo {
+ my $self = shift;
+
+ my $file =
+ $self->cache->get_url("http://www.gentoo.org/dyn/gentoo_pkglist_x86.txt",
+ "gentoo.html");
+ $file =~ s{</a></td>\n}{</a></td>}g;
+
+ my @dists = keys %{ $self->{data} };
+
+ foreach my $line (split "\n", $file) {
+ next unless ($line =~ m/dev-perl/);
+ my $dist;
+ $line =~ s/\.ebuild//g;
+ my ($package, $version, $trash) = split(' ', $line);
+ next unless $package;
+
+ # Let's try to find a cpan dist that matches the package name
+ if (exists $self->{data}->{$package}) {
+ $dist = $package;
+ } else {
+ foreach my $d (@dists) {
+ if (lc $d eq lc $package) {
+ $dist = $d;
+ last;
+ }
+ }
+ }
+
+ if ($dist) {
+ $self->{data}->{$dist}->{gentoo} = $version;
+ } else {
+
+ # I should probably care about these and fix them
+ # warn "Could not find $package: $version\n";
+ }
+ }
+}
+
+sub _fetch_fedora {
+ my $self = shift;
+ my $file =
+ $self->cache->get_url("http://fedora.redhat.com/docs/package-list/fc2/",
+ "fedora.html");
+ foreach my $line (split "\n", $file) {
+ next unless $line =~ /^perl-/;
+ my ($dist, $version) =
+ $line =~ m{perl-(.*?)</td><td class="column-2">(.*?)</td>};
+
+ # only populate if CPAN already has
+ $self->{data}{$dist}{fedora} = $version
+ if $self->{data}{$dist};
+ }
+}
+
+sub _fetch_suse {
+ my $self = shift;
+ my $file = $self->cache->get_url(
+ "http://www.novell.com/products/linuxpackages/professional/index_all.html",
+ "suse.html"
+ );
+
+ foreach my $line (split "\n", $file) {
+
+ # <a href="perl-dbi.html">perl-DBI 1.43 </a> (The Perl Database Interface)
+ my ($dist, $version) = $line =~ m{">perl-(.*?) (.*?) </a>};
+ next unless $dist;
+
+ # only populate if CPAN already has
+ $self->{data}{$dist}{suse} = $version
+ if $self->{data}{$dist};
+ }
+}
+
+sub _fetch_mandrake {
+ my $self = shift;
+ my $file1 = $self->cache->get_url(
+"http://distro.ibiblio.org/pub/linux/distributions/mandriva/MandrivaLinux/official/current/i586/media/media_info/synthesis.hdlist_main.cz",
+ "mandrake1.html"
+ );
+ my $file2 = $self->cache->get_url(
+"http://distro.ibiblio.org/pub/linux/distributions/mandriva/MandrivaLinux/official/current/i586/media/media_info/synthesis.hdlist_contrib.cz",
+ "mandrake2.html"
+ );
+
+ foreach my $file ($file1, $file2) {
+ $file = Compress::Zlib::memGunzip($file);
+ foreach my $line (split / /, $file) {
+
+ # @info at perl-DBI-1.43-2mdk.i586@0 at 1371700@Development/Perl
+ next
+ unless my ($dist, $version) =
+ $line =~ m{\@info\@perl-(.*)-(.*?)-\d+mdk};
+
+ # only populate if CPAN already has
+ $self->{data}{$dist}{mandrake} = $version
+ if $self->{data}{$dist};
+ }
+ }
+}
+
+sub _fetch_freebsd {
+ my $self = shift;
+ my $file = $self->cache->get_url("http://www.freebsd.org/ports/perl5.html",
+ "freebsd.html");
+
+#<DT><B><A NAME="p5-DBI-1.37"></A><A HREF="http://www.FreeBSD.org/cgi/cvsweb.cgi/ports/databases/p5-DBI-137">p5-DBI-1.37</A></B> </DT>
+ for my $package ($file =~ m/A NAME="p5-(.*?)"/g) {
+ my ($dist, $version) = $package =~ /^(.*?)-(\d.*)$/ or next;
+
+ # tidy up the oddness FreeBSD versions
+ $version =~ s/_\d$//;
+
+ # only populate if CPAN already has
+ $self->{data}{$dist}{freebsd} = $version
+ if $self->{data}{$dist};
+ }
+}
+
+sub _fetch_debian {
+ my $self = shift;
+
+ my %dists = map { lc $_ => $_ } keys %{ $self->{data} };
+ for my $dist (qw( stable testing unstable )) {
+ my $data =
+ $self->cache->get_url(
+ "http://ftp.debian.org/dists/$dist/main/binary-i386/Packages.gz",
+ "debian-$dist-Packages.gz");
+ $data = Compress::Zlib::memGunzip($data);
+
+ my $fh = IO::String->new($data);
+ my $debthing = Parse::Debian::Packages->new($fh);
+ while (my %package = $debthing->next) {
+ next
+ unless $package{Package} =~ /^lib(.*?)-perl$/
+ || $package{Package} =~ /^perl-(tk)$/;
+ my $dist = $dists{$1} or next;
+
+ # don't care about the debian version
+ my ($version) = $package{Version} =~ /^(.*?)-/;
+ $self->{data}{$dist}{debian} = $version
+ if $self->{data}{$dist};
+ }
+ }
+}
+
+sub _fetch_openbsd {
+ my $self = shift;
+ my $file =
+ $self->cache->get_url("http://www.openbsd.org/3.6_packages/i386.html",
+ "openbsd.html");
+
+ for my $package ($file =~ m/href=i386\/p5-(.*?)\.tgz-long/g) {
+ my ($dist, $version) = $package =~ /^(.*?)-(\d.*)$/ or next;
+
+ # only populate if CPAN already has
+ $self->{data}{$dist}{openbsd} = $version
+ if $self->{data}{$dist};
+ }
+}
+
+sub check {
+ my ($self, $dist) = @_;
+
+ return $self->{data}->{$dist};
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Module::Packaged - Report upon packages of CPAN distributions
+
+=head1 SYNOPSIS
+
+ use Module::Packaged;
+
+ my $p = Module::Packaged->new();
+ my $dists = $p->check('Archive-Tar');
+ # $dists is now:
+ # {
+ # cpan => '1.08',
+ # debian => '1.03',
+ # fedora => '0.22',
+ # freebsd => '1.07',
+ # gentoo => '1.05',
+ # openbsd => '0.22',
+ # suse => '0.23',
+ # }
+
+ # meaning that Archive-Tar is at version 1.08 on CPAN but only at
+ # version 1.07 on FreeBSD, version 1.05 on Gentoo, version 1.03 on
+ # Debian, version 0.23 on SUSE and version 0.22 on OpenBSD
+
+=head1 DESCRIPTION
+
+CPAN consists of distributions. However, CPAN is not an isolated
+system - distributions are also packaged in other places, such as for
+operating systems. This module reports whether CPAN distributions are
+packaged for various operating systems, and which version they have.
+
+Note: only CPAN, Debian, Fedora (Core 2), FreeBSD, Gentoo, Mandriva
+(10.1), OpenBSD (3.6) and SUSE (9.2) are currently supported. I want to
+support everything else. Patches are welcome.
+
+=head1 METHODS
+
+=head2 new()
+
+The new() method is a constructor:
+
+ my $p = Module::Packaged->new();
+
+=head2 check()
+
+The check() method returns a hash reference. The keys are various
+distributions, the values the version number included:
+
+ my $dists = $p->check('Archive-Tar');
+
+=head1 COPYRIGHT
+
+Copyright (c) 2003-5 Leon Brocard. All rights reserved. This program is
+free software; you can redistribute it and/or modify it under the same
+terms as Perl itself.
+
+=head1 AUTHOR
+
+Leon Brocard, leon at astray.com
+
Modified: packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm 2006-01-02 22:38:48 UTC (rev 1836)
@@ -1,239 +1,28 @@
package Module::Packaged;
use strict;
-use IO::File;
-use IO::Zlib;
-use File::Spec::Functions qw(catdir catfile tmpdir);
-use LWP::Simple qw(mirror);
-use Parse::CPAN::Packages;
-use Parse::Debian::Packages;
-use Sort::Versions;
-use Storable qw(store retrieve);
+use App::Cache;
+use Compress::Zlib;
+use LWP::Simple;
+use Storable qw(thaw);
use vars qw($VERSION);
-$VERSION = '0.76';
+$VERSION = '0.84';
sub new {
my $class = shift;
- my $self = {};
+ my $self = {};
bless $self, $class;
- # At some point I should unify these caching schemes, but for now
- # let's be ultra nice to the websites
- my $dir = tmpdir();
- $dir = catdir($dir, "mod_pac");
- mkdir $dir || die "Failed to mkdir $dir";
- chmod 0777, $dir || die "Failed to chmod $dir";
- $self->{DIR} = $dir;
-
- my $t = (stat "$dir/stored")[9];
-
- if (defined $t && (time - $t) < 3600) {
- # It's cached, excellent
- my $data = retrieve("$dir/stored") || die "Error reading: $!";
- $self->{data} = $data;
- } else {
- # Not cached, generate it
- $self->fetch_cpan;
- $self->fetch_debian;
- $self->fetch_fedora;
- $self->fetch_freebsd;
- $self->fetch_gentoo;
- $self->fetch_mandrake;
- $self->fetch_openbsd;
- $self->fetch_suse;
- store($self->{data}, "$dir/stored") || die "Error storing: $!";
- }
-
+ my $cache = App::Cache->new({ ttl => 60 * 60 });
+ my $data = $cache->get_url('http://www.astray.com/tmp/module_packaged.gz');
+ $self->{data} = thaw(uncompress($data));
return $self;
}
-sub mirror_file {
- my $self = shift;
- my $url = shift;
- my $file = shift;
- my $dir = $self->{DIR};
-
- my $filename = catfile($dir, $file);
- mirror($url, $filename);
- chmod 0666, $filename || die "Failed to chmod $filename";
-
- return $filename;
-}
-
-sub fetch_cpan {
- my $self = shift;
- my $filename = $self->mirror_file(
- "http://cpan.geekflat.org/modules/02packages.details.txt.gz",
- "02packages.gz" );
-
- my $fh = IO::Zlib->new;
- die "Error opening file $filename!" unless $fh->open($filename, "rb");
- my $details = join '', <$fh>;
- $fh->close;
-
- my $p = Parse::CPAN::Packages->new($details);
-
- foreach my $dist ($p->latest_distributions) {
- $self->{data}->{$dist->dist}->{cpan} = $dist->version;
- }
-}
-
-sub fetch_gentoo {
- my $self = shift;
-
- my $filename = $self->mirror_file(
- "http://www.gentoo.org/dyn/gentoo_pkglist_x86.txt",
- "gentoo.html");
-
- my $file = $self->slurp($filename);
- $file =~ s{</a></td>\n}{</a></td>}g;
-
- my @dists = keys %{$self->{data}};
-
- foreach my $line (split "\n", $file) {
- next unless ($line =~ m/dev-perl/);
- my $dist;
- $line =~ s/\.ebuild//g;
- my ($package, $version, $trash) = split(' ', $line);
- next unless $package;
-
- # Let's try to find a cpan dist that matches the package name
- if (exists $self->{data}->{$package}) {
- $dist = $package;
- } else {
- foreach my $d (@dists) {
- if (lc $d eq lc $package) {
- $dist = $d;
- last;
- }
- }
- }
-
- if ($dist) {
- $self->{data}->{$dist}->{gentoo} = $version;
- } else {
- # I should probably care about these and fix them
- # warn "Could not find $package: $version\n";
- }
- }
-}
-
-sub fetch_fedora {
- my $self = shift;
- my $filename = $self->mirror_file( "http://fedora.redhat.com/projects/package-list/", "fedora.html" );
- my $file = $self->slurp($filename);
-
- foreach my $line (split "\n", $file) {
- next unless $line =~ /^perl-/;
- my($dist, $version) = $line =~ m{perl-(.*?)</td><td class="column-2">(.*?)</td>};
-
- # only populate if CPAN already has
- $self->{data}{$dist}{fedora} = $version
- if $self->{data}{$dist};
- }
-}
-
-sub fetch_suse {
- my $self = shift;
- my $filename = $self->mirror_file( "http://www.suse.de/us/private/products/suse_linux/i386/packages_professional/index_all.html", "suse.html" );
- my $file = $self->slurp($filename);
-
- foreach my $line (split "\n", $file) {
- my($dist, $version) = $line =~ m{">perl-(.*?) (.*?) </a>};
- next unless $dist;
-
- # only populate if CPAN already has
- $self->{data}{$dist}{suse} = $version
- if $self->{data}{$dist};
- }
-}
-
-sub fetch_mandrake {
- my $self = shift;
- my $filename = $self->mirror_file("http://www.mandrakelinux.com/en/10.0/features/15.php3", "mandrake.html" );
- my $file = $self->slurp($filename);
-
- foreach my $line (split "\n", $file) {
- next unless $line =~ /^perl-/;
- my($dist, $version) = $line =~ m{perl-(.*?)-(.*?)-\d+mdk};
- next unless $dist;
-
- # only populate if CPAN already has
- $self->{data}{$dist}{mandrake} = $version
- if $self->{data}{$dist};
- }
-}
-sub fetch_freebsd {
- my $self = shift;
- my $filename = $self->mirror_file( "http://www.freebsd.org/ports/perl5.html",
- "freebsd.html" );
- my $file = $self->slurp($filename);
-
- for my $package ($file =~ m/a id="p5-(.*?)"/g) {
- my ($dist, $version) = $package =~ /^(.*?)-(\d.*)$/ or next;
- # tidy up the oddness that is p5-DBI-137-1.37
- $version =~ s/^\d+-//;
-
- # only populate if CPAN already has
- $self->{data}{$dist}{freebsd} = $version
- if $self->{data}{$dist};
- }
-}
-
-sub fetch_debian {
- my $self = shift;
-
- my %dists = map { lc $_ => $_ } keys %{ $self->{data} };
- for my $dist (qw( stable testing unstable )) {
- my $filename = $self->mirror_file(
- "http://ftp.debian.org/dists/$dist/main/binary-i386/Packages.gz",
- "debian-$dist-Packages.gz" );
-
- my $fh = IO::Zlib->new;
- die "Error opening file $filename!" unless $fh->open($filename, "rb");
-
- my $debthing = Parse::Debian::Packages->new( $fh );
- while (my %package = $debthing->next) {
- next unless $package{Package} =~ /lib(.*?)-perl$/;
- my $dist = $dists{ $1 } or next;
- # don't care about the debian version
- my ($version) = $package{Version} =~ /^(.*?)-/;
-
- $self->{data}{$dist}{debian} = $version
- if $self->{data}{$dist};
- }
- }
-}
-
-sub fetch_openbsd {
- my $self = shift;
- my $filename = $self->mirror_file(
- "http://www.openbsd.org/3.4_packages/i386.html",
- "openbsd.html" );
- my $file = $self->slurp($filename);
-
- for my $package ($file =~ m/href=i386\/p5-(.*?)\.tgz-long/g) {
- my ($dist, $version) = $package =~ /^(.*?)-(\d.*)$/ or next;
-
- # only populate if CPAN already has
- $self->{data}{$dist}{openbsd} = $version
- if $self->{data}{$dist};
- }
-}
-
sub check {
- my($self, $dist) = @_;
-
+ my ($self, $dist) = @_;
return $self->{data}->{$dist};
}
-sub slurp {
- my($self, $filename) = @_;
- open(IN, $filename) || die "Module::Packaged: Error opening file $filename!";
- my $content = join '', <IN>;
- close IN;
- return $content;
-}
-
1;
__END__
@@ -244,7 +33,7 @@
=head1 SYNOPSIS
- use Module::Packages;
+ use Module::Packaged;
my $p = Module::Packaged->new();
my $dists = $p->check('Archive-Tar');
@@ -270,13 +59,30 @@
operating systems. This module reports whether CPAN distributions are
packaged for various operating systems, and which version they have.
-Note: only CPAN, Debian, Fedora, FreeBSD, Gentoo, Mandrake, OpenBSD
-and SUSE are currently supported. I want to support everything
-else. Patches are welcome.
+Only CPAN, Debian, Fedora (Core 2), FreeBSD, Gentoo, Mandriva (10.1),
+OpenBSD (3.6) and SUSE (9.2) are currently supported. I want to support
+everything else. Patches are welcome.
+The data is fetched from the net and cached for an hour.
+
+=head1 METHODS
+
+=head2 new()
+
+The new() method is a constructor:
+
+ my $p = Module::Packaged->new();
+
+=head2 check()
+
+The check() method returns a hash reference. The keys are various
+distributions, the values the version number included:
+
+ my $dists = $p->check('Archive-Tar');
+
=head1 COPYRIGHT
-Copyright (c) 2003-4 Leon Brocard. All rights reserved. This program is
+Copyright (c) 2003-5 Leon Brocard. All rights reserved. This program is
free software; you can redistribute it and/or modify it under the same
terms as Perl itself.
Added: packages/libmodule-packaged-perl/branches/upstream/current/t/pod.t
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/t/pod.t 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/t/pod.t 2006-01-02 22:38:48 UTC (rev 1836)
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD: $@" if $@;
+all_pod_files_ok();
Added: packages/libmodule-packaged-perl/branches/upstream/current/t/pod_coverage.t
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/t/pod_coverage.t 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/t/pod_coverage.t 2006-01-02 22:38:48 UTC (rev 1836)
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Modified: packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t 2006-01-02 22:36:53 UTC (rev 1835)
+++ packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t 2006-01-02 22:38:48 UTC (rev 1836)
@@ -4,8 +4,8 @@
use Test::More tests => 4;
use_ok('Module::Packaged');
-warn "\n# These tests take a while to run as we need to mirror large\n";
-warn "# files from the web and then parse them. Please be patient.\n";
+warn "\n# These tests take a while to run as we need to mirror a large\n";
+warn "# file from the web. Please be patient.\n";
my $p = Module::Packaged->new();
@@ -16,23 +16,26 @@
$dists = $p->check('Archive-Tar');
is_deeply($dists, {
- cpan => '1.10',
- debian => '1.08',
+ cpan => '1.24',
+ debian => '1.23',
fedora => '1.08',
- freebsd => '1.08_1',
- gentoo => '1.09',
- openbsd => '1.03',
+ freebsd => '1.24',
+ gentoo => '1.23',
+ mandrake => '1.23',
+ openbsd => '1.08',
suse => '1.08',
}, 'Archive-Tar');
$dists = $p->check('DBI');
is_deeply($dists, {
- cpan => '1.43',
- debian => '1.43',
+ cpan => '1.48',
+ debian => '1.48',
fedora => '1.40',
- freebsd => '1.37',
- gentoo => '1.38',
- mandrake => '1.40',
- openbsd => '1.37',
- suse => '1.41',
+ freebsd => '1.48',
+ gentoo => '1.46',
+ mandrake => '1.47',
+ openbsd => '1.43',
+ suse => '1.47',
}, 'DBI');
+
+
More information about the Pkg-perl-cvs-commits
mailing list