From 5d2f818d33801b1ae6c7d3c19ab67e52a4944251 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Mon, 13 Jul 2015 18:27:50 -0600
Subject: [PATCH 19/20] Ticket #48224 - logconv.pl should handle *.tar.xz,
*.txz, *.xz log files
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 d1b0acd12faa620774c66044f91e509ae175e4a1)
(cherry picked from commit 4f3b802fac46adfa8fd5cf49443b875f136fb19c)
---
ldap/admin/src/logconv.pl | 20 +++++++++++++++++++-
rpm/389-ds-base.spec.in | 3 +++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
index 7ca9084..a6bd6c2 100755
--- a/ldap/admin/src/logconv.pl
+++ b/ldap/admin/src/logconv.pl
@@ -398,14 +398,26 @@ my $totalLineCount = 0;
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;
@@ -503,7 +515,13 @@ for (my $count=0; $count < $file_count; $count++){
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;
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
index d0bbb7a..3405ccd 100644
--- a/rpm/389-ds-base.spec.in
+++ b/rpm/389-ds-base.spec.in
@@ -116,6 +116,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
--
1.9.3