r105 - in packages: . libmodule-packaged-perl libmodule-packaged-perl/branches libmodule-packaged-perl/branches/upstream libmodule-packaged-perl/branches/upstream/current libmodule-packaged-perl/branches/upstream/current/lib libmodule-packaged-perl/branches/upstream/current/lib/Module libmodule-packaged-perl/branches/upstream/current/t
Allard Hoeve
hoeve-guest@haydn.debian.org
Thu, 10 Jun 2004 07:59:09 -0600
Author: hoeve-guest
Date: 2004-06-10 07:59:05 -0600 (Thu, 10 Jun 2004)
New Revision: 105
Added:
packages/libmodule-packaged-perl/
packages/libmodule-packaged-perl/branches/
packages/libmodule-packaged-perl/branches/upstream/
packages/libmodule-packaged-perl/branches/upstream/current/
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/MANIFEST.SKIP
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/NINJA
packages/libmodule-packaged-perl/branches/upstream/current/README
packages/libmodule-packaged-perl/branches/upstream/current/lib/
packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/
packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm
packages/libmodule-packaged-perl/branches/upstream/current/t/
packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t
packages/libmodule-packaged-perl/tags/
Log:
[svn-inject] Installing original source of libmodule-packaged-perl
Added: packages/libmodule-packaged-perl/branches/upstream/current/Build.PL
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/Build.PL 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/Build.PL 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,19 @@
+use strict;
+use Module::Build;
+
+my $build = Module::Build->new(
+ create_makefile_pl => 'traditional',
+ license => 'perl',
+ module_name => 'Module::Packaged',
+ requires => {
+ 'Cache::Cache' => '1.02',
+ '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',
+ 'Parse::Debian::Packages' => '0.01',
+ },
+);
+$build->create_build_script;
Added: packages/libmodule-packaged-perl/branches/upstream/current/CHANGES
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/CHANGES 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/CHANGES 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,36 @@
+Revision history for Perl module Module::Packaged.
+
+0.74 Thu Apr 22 17:17:21 BST 2004
+ - resupport Gentoo (thanks to patch from Michael Cummings)
+ - remove Perl6::Slurp dependency (sorry, too many deps)
+ - make it work with Parse::CPAN::Packages 2.20 (oops)
+ - added support for Fedora, Mandrake and SUSE
+ - updated the tests
+
+0.73 Thu Mar 4 09:33:38 GMT 2004
+ - use Perl6::Slurp instead of File::Slurp
+ - remove Gentoo support (the URL we were using is now a 404 and
+ packages.gentoo.org isn't easy to scrape)
+ - report OpenBSD packages in 3.4 (3.2 is old now)
+ - updated the tests
+ - now use Parse::CPAN::Packages
+
+0.72 Wed Jan 7 16:25:31 GMT 2004
+ - a new version of Archive::Tar came out, update the tests
+
+0.71 Mon Jan 5 16:14:32 GMT 2004
+ - a new version of DBI came out, update the tests
+
+0.67 Tue Nov 18 22:16:11 GMT 2003
+ - added OpenBSD support (thanks to Richard Clamp, again)
+
+0.54 Mon Nov 17 22:42:42 GMT 2003
+ - added Debian support (thanks to Richard Clamp)
+ - reworked caching
+
+0.41 Mon Nov 17 17:55:35 GMT 2003
+ - support FreeBSD too (thanks to Richard Clamp)
+ - added NINJA support
+
+0.34 Thu Nov 13 19:53:01 GMT 2003
+ - initial release
Added: packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,10 @@
+Build.PL
+CHANGES
+Makefile.PL
+MANIFEST This list of files
+MANIFEST.SKIP
+META.yml
+NINJA
+README
+lib/Module/Packaged.pm
+t/simple.t
Added: packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/MANIFEST.SKIP 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,31 @@
+_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
Added: packages/libmodule-packaged-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/META.yml 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/META.yml 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,22 @@
+--- #YAML:1.0
+name: Module-Packaged
+version: 0.74
+license: perl
+distribution_type: module
+requires:
+ Cache::Cache: 1.02
+ IO::File: 1.08
+ IO::Zlib: 1.01
+ LWP::Simple: 1.38
+ Parse::CPAN::Packages: 2.20
+ Parse::Debian::Packages: 0.01
+ Sort::Versions: 1.50
+ Test::More: 0.47
+recommends: {}
+build_requires: {}
+conflicts: {}
+provides:
+ Module::Packaged:
+ file: lib/Module/Packaged.pm
+ version: 0.74
+generated_by: Module::Build version 0.21
Added: packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/Makefile.PL 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,20 @@
+# Generated by Module::Build::Compat->create_makefile_pl
+
+use ExtUtils::MakeMaker;
+WriteMakefile
+ (
+ NAME => 'Module::Packaged',
+ VERSION => '0.74',
+ PL_FILES => {},
+ INSTALLDIRS => 'site',
+ PREREQ_PM => {
+ 'Parse::CPAN::Packages' => '2.20',
+ 'Cache::Cache' => '1.02',
+ 'Sort::Versions' => '1.50',
+ 'IO::Zlib' => '1.01',
+ 'IO::File' => '1.08',
+ 'Parse::Debian::Packages' => '0.01',
+ 'Test::More' => '0.47',
+ 'LWP::Simple' => '1.38',
+ },
+ );
Added: packages/libmodule-packaged-perl/branches/upstream/current/NINJA
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/NINJA 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/NINJA 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,8 @@
+--- #YAML:1.0
+attributes:
+ charisma: 0.33
+ constitution: 0.47
+ dexterity: 1.00
+ intelligence: 0.27
+ strength: 0.93
+ wisdom: 0.87
Added: packages/libmodule-packaged-perl/branches/upstream/current/README
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/README 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/README 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,39 @@
+NAME
+ Module::Packaged - Report upon packages of CPAN distributions
+
+SYNOPSIS
+ use Module::Packages;
+
+ my $p = Module::Packaged->new();
+ my $dists = $p->check('Archive-Tar');
+ # $dists is now:
+ # {
+ # cpan => '1.08',
+ # debian => '1.03',
+ # freebsd => '1.07',
+ # gentoo => '1.03',
+ # openbsd => '0.22',
+ # }
+
+ # 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
+
+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, FreeBSD, Gentoo, and OpenBSD are currently
+ supported. I want to support versions of PPM, and Redhat. Patches are
+ welcome.
+
+COPYRIGHT
+ Copyright (c) 2003 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.
+
+AUTHOR
+ Leon Brocard, leon@astray.com
+
Added: packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/lib/Module/Packaged.pm 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,297 @@
+package Module::Packaged;
+use strict;
+use Cache::FileCache;
+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 vars qw($VERSION);
+$VERSION = '0.74';
+
+sub new {
+ my $class = shift;
+ 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;
+
+ # The data takes a while to parse, so let's cache it
+ my $cache = Cache::FileCache->new({
+ 'namespace' => 'module_packaged',
+ 'default_expires_in' => '1 hour',
+ 'cache_depth' => 1,
+ });
+
+ my $data = $cache->get('data');
+ if (defined $data) {
+ # It's cached, excellent
+ $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;
+ $cache->set('data', $self->{data});
+ }
+
+ return $self;
+}
+
+sub cache {
+ my $self = shift;
+ return $self->{cache};
+}
+
+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) = @_;
+
+ 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__
+
+=head1 NAME
+
+Module::Packaged - Report upon packages of CPAN distributions
+
+=head1 SYNOPSIS
+
+ use Module::Packages;
+
+ 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, FreeBSD, Gentoo, Mandrake, OpenBSD
+and SUSE are currently supported. I want to support everything
+else. Patches are welcome.
+
+=head1 COPYRIGHT
+
+Copyright (c) 2003-4 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@astray.com
+
Added: packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t
===================================================================
--- packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t 2004-06-10 13:58:12 UTC (rev 104)
+++ packages/libmodule-packaged-perl/branches/upstream/current/t/simple.t 2004-06-10 13:59:05 UTC (rev 105)
@@ -0,0 +1,38 @@
+#!/usr/bin/perl -w
+
+use strict;
+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";
+
+my $p = Module::Packaged->new();
+
+my $dists = $p->check('Acme-Buffy');
+is_deeply($dists, {
+ cpan => '1.3',
+}, 'Acme-Buffy');
+
+$dists = $p->check('Archive-Tar');
+is_deeply($dists, {
+ cpan => '1.08',
+ debian => '1.08',
+ fedora => '0.22',
+ freebsd => '1.08',
+ gentoo => '1.05',
+ openbsd => '1.03',
+ suse => '0.23',
+}, 'Archive-Tar');
+
+$dists = $p->check('DBI');
+is_deeply($dists, {
+ cpan => '1.42',
+ debian => '1.41',
+ fedora => '1.37',
+ freebsd => '1.37',
+ gentoo => '1.38',
+ mandrake => '1.40',
+ openbsd => '1.37',
+ suse => '1.37',
+}, 'DBI');