Subject: | Tar::Archive files are incompatible with busybox tar applet |
Archive::Tar generates file headers with space padded numbers for size,
mtime and checksum. This format is incompatible with some versions of
the busybox implementation of tar (I am using 1.13.2), which requires 0
padded numbers (despite comments in the source that say otherwise).
I've included a patch that adds a control flag that enables zero padded
numbers in the header. It passes all tests with ActiveState Perl 5.8.8
on WinXP.
Subject: | 0001-Added-ZERO_PAD_NUMBERS-flag-to-interface.patch |
From c576389118bbfc4b78c75466f916c7a60b5cd559 Mon Sep 17 00:00:00 2001
From: Mark Swayne <mark.swayne@q.com>
Date: Tue, 13 Oct 2009 17:01:22 -0700
Subject: [PATCH] Added $ZERO_PAD_NUMBERS flag to interface.
Busybox tar can not read space padded size or checksum values. Added the ZERO_PAD_NUMBERS flag to allow forcing size, mtime and checksum to be 0 padded octal numbers instead of space padded octal numbers.
---
lib/Archive/Tar.pm | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/Archive/Tar.pm b/lib/Archive/Tar.pm
index 006edbd..5f2f9ab 100644
--- a/lib/Archive/Tar.pm
+++ b/lib/Archive/Tar.pm
@@ -23,7 +23,7 @@ require Exporter;
use strict;
use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
$DO_NOT_USE_PREFIX $HAS_PERLIO $HAS_IO_STRING $SAME_PERMISSIONS
- $INSECURE_EXTRACT_MODE @ISA @EXPORT
+ $INSECURE_EXTRACT_MODE $ZERO_PAD_NUMBERS @ISA @EXPORT
];
@ISA = qw[Exporter];
@@ -37,6 +37,7 @@ $CHMOD = 1;
$SAME_PERMISSIONS = $> == 0 ? 1 : 0;
$DO_NOT_USE_PREFIX = 0;
$INSECURE_EXTRACT_MODE = 0;
+$ZERO_PAD_NUMBERS = 0;
BEGIN {
use Config;
@@ -1273,7 +1274,7 @@ sub _format_tar_entry {
my $l = PREFIX_LENGTH; # is ambiguous otherwise...
substr ($prefix, 0, -$l) = "" if length $prefix >= PREFIX_LENGTH;
- my $f1 = "%06o"; my $f2 = "%11o";
+ my $f1 = "%06o"; my $f2 = $ZERO_PAD_NUMBERS ? "%011o" : "%11o";
### this might be optimizable with a 'changed' flag in the file objects ###
my $tar = pack (
@@ -1296,6 +1297,7 @@ sub _format_tar_entry {
);
### add the checksum ###
+ my $checksum_fmt = $ZERO_PAD_NUMBERS ? "%06o\0" : "%06o\0";
substr($tar,148,7) = sprintf("%6o\0", unpack("%16C*",$tar));
return $tar;
--
1.6.2.2.1669.g7eaf8