This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Time-Piece to CPAN version 1.23
[perl5.git] / Porting / sync-with-cpan
index e6f59b1..c3f9ce1 100755 (executable)
@@ -2,7 +2,7 @@
 
 =head1 NAME
 
-Porting/sync-with-cpan
+Porting/sync-with-cpan - Synchronize with CPAN distributions
 
 =head1 SYNOPSIS
 
@@ -127,6 +127,7 @@ use 5.010;
 use strict;
 use warnings;
 use Getopt::Long;
+use Archive::Tar;
 
 $| = 1;
 
@@ -146,6 +147,10 @@ my $package      = "02packages.details.txt";
 my $package_url  = "http://www.cpan.org/modules/$package";
 my $package_file = "/tmp/$package";
 
+my @problematic = (
+    'podlators', # weird CUSTOMIZED section due to .PL files
+);
+
 
 GetOptions ('tarball=s'  =>  \my $tarball,
             'version=s'  =>  \my $version,
@@ -162,7 +167,7 @@ my  $info         = $Modules {$module} or die "Cannot find module $module";
 my  $distribution = $$info {DISTRIBUTION};
 
 my @files         = glob $$info {FILES};
-if (!-d $files [0]) {
+if (!-d $files [0] || grep { $_ eq $module } @problematic) {
     say "This looks like a setup $0 cannot handle (yet)";
     unless ($force) {
         say "Will not continue without a --force option";
@@ -225,8 +230,8 @@ say "Cleaning out old directory";
 system git => 'clean', '-dfxq', $pkg_dir;
 
 say "Unpacking $new_file";
+Archive::Tar->extract_archive( $new_file );
 
-system tar => 'xfz', $new_file;
 (my $new_dir = $new_file) =~ s/\.tar\.gz//;
 # ensure 'make' will update all files
 system('find', $new_dir, '-exec', 'touch', '{}', ';');
@@ -264,6 +269,9 @@ FILE: for my $file ( `find $new_dir -type f` ) {
             last if $file =~ s/^$key/$val/;
         }
     }
+    else {
+        $file = $files[0] . '/' . $file;
+    }
 
     if ( $file =~ m{^cpan/} ) {
         $file =~ s{^cpan/}{};
@@ -394,7 +402,7 @@ print "done\n";
 
 #
 # Must clean up, or else t/porting/FindExt.t will fail.
-# Note that we can always retrieve the orginal directory with a git checkout.
+# Note that we can always retrieve the original directory with a git checkout.
 #
 print "About to clean up; hit return or abort (^C) "; <STDIN>;
 
@@ -442,7 +450,7 @@ while (<$Maintainers_pl>) {
     if (!$found) {
         if ($in_mod_section) {
             if (/DISTRIBUTION/) {
-                if (s/\Q$old_version/$version/) {
+                if (s/\Q$old_version/$new_version/) {
                     $found = 1;
                 }
             }