Skip to content

Commit

Permalink
Ticket #48224 - logconv.pl should handle *.tar.xz, *.txz, *.xz log files
Browse files Browse the repository at this point in the history
https://fedorahosted.org/389/ticket/48224
Reviewed by: ???
Branch: 389-ds-base-1.3.4
Fix Description: There is no xz support by default, the perl module
IO::Uncompress::UnXz is required for that.  Also, Tar::Archive can't
handle xz files by default, so they have to be uncompressed first.
This will also need a spec file change:
Requires: perl-IO-Compress
Requires: perl-IO-Compress-Lzma
Platforms tested: Fedora 21
Flag Day: no
Doc impact: no

(cherry picked from commit d1b0acd)
  • Loading branch information
richm committed Jul 14, 2015
1 parent 3bf1daa commit 4f3b802
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ldap/admin/src/logconv.pl
Expand Up @@ -398,14 +398,26 @@ sub statusreport {

sub isTarArchive {
local $_ = shift;
if (/\.txz$/ || /\.tar.xz$/) {
use IO::Uncompress::UnXz;
}
return /\.tar$/ || /\.tar\.bz2$/ || /\.tar.gz$/ || /\.tar.xz$/ || /\.tgz$/ || /\.tbz$/ || /\.txz$/;
}

sub isCompressed {
local $_ = shift;
if (/\.xz$/) {
use IO::Uncompress::UnXz;
}
return /\.gz$/ || /\.bz2$/ || /\.xz$/;
}

# Tar::Archive can't grok xz, so have to uncompress first
sub tarNeedsUncompress {
local $_ = shift;
return /\.tar.xz$/ || /\.txz$/;
}

sub convertTimeToSeconds {
my $log_line = shift;

Expand Down Expand Up @@ -503,7 +515,13 @@ sub convertTimeToSeconds {
my $comp = 0;
if (isTarArchive($logname)) {
$tar = Archive::Tar->new();
$tariter = Archive::Tar->iter($logname);
if (tarNeedsUncompress($logname)) {
my $TARFH = new IO::Uncompress::AnyUncompress $logname or
do { openFailed($AnyUncompressError, $logname); next };
$tariter = Archive::Tar->iter($TARFH);
} else {
$tariter = Archive::Tar->iter($logname);
}
if (!$tariter) {
print "$logname is not a valid tar archive, or compression is unrecognized: $!\n";
next;
Expand Down
3 changes: 3 additions & 0 deletions rpm/389-ds-base.spec.in
Expand Up @@ -121,6 +121,9 @@ Requires: perl-Socket6
Requires: perl-Socket
%endif
Requires: perl-NetAddr-IP
# for logconv compressed file support
Requires: perl-IO-Compress
Requires: perl-IO-Compress-Lzma

Source0: http://port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2
# 389-ds-git.sh should be used to generate the source tarball from git
Expand Down

0 comments on commit 4f3b802

Please sign in to comment.