perl
view release on metacpan or search on metacpan
Porting/add-package.pl view on Meta::CPAN
}
my $TopDirRe = quotemeta( $TopDir . '/' );
### copy over t/ and bin/ directories to the $TopDir
my @TestFiles;
{ print "Copying t/* files to $TopDir..." if $Verbose;
-d 't'
? system( "cp -fR $CPV t $TopDir" ) && die "Copy of t/ failed: $?"
: warn "No t/ directory found\n";
@TestFiles = map { chomp; s|^$TopDirRe||; s|//|/|g; $_ }
### should we get rid of this file?
grep { $ExcludeRe && $_ =~ $ExcludeRe
? do { warn "Removing $_\n";
system("rm $TopDir/$_") and die "rm '$_' failed: $?";
undef
}
: 1
} `find t -type f`
or die "Could not detect testfiles\n";
print "done\n" if $Verbose;
}
my $BinDir;
my @BinFiles;
my $TopBinDir;
BIN: {
$BinDir = -d 'bin' ? 'bin' :
-d 'scripts' ? 'scripts' : undef ;
unless ($BinDir) {
print "No bin/ or scripts/ directory found\n" if $Verbose;
last BIN;
}
my $TopBinDir = "$TopDir/$BinDir/";
print "Copying $BinDir/* files to $TopBinDir..." if $Verbose;
my $CopyCmd = "cp -fR $CPV $BinDir $TopDir";
print "Running '$CopyCmd'..." if $Verbose;
system($CopyCmd) && die "Copy of $BinDir failed: $?";
@BinFiles = map { chomp; s|^$TopDirRe||; s|//|/|g; $_ }
### should we get rid of this file?
grep { $ExcludeRe && $_ =~ $ExcludeRe
? do { warn "Removing $_\n";
system("rm $TopDir/$_") and die "rm '$_' failed: $?";
undef
}
: 1
} `find $BinDir -type f`
or die "Could not detect binfiles\n";
print "done\n" if $Verbose;
}
### copy over change log
my @Changes;
foreach my $cl (split m/\s+/ => $Changes) {
-f $cl or next;
push @Changes, $cl;
print "Copying $cl files to $TopDir..." if $Verbose;
system( "cp -f $CPV $cl $TopDir" )
and die "Copy of $cl failed: $?";
}
### add files where they are required
my @NewFiles;
my @ChangedFiles;
{ for my $bin ( map { basename( $_ ) } @BinFiles ) {
print "Registering $bin with system files...\n";
### fix installperl, so these files get installed by other utils
### ./installperl: return if $name =~
### /^(?:cpan|instmodsh|prove|corelist|ptar|ptardiff)\z/;
{ my $file = 'installperl';
### not there already?
unless( `grep $TestBin $Repo/$file| grep $bin` ) {
print " Adding $bin to $file..." if $Verbose;
### double \\| required --> once for in this script, once
### for the cli
system("$^X -pi -e 's/($TestBin\\|)/$bin|\$1/' $Repo/$file")
and die "Could not add $bin to $file: $?";
print "done\n" if $Verbose;
push @ChangedFiles, $file;
} else {
print " $bin already mentioned in $file\n" if $Verbose;
}
}
### fix utils.lst, so the new tools are mentioned
{ my $file = 'utils.lst';
### not there already?
unless( `grep $bin $Repo/$file` ) {
print " Adding $bin to $file..." if $Verbose;
### double \\| required --> once for in this script, once
### for the cli
system("$^X -pi -e 's!($TestBin)!\$1\nutils/$bin!' $Repo/$file")
and die "Could not add $bin to $file: $?";
print "done\n" if $Verbose;
push @ChangedFiles, $file;
} else {
print " $bin already mentioned in $file\n" if $Verbose;
}
}
### make a $bin.PL file and fix it up
{ my $src = "utils/${TestBin}.PL";
my $file = "utils/${bin}.PL";
### not there already?
unless( -e "$Repo/$file" ) {
print " Creating $file..." if $Verbose;
( run in 2.246 seconds using v1.01-cache-2.11-cpan-71847e10f99 )