Skip to content

Commit

Permalink
use perl-cpan-index-generate
Browse files Browse the repository at this point in the history
  • Loading branch information
skaji committed Oct 19, 2024
1 parent e8a3136 commit 9eb9451
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
33 changes: 5 additions & 28 deletions author/fatpack.pl
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,9 @@ ()
Path::Tiny->new($dir)->remove_tree({ safe => 0 }) if -d $dir;
}

sub generate_index ($from) {
my @index;
my $visit = sub ($path, $state) {
return if $path !~ /install\.json$/;
state $JSON = JSON::XS->new;
my $install = $JSON->decode($path->slurp_utf8);
for my ($package, $option) ($install->{provides}->%*) {
push @index, {
package => $package,
version => $option->{version},
pathname => $install->{pathname},
};
}
};
Path::Tiny->new($from)->visit($visit, { recurse => 1 });

my $out = "";
for my $index (sort { lc($a->{package}) cmp lc($b->{package}) } @index) {
$out .= sprintf "%s %s %s\n",
$index->{package}, $index->{version} || 'undef', $index->{pathname};
}
$out;
sub generate_index ($from, $file) {
my $exit = system "perl-cpan-index-generate", "--output", $file, $from;
$exit == 0 or die;
}

sub git_info () {
Expand Down Expand Up @@ -148,17 +129,13 @@ ($file, $describe, $url)
if (-f "index.txt" && !$force && !$test && !$update_only) {
@resolver = ("-r", "02packages,index.txt,https://cpan.metacpan.org/", "--no-default-resolvers");
} else {
@resolver = ("-r", 'Fixed,CPAN::Meta::[email protected]', "-r", "metadb");
@resolver = ("-r", 'Fixed,CPAN::Meta::[email protected]');
}

warn "Resolver: @resolver\n";
cpm "install", "--target-perl", $target, @resolver, "--cpmfile", "../cpm.yml";
cpm "install", "--target-perl", $target, @resolver, @extra;
if (!$test) {
my $fh = Path::Tiny->new("index.txt")->openw_raw;
$fh->print("# This file was automatically generated by fatpack.pl\n\n");
$fh->print(generate_index "local/lib/perl5");
}
generate_index "local/lib/perl5", "index.txt" if !$test;
remove_version_xs;
exit if $update_only;

Expand Down
2 changes: 1 addition & 1 deletion author/index.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was automatically generated by fatpack.pl
# This file was generated by perl-cpan-index-generate.

Algorithm::C3 0.11 H/HA/HAARG/Algorithm-C3-0.11.tar.gz
Capture::Tiny 0.48 D/DA/DAGOLDEN/Capture-Tiny-0.48.tar.gz
Expand Down

0 comments on commit 9eb9451

Please sign in to comment.