implement tar format guessing
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Mon, 3 Jun 2013 10:16:00 +0000 (13:16 +0300)
committerJoey Hess <joey@kitenet.net>
Sat, 15 Jun 2013 00:35:43 +0000 (20:35 -0400)
Try "posix" and "gnu" formats if tarball re-creation with the default
tar format fails.

Makes pristine-tar more compatible accross different Linux distributions
as the default format used by tar varies.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
pristine-tar

index 14bac158c90f8e0ff9c9f9a0ac401297b8b13560..1c321d4ab61f11dda14690a71cf1219f2cb3b787 100755 (executable)
@@ -343,18 +343,23 @@ sub recreatetarball {
 
        delete $ENV{TAR_LONGLINK_100};
        $recreatetarball_tempdir=$tempdir;
-       return recreatetarball_helper();
+       return recreatetarball_helper(%options);
 }
 
 sub recreatetarball_helper {
+       my %options=@_;
        my $tempdir=$recreatetarball_tempdir;
        
        my $ret="$tempdir/recreatetarball";
+       my @cmd=($tar_program, "cf", $ret, "--owner", 0, "--group", 0,
+                       "--numeric-owner", "-C", "$tempdir/workdir",
+                       "--no-recursion", "--mode", "0644",
+            "--files-from", "$tempdir/manifest");
+       if (exists $options{tar_format}) {
+               push @cmd, ("-H", $options{tar_format});
+       }
 
-       doit($tar_program, "cf", $ret, "--owner", 0, "--group", 0, 
-               "--numeric-owner", "-C", "$tempdir/workdir",
-               "--no-recursion", "--mode", "0644", 
-               "--files-from", "$tempdir/manifest");
+       doit(@cmd);
        
        return $ret;
 }
@@ -393,6 +398,10 @@ sub gentar {
        push @try, sub { recreatetarball($delta->{manifest}, getcwd,
                        clobber_source => 0, %opts) };
        push @try, \&recreatetarball_longlink_100;
+       push @try, sub { recreatetarball($delta->{manifest}, getcwd,
+                       clobber_source => 0, tar_format => "gnu", %opts) };
+       push @try, sub { recreatetarball($delta->{manifest}, getcwd,
+                       clobber_source => 0, tar_format => "posix", %opts) };
 
        my $ok;
        foreach my $variant (@try) {