Blame SOURCES/0019-Ticket-48224-logconv.pl-should-handle-.tar.xz-.txz-..patch

a2f18f
From 5d2f818d33801b1ae6c7d3c19ab67e52a4944251 Mon Sep 17 00:00:00 2001
a2f18f
From: Rich Megginson <rmeggins@redhat.com>
a2f18f
Date: Mon, 13 Jul 2015 18:27:50 -0600
a2f18f
Subject: [PATCH 19/20] Ticket #48224 - logconv.pl should handle *.tar.xz,
a2f18f
 *.txz, *.xz log files
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/48224
a2f18f
Reviewed by: ???
a2f18f
Branch: 389-ds-base-1.3.4
a2f18f
Fix Description: There is no xz support by default, the perl module
a2f18f
IO::Uncompress::UnXz is required for that.  Also, Tar::Archive can't
a2f18f
handle xz files by default, so they have to be uncompressed first.
a2f18f
This will also need a spec file change:
a2f18f
Requires: perl-IO-Compress
a2f18f
Requires: perl-IO-Compress-Lzma
a2f18f
Platforms tested: Fedora 21
a2f18f
Flag Day: no
a2f18f
Doc impact: no
a2f18f
a2f18f
(cherry picked from commit d1b0acd12faa620774c66044f91e509ae175e4a1)
a2f18f
(cherry picked from commit 4f3b802fac46adfa8fd5cf49443b875f136fb19c)
a2f18f
---
a2f18f
 ldap/admin/src/logconv.pl | 20 +++++++++++++++++++-
a2f18f
 rpm/389-ds-base.spec.in   |  3 +++
a2f18f
 2 files changed, 22 insertions(+), 1 deletion(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/logconv.pl b/ldap/admin/src/logconv.pl
a2f18f
index 7ca9084..a6bd6c2 100755
a2f18f
--- a/ldap/admin/src/logconv.pl
a2f18f
+++ b/ldap/admin/src/logconv.pl
a2f18f
@@ -398,14 +398,26 @@ my $totalLineCount = 0;
a2f18f
 
a2f18f
 sub isTarArchive {
a2f18f
 	local $_ = shift;
a2f18f
+	if (/\.txz$/ || /\.tar.xz$/) {
a2f18f
+		use IO::Uncompress::UnXz;
a2f18f
+	}
a2f18f
 	return /\.tar$/ || /\.tar\.bz2$/ || /\.tar.gz$/ || /\.tar.xz$/ || /\.tgz$/ || /\.tbz$/ || /\.txz$/;
a2f18f
 }
a2f18f
 
a2f18f
 sub isCompressed {
a2f18f
 	local $_ = shift;
a2f18f
+	if (/\.xz$/) {
a2f18f
+		use IO::Uncompress::UnXz;
a2f18f
+	}
a2f18f
 	return /\.gz$/ || /\.bz2$/ || /\.xz$/;
a2f18f
 }
a2f18f
 
a2f18f
+# Tar::Archive can't grok xz, so have to uncompress first
a2f18f
+sub tarNeedsUncompress {
a2f18f
+	local $_ = shift;
a2f18f
+	return /\.tar.xz$/ || /\.txz$/;
a2f18f
+}
a2f18f
+
a2f18f
 sub convertTimeToSeconds {
a2f18f
 	my $log_line = shift;
a2f18f
 
a2f18f
@@ -503,7 +515,13 @@ for (my $count=0; $count < $file_count; $count++){
a2f18f
 	my $comp = 0;
a2f18f
 	if (isTarArchive($logname)) {
a2f18f
 		$tar = Archive::Tar->new();
a2f18f
-		$tariter = Archive::Tar->iter($logname);
a2f18f
+		if (tarNeedsUncompress($logname)) {
a2f18f
+			my $TARFH = new IO::Uncompress::AnyUncompress $logname or
a2f18f
+				do { openFailed($AnyUncompressError, $logname); next };
a2f18f
+			$tariter = Archive::Tar->iter($TARFH);
a2f18f
+		} else {
a2f18f
+			$tariter = Archive::Tar->iter($logname);
a2f18f
+		}
a2f18f
 		if (!$tariter) {
a2f18f
 			print "$logname is not a valid tar archive, or compression is unrecognized: $!\n";
a2f18f
 			next;
a2f18f
diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in
a2f18f
index d0bbb7a..3405ccd 100644
a2f18f
--- a/rpm/389-ds-base.spec.in
a2f18f
+++ b/rpm/389-ds-base.spec.in
a2f18f
@@ -116,6 +116,9 @@ Requires:         perl-Socket6
a2f18f
 Requires:         perl-Socket
a2f18f
 %endif
a2f18f
 Requires:         perl-NetAddr-IP
a2f18f
+# for logconv compressed file support
a2f18f
+Requires:         perl-IO-Compress
a2f18f
+Requires:         perl-IO-Compress-Lzma
a2f18f
 
a2f18f
 Source0:          http://port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2
a2f18f
 # 389-ds-git.sh should be used to generate the source tarball from git
a2f18f
-- 
a2f18f
1.9.3
a2f18f