Last active
August 29, 2015 14:22
-
-
Save skaji/4856eca9c794b8b27916 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use utf8; | |
use warnings; | |
use CPAN::Meta::Requirements; | |
use CPAN::Meta; | |
use Carton::CPANfile; | |
use Carton::Dist; | |
use Carton::Snapshot; | |
use Config; | |
use Perl::PrereqDistributionGatherer; | |
my $g = Perl::PrereqDistributionGatherer->new; | |
my ($dists, $core, $miss) = $g->gather_from_cpanfile( | |
"cpanfile", | |
inc => ["local/lib/perl5/$Config{archname}", "local/lib/perl5"], | |
); | |
my $snapshot = Carton::Snapshot->new(path => "cpanfile.snapshot"); | |
for (sort { $a->name cmp $b->name } @$dists) { | |
my $dist = $_->install_json_hash; | |
my $prereqs = CPAN::Meta->load_file($_->mymeta_json)->effective_prereqs; | |
my $reqs = CPAN::Meta::Requirements->new; | |
$reqs->add_requirements($prereqs->requirements_for($_, 'requires')) | |
for qw( configure build runtime ); | |
$snapshot->add_distribution( | |
Carton::Dist->new( | |
name => $dist->{dist}, | |
pathname => $dist->{pathname}, | |
provides => $dist->{provides}, | |
version => $dist->{version}, | |
requirements => $reqs, | |
) | |
); | |
} | |
$snapshot->save; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment