Fixes related to transition to Python 3 and fix in abrt-merge-pstoreoops

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
This commit is contained in:
Matej Habrnal 2015-07-24 15:22:08 +02:00
commit c40d958f7b
4 changed files with 130 additions and 1 deletions

View file

@ -0,0 +1,35 @@
From 668014b725660785c43b880e73a9ff723abc0be5 Mon Sep 17 00:00:00 2001
From: "knoha@redhat.com" <knoha@redhat.com>
Date: Fri, 24 Jul 2015 07:56:02 +0200
Subject: [PATCH] abrt-merge-pstoreoops: merge files in descending order
fs/pstore reads the data from kmsg_dump_get_buffer(), which starts at
the end of the kmsg buffer, in a while loop and increases Part no. in
each iteration.
Related: rhbz#1233662
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/hooks/abrt-merge-pstoreoops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/hooks/abrt-merge-pstoreoops.c b/src/hooks/abrt-merge-pstoreoops.c
index 6fc3109..36f1e0b 100644
--- a/src/hooks/abrt-merge-pstoreoops.c
+++ b/src/hooks/abrt-merge-pstoreoops.c
@@ -64,9 +64,9 @@ int compare_oops_texts(const void *a, const void *b)
return -1;
if (aa->panic_no > bb->panic_no)
return 1;
- if (aa->part_no < bb->part_no)
+ if (aa->part_no > bb->part_no)
return -1;
- return (aa->part_no > bb->part_no);
+ return (aa->part_no < bb->part_no);
}
int main(int argc, char **argv)
--
2.4.6

View file

@ -0,0 +1,44 @@
From ed7aaffdcac4f29cd513cd4c1086339512320a1c Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Fri, 24 Jul 2015 13:47:15 +0200
Subject: [PATCH] pass encoded Unicode to hashlib.sha1.update()
Python 3 compatibility commit.
Related: rhbz#1246459
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/plugins/abrt-action-check-oops-for-hw-error.in | 2 +-
src/plugins/abrt-action-generate-machine-id | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/plugins/abrt-action-check-oops-for-hw-error.in b/src/plugins/abrt-action-check-oops-for-hw-error.in
index 400ed99..1695ddb 100644
--- a/src/plugins/abrt-action-check-oops-for-hw-error.in
+++ b/src/plugins/abrt-action-check-oops-for-hw-error.in
@@ -88,7 +88,7 @@ if __name__ == "__main__":
oops_hash = hashlib.sha1()
with open("backtrace", "r") as btfile:
for line in btfile:
- oops_hash.update(line)
+ oops_hash.update(line.encode())
with open_or_die("uuid", "w") as f:
f.write(oops_hash.hexdigest())
diff --git a/src/plugins/abrt-action-generate-machine-id b/src/plugins/abrt-action-generate-machine-id
index 1005b2c..63b5c93 100644
--- a/src/plugins/abrt-action-generate-machine-id
+++ b/src/plugins/abrt-action-generate-machine-id
@@ -63,7 +63,7 @@ def generate_machine_id_dmidecode():
data = dmixp.xpathEval(k)
for d in data:
# Update the hash as we find the fields we are looking for
- machine_id.update(d.get_content())
+ machine_id.update(d.get_content().encode())
del dmixp
del xmldoc
--
2.4.6

View file

@ -0,0 +1,38 @@
From 8f26482402179dc64b9488be05ef9686922446ec Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Fri, 24 Jul 2015 13:50:00 +0200
Subject: [PATCH] vmcore: read vmcore by chunks
Reading vmcore by lines was not a good idea and the switch to Python 3
makes it impossible because of the binary format of that file (the file
does not contain only valid Unicode strings and that raises
UnicodeDecodeError from the for statement).
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/hooks/abrt_harvest_vmcore.py.in | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/hooks/abrt_harvest_vmcore.py.in b/src/hooks/abrt_harvest_vmcore.py.in
index c5e7d53..61a6e57 100644
--- a/src/hooks/abrt_harvest_vmcore.py.in
+++ b/src/hooks/abrt_harvest_vmcore.py.in
@@ -214,9 +214,12 @@ def harvest_vmcore():
hashobj = hashlib.sha1()
# Iterate over the file a line at a time in order to not load the whole
# vmcore file
- with open(os.path.join(f_full, 'vmcore'), 'r') as corefile:
- for line in corefile:
- hashobj.update(line)
+ with open(os.path.join(f_full, 'vmcore'), 'rb') as corefile:
+ while True:
+ chunk = corefile.read(8192)
+ if not chunk:
+ break
+ hashobj.update(chunk)
dd = create_abrtd_info(destdirnew, hashobj.hexdigest())
if dd is None:
--
2.4.6

View file

@ -49,7 +49,7 @@
Summary: Automatic bug detection and reporting tool
Name: abrt
Version: 2.6.2
Release: 2%{?dist}
Release: 3%{?dist}
License: GPLv2+
Group: Applications/System
URL: https://abrt.readthedocs.org/
@ -60,6 +60,13 @@ Patch0: disable-OpenGPGCheck-in-Fedora-Rawhide.patch
# git format-patch %%{Version} --topo-order -N -M;
# i=1; for p in `ls 0*.patch`; do printf "Patch%04d: %s\n" $i $p; ((i++)); done
Patch0001: 0001-use-gettext-instead-of-lgettext-in-all-python-script.patch
Patch0002: 0002-abrt-merge-pstoreoops-merge-files-in-descending-orde.patch
#Patch0003: 0003-testsuite-pstore-adapt-to-merging-in-descending-orde.patch
#Patch0004: 0004-testsuite-a-a-reporting-sanity-add-test-for-missing-.patch
#Patch0005: 0005-testsuite-pstore-harvest-adapt-to-merging-in-descend.patch
Patch0006: 0006-pass-encoded-Unicode-to-hashlib.sha1.update.patch
Patch0007: 0007-vmcore-read-vmcore-by-chunks.patch
# '%%autosetup -S git' -> git
BuildRequires: git
@ -1046,6 +1053,11 @@ killall abrt-dbus >/dev/null 2>&1 || :
%config(noreplace) %{_sysconfdir}/profile.d/abrt-console-notification.sh
%changelog
* Fri Jul 24 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-3
- read vmcore by chunks
- pass encoded Unicode to hashlib.sha1.update()
- abrt-merge-pstoreoops: merge files in descending order
* Wed Jul 22 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-2
- use gettext instead of lgettext in all python scripts
- Resolves: #1245600