Skip to content

Instantly share code, notes, and snippets.

@skaji
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skaji/4856eca9c794b8b27916 to your computer and use it in GitHub Desktop.
Save skaji/4856eca9c794b8b27916 to your computer and use it in GitHub Desktop.
#!/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