This is an automated email from the git hooks/post-receive script.

kanashiro-guest pushed a commit to branch master
in repository carton.

commit 520305ad21e6a48753a9748a594296136ce7a99f
Author: Tatsuhiko Miyagawa <miyag...@bulknews.net>
Date:   Sat Aug 10 21:15:11 2013 -0700

    Load extra modules for fatpack, detected from Carton's MYMETA files
---
 lib/Carton/Packer.pm | 59 +++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 52 insertions(+), 7 deletions(-)

diff --git a/lib/Carton/Packer.pm b/lib/Carton/Packer.pm
index 9d604b6..e261be2 100644
--- a/lib/Carton/Packer.pm
+++ b/lib/Carton/Packer.pm
@@ -3,6 +3,8 @@ use strict;
 use App::FatPacker;
 use File::pushd ();
 use Path::Tiny ();
+use CPAN::Meta ();
+use File::Find ();
 
 use Moo;
 
@@ -23,10 +25,22 @@ $Carton::Fatpacked = 1;
 exit Carton::CLI->new->run(@ARGV);
 EOF
 
-    my $packer = App::FatPacker->new;
+    my $fatpacked = $self->do_fatpack($file);
+
+    my $executable = $dir->child('carton');
+    warn "Bundling $executable\n";
+
+    $dir->mkpath;
+    $executable->spew($fatpacked);
+    chmod 0755, $executable;
+}
 
-    my @modules = split /\r?\n/, $packer->trace(args => [$file], use => 
['App::cpanminus']);
+sub do_fatpack {
+    my($self, $file) = @_;
+
+    my $packer = App::FatPacker->new;
 
+    my @modules = split /\r?\n/, $packer->trace(args => [$file], use => 
$self->required_modules);
     my @packlists = $packer->packlists_containing(\@modules);
     $packer->packlists_to_tree(Path::Tiny->new('fatlib')->absolute, 
\@packlists);
 
@@ -39,12 +53,43 @@ EOF
     use Config;
     $fatpacked =~ 
s/\$fatpacked{"$Config{archname}\/(Cwd|File)/\$fatpacked{"$1/g;
 
-    my $executable = $dir->child('carton');
-    warn "Bundling $executable\n";
+    $fatpacked;
+}
 
-    $dir->mkpath;
-    $executable->spew($fatpacked);
-    chmod 0755, $executable;
+sub required_modules {
+    my($self, $packer) = @_;
+
+    my $meta = $self->installed_meta('Carton')
+        or die "Couldn't find install metadata for Carton";
+
+    my %excludes = (
+        perl => 1,
+        'ExtUtils::MakeMaker' => 1,
+        'Module::Build' => 1,
+    );
+
+    my @requirements = grep !$excludes{$_},
+        $meta->effective_prereqs->requirements_for('runtime', 
'requires')->required_modules;
+
+    return \@requirements;
+}
+
+sub installed_meta {
+    my($self, $dist) = @_;
+
+    my @meta;
+    my $finder = sub {
+        if (m!\b$dist-.*[\\/]MYMETA.json!) {
+            push @meta, CPAN::Meta->load_file($_);
+        }
+    };
+
+    File::Find::find({ wanted => $finder, no_chdir => 1 }, grep -d, map 
"$_/.meta", @INC);
+
+    # return the latest version
+    @meta = sort { version->new($b->version) cmp version->new($a->version) } 
@meta;
+
+    return $meta[0];
 }
 
 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/carton.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to