Skip to content

Commit

Permalink
Merge pull request #29 from perlpunk/metajson
Browse files Browse the repository at this point in the history
Read from META.json and more
  • Loading branch information
perlpunk committed May 4, 2021
2 parents aa5d1a0 + fd0f05b commit 2e4901d
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 71 deletions.
38 changes: 38 additions & 0 deletions Dockerfile
@@ -0,0 +1,38 @@
FROM opensuse/leap:15.2

RUN zypper refresh \
&& zypper install -y \
osc \
perl \
perl-YAML-LibYAML \
perl-XML-Simple \
perl-Parse-CPAN-Packages \
procmail \
wget \
vim \
git \
perl-Text-Autoformat \
perl-YAML \
perl-Pod-POM \
perl-libwww-perl \
perl-Class-Accessor-Chained \
perl-Perl-PrereqScanner \
perl-Algorithm-Diff \
perl-Module-Build-Tiny \
perl-ExtUtils-Depends \
perl-ExtUtils-PkgConfig \
obs-service-format_spec_file \
&& true


RUN cd /tmp && wget http://www.cpan.org/modules/02packages.details.txt.gz

ENV LANG=en_US.UTF-8 \
LC_CTYPE="en_US.UTF-8" \
LC_NUMERIC="en_US.UTF-8" \
LC_TIME="en_US.UTF-8" \
LC_COLLATE="en_US.UTF-8"


# perl /cpanspec/cpanspec -v -f --skip-changes --pkgdetails /tmp/02packages.details.txt.gz tarball

82 changes: 82 additions & 0 deletions bin/batch.pl
@@ -0,0 +1,82 @@
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Data::Dumper;
use Getopt::Long;

GetOptions(
"debug" => \my $debug,
"dry" => \my $dry,
"help|h" => \my $help,
) # flag
or die "Error in command line arguments";

if ($help) {
print <<'EOM';
Usage:
batch.pl /path/to/packages 0 50 # process the first 51 packages
EOM
exit;
}

my ($dir, $from, $to) = @ARGV;
$from ||= 0;
$to ||= $from;

my @skip = qw/
perl-AcePerl
perl-Acme-MetaSyntactic
perl-Acme-Ook
perl-Algorithm-Munkres
perl-Alien-LibGumbo
perl-Alien-SVN
perl-Alien-Tidyp
perl-Apache-AuthNetLDAP
perl-Apache-Filter
perl-Apache-SessionX
perl-Apache-Gallery
perl-App-ProcIops
perl-App-Nopaste
perl-App-SVN-Bisect
perl-App-gcal
perl-Array-Dissect
perl-Audio-CD
perl-Authen-SASL-Cyrus
perl-BIND-Conf_Parser
perl-BSXML
perl-Boost-Geometry-Utils
perl-Class-Accessor-Chained
Class-Multimethods
perl-Crypt-HSXKPasswd
perl-Crypt-Rot13
/;
my %skip;
@skip{ @skip } = ();

opendir my $dh, $dir or die $!;
my @pkgs = sort grep {
-d "$dir/$_" && m/^perl-/
and not exists $skip{ $_ }
} readdir $dh;
closedir $dh;

my $count = @pkgs;
say "Total: $count";

my $opt_debug = $debug ? '--debug' : '';
for my $i ($from .. $to) {
my $pkg = $pkgs[ $i ];
chdir $dir;
say "=========== ($i) $pkg";
next if $dry;
chdir $pkg;
my $mod = $pkg;
$mod =~ s/^perl-//;
my @glob = glob("$mod*");
my $cmd = qq{cpanspec $opt_debug -v -f --skip-changes --pkgdetails /tmp/02packages.details.txt.gz @glob 2>&1};
say "Cmd: $cmd";
my $out = qx{$cmd};
say $out;

}
26 changes: 26 additions & 0 deletions bin/intrusive.pl
@@ -0,0 +1,26 @@
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use JSON::PP;
use File::Basename qw/ dirname /;
my $bin = dirname(__FILE__);
require "$bin/../lib/Intrusive.pm";

my $coder = JSON::PP->new->utf8->pretty->canonical;

my ($path) = @ARGV;

# Makefile.PL etc. might print things to STDOUT, temporary redirect
# to STDERR
open my $orig, ">&", STDOUT;
open STDOUT, ">&STDERR";

my $deps = Intrusive->new->dist_dir($path)->find_modules;

# restore STDOUT
open STDOUT, ">&", $orig;

my $json = $coder->encode({%$deps});
print $json;

0 comments on commit 2e4901d

Please sign in to comment.