Skip to content

Commit

Permalink
Generate META files if not included
Browse files Browse the repository at this point in the history
Resolves skaji#230
  • Loading branch information
morckx committed Sep 9, 2024
1 parent af15536 commit 88cc0a6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/App/cpm/Worker/Installer.pm
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ sub enable_prebuilt {
$self->{prebuilt} && !$self->{prebuilt}->skip($uri) && $TRUSTED_MIRROR->($uri);
}

sub mymeta2meta {
my ($input_file, $output_file) = @_;
open my $in, '<', $input_file or die "Cannot open $input_file: $!";
open my $out, '>', $output_file or die "Cannot open $output_file: $!";
while (my $line = <$in>) {
$line =~ s/(.*dynamic_config.* )0/$1 1/; # Apply the substitution
print $out $line; # Write the modified line to the output file
}
close $in;
close $out;
}

sub fetch {
my ($self, $task) = @_;
my $guard = pushd;
Expand Down Expand Up @@ -213,6 +225,13 @@ sub fetch {

chdir $dir or die;

if ((! -f 'META.json' || ! -f 'META.yml') && (-f 'Makefile.PL' || -f 'Build.PL')) {
$self->{logger}->log("Configuring distribution via Makefile.PL or Build.PL");
system('perl Makefile.PL') == 0 or system('perl Build.PL') == 0 or die "Failed to run Makefile.PL or Build.PL: $!";
mymeta2meta('MYMETA.json', 'META.json');
mymeta2meta('MYMETA.yml', 'META.yml');
}

my $meta = $self->_load_metafile($distfile, 'META.json', 'META.yml');
if (!$meta) {
$self->{logger}->log("Distribution does not have META.json nor META.yml");
Expand Down

0 comments on commit 88cc0a6

Please sign in to comment.