From f10d44d305ed773eedee4093a5c9ed06f948e60c Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Mon, 10 Sep 2012 14:29:05 +0200 Subject: [PATCH] Enable zypper-log reading lzma (.xz) compressed logs. --- doc/zypper-log.8 | 2 +- tools/zypper-log | 5 ++++- zypper.spec.cmake | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/zypper-log.8 b/doc/zypper-log.8 index 60927c1..98a044e 100644 --- a/doc/zypper-log.8 +++ b/doc/zypper-log.8 @@ -6,7 +6,7 @@ zypper-log \- Zypper logfile reader .SH SYNOPSIS \fBzypper-log\fP [\fIoptions\fP] [\fIpid\fP] .SH DESCRIPTION -zypper-log can read zypper's logfiles. It can also handle rotated logfiles, and will open plain, gz and bz2-compressed files. +zypper-log can read zypper's logfiles. It can also handle rotated logfiles, and will open plain, xz, gz and bz2-compressed files. .sp By default zypper.log will be read in. .sp diff --git a/tools/zypper-log b/tools/zypper-log index 890ece2..710ebae 100755 --- a/tools/zypper-log +++ b/tools/zypper-log @@ -6,6 +6,7 @@ # Author: Dominik Heidler import os, string, re, bz2, zlib, sys, time, argparse, errno +import subprocess filenamelen = 0 pidlen = 0 @@ -35,7 +36,9 @@ def readFile(logfile): print >> sys.stderr, "\rIOError: %s: '%s'" % (e.strerror, e.filename) sys.exit(1) fext = logfile.split('.')[-1] - if fext == 'bz2': + if fext == 'xz': + logtxt = subprocess.Popen(['xzcat',logfile], stdout=subprocess.PIPE).stdout.read() + elif fext == 'bz2': logtxt = bz2.decompress(logtxt) elif fext == 'gz': logtxt = zlib.decompress(logtxt) diff --git a/zypper.spec.cmake b/zypper.spec.cmake index c03c294..19a8b41 100644 --- a/zypper.spec.cmake +++ b/zypper.spec.cmake @@ -64,6 +64,7 @@ Requires: python-argparse %else Requires: python >= 2.7 %endif +Requires: xz BuildArch: noarch Summary: CLI for accessing the zypper logfile License: GPL-2.0+ -- 2.7.4