[Debian-l10n-commits] r1613 - in /dl10n/trunk: Changelog lib/Debian/Pkg/Tar.pm
nekral-guest at users.alioth.debian.org
nekral-guest at users.alioth.debian.org
Sat Feb 21 17:58:38 UTC 2009
Author: nekral-guest
Date: Sat Feb 21 17:58:37 2009
New Revision: 1613
URL: http://svn.debian.org/wsvn/?sc=1&rev=1613
Log:
* lib/Debian/Pkg/Tar.pm: "Some tar files have no trailing null
block". Added an argument to _io_read to avoid failing when it
cannot read this bloc at the end of the archive.
* lib/Debian/Pkg/Tar.pm: Added support for wrong checksums from
SunOS and HP-UX tar.
* lib/Debian/Pkg/Tar.pm: Do not warn for the "unable to determine
top-level directory" errors. This is handled correctly later. The
warning will be output in debug mode.
Modified:
dl10n/trunk/Changelog
dl10n/trunk/lib/Debian/Pkg/Tar.pm
Modified: dl10n/trunk/Changelog
URL: http://svn.debian.org/wsvn/dl10n/trunk/Changelog?rev=1613&op=diff
==============================================================================
--- dl10n/trunk/Changelog (original)
+++ dl10n/trunk/Changelog Sat Feb 21 17:58:37 2009
@@ -1,3 +1,14 @@
+2008-02-21 Nicolas François <nicolas.francois at centraliens.net>
+
+ * lib/Debian/Pkg/Tar.pm: "Some tar files have no trailing null
+ block". Added an argument to _io_read to avoid failing when it
+ cannot read this bloc at the end of the archive.
+ * lib/Debian/Pkg/Tar.pm: Added support for wrong checksums from
+ SunOS and HP-UX tar.
+ * lib/Debian/Pkg/Tar.pm: Do not warn for the "unable to determine
+ top-level directory" errors. This is handled correctly later. The
+ warning will be output in debug mode.
+
2008-01-15 Nicolas François <nicolas.francois at centraliens.net>
* lib/Debian/L10n/BTS.pm, lib/Debian/L10n/Spider.pm: Do not
Modified: dl10n/trunk/lib/Debian/Pkg/Tar.pm
URL: http://svn.debian.org/wsvn/dl10n/trunk/lib/Debian/Pkg/Tar.pm?rev=1613&op=diff
==============================================================================
--- dl10n/trunk/lib/Debian/Pkg/Tar.pm (original)
+++ dl10n/trunk/lib/Debian/Pkg/Tar.pm Sat Feb 21 17:58:37 2009
@@ -153,6 +153,7 @@
my $self = shift;
my $nbytes = shift;
my $getData = shift || 0;
+ my $ignore_eof = shift || 0;
return '' if $nbytes <= 0;
@@ -168,9 +169,18 @@
$text .= $buffer if $getData;
}
if ($nbytes > 0) {
- read($self->{handle}, $buffer, $nbytes) ||
- Carp::carp "End of file found when reading \`$self->{name}'";
- $text .= $buffer if $getData;
+ my $nread = read($self->{handle}, $buffer, $nbytes);
+ if (not defined $nread) {
+ Carp::carp "Failed to read \`$self->{name}': $!";
+ } elsif ($nread == 0) {
+ if ($ignore_eof) {
+ $text = undef;
+ } else {
+ Carp::carp "End of file found when reading \`$self->{name}'";
+ }
+ } else {
+ $text .= $buffer if $getData;
+ }
}
return $text;
}
@@ -337,9 +347,10 @@
my $cont = shift; # 1 when reading long filenames, 0 otherwise
# Read header
- my $head = $self->_io_read(512, 1);
+ my $head = $self->_io_read(512, 1, 1);
# Some tar files have no trailing null block
- if ($head eq "\0" x 512 or $head eq '') {
+ if ( (not defined $head)
+ or ($head eq "\0" x 512)) {
$self->_debug("EOF detected");
return;
}
@@ -363,8 +374,18 @@
# Calculate checksum
substr ($head, 148, 8) = " ";
+ # http://www.gnu.org/software/tar/manual/tar.html#SEC139
+ # "SunOS and HP-UX tar fail to accept archives created using GNU tar
+ # and containing non-ASCII file names, that is, file names having
+ # characters with the eight bit set, because they use signed checksums,
+ # while GNU tar uses unsigned checksums while creating archives, as per
+ # POSIX standards. On reading, GNU tar computes both checksums and
+ # accept any."
+ # The regular checksum is unpack ("%16C*", $head), but we also accept
+ # unpack ("%16c*", $head)
Carp::carp "$self->{name}:$name: checksum error.\n"
- if unpack ("%16C*", $head) != $chksum;
+ if ( (unpack ("%16C*", $head) != $chksum)
+ and (unpack ("%16c*", $head) != $chksum));
# Handle long filename (>100 chars)
if ($prefix ne "") {
@@ -399,9 +420,7 @@
if ($self->{dir} ne "" && $self->{dir} ne $1) {
$name = $1 . '/' . $name;
$self->{wrongdir} = 1;
-# TODO: Check if this is handled correctly.
-# If it is, this should not be reported.
- warn "Warning: unable to determine top-level directory in $self->{name}, assuming there is no root directory\n";
+ $self->_debug("Warning: unable to determine top-level directory in $self->{name}, assuming there is no root directory");
# Adapt already scanned files and
# directories
$self->_prepend_dir($self->{dir});
@@ -415,9 +434,7 @@
} else {
if ($self->{wrongdir} == 0) {
$self->{wrongdir} = 1;
-# TODO: Check if this is handled correctly.
-# If it is, this should not be reported.
- warn "Warning: unable to determine top-level directory in $self->{name}, assuming there is no root directory\n";
+ $self->_debug("Warning: unable to determine top-level directory in $self->{name}, assuming there is no root directory");
$self->_prepend_dir($self->{dir}) if $self->{dir} ne '';
}
}
More information about the Debian-l10n-commits
mailing list