-
Notifications
You must be signed in to change notification settings - Fork 0
/
unify-lib.pl
executable file
·36 lines (31 loc) · 1008 Bytes
/
unify-lib.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!perl
use strict;
use warnings;
use Cwd qw( getcwd realpath );
use CPAN::DistnameInfo;
use constant SOURCEDIR => ( getcwd . '/dists-unpacked' );
use constant TARGETDIR => ( getcwd . '/lib' );
if ( !-e TARGETDIR ) {
mkdir TARGETDIR or die "Can't make " . TARGETDIR;
}
open my $dist_fh, '<', 'dists.list' or die "Can't open dists.list";
while ( my $dist = <$dist_fh> ) {
chomp $dist;
$dist =~ s/#.*$//;
next if $dist =~ /^\s*$/;
my $info = CPAN::DistnameInfo->new($dist);
my $newname = $info->dist;
my $indir = SOURCEDIR . '/' . $newname;
if ( not -e $indir ) {
warn "* $indir does not exist, not unpacking\n";
next;
}
opendir my $dh, "$indir/lib" or die "Can't copy libs from $indir";
while ( my $node = readdir $dh ) {
next if $node eq '.';
next if $node eq '..';
system( "cp", "-r", "-v", "-x", "-P", "-t", TARGETDIR,
"$indir/lib/$node" ) == 0
or die "Can't copy $indir/lib/$node";
}
}