Richard Marko <[email protected]> writes: > On 08/27/2012 09:05 PM, Nikola Pajkovsky wrote: >> Richard Marko <[email protected]> writes: >> >>> Required for reporter-ureport to work with kernel oopses. >>> >>> Signed-off-by: Richard Marko <[email protected]> >>> --- >>> abrt.spec.in | 1 + >>> src/plugins/Makefile.am | 3 ++- >>> src/plugins/abrt-action-save-kernel-data | 27 +++++++++++++++++++++++++++ >>> src/plugins/koops_event.conf | 1 + >>> 4 files changed, 31 insertions(+), 1 deletion(-) >>> create mode 100755 src/plugins/abrt-action-save-kernel-data >>> >>> diff --git a/abrt.spec.in b/abrt.spec.in >>> index a1c00ba..65a03d3 100644 >>> --- a/abrt.spec.in >>> +++ b/abrt.spec.in >>> @@ -571,6 +571,7 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor >>> &>/dev/null || : >>> %endif >>> %{_bindir}/abrt-dump-oops >>> %{_bindir}/abrt-action-analyze-oops >>> +%{_bindir}/abrt-action-save-kernel-data >>> %{_mandir}/man1/abrt-action-analyze-oops.1* >>> >>> %files addon-xorg >>> diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am >>> index 675b1a7..8829c06 100644 >>> --- a/src/plugins/Makefile.am >>> +++ b/src/plugins/Makefile.am >>> @@ -4,7 +4,8 @@ bin_SCRIPTS = \ >>> abrt-action-install-debuginfo \ >>> abrt-action-analyze-core \ >>> abrt-action-analyze-vmcore \ >>> - abrt-action-list-dsos >>> + abrt-action-list-dsos \ >>> + abrt-action-save-kernel-data >>> >>> bin_PROGRAMS = \ >>> abrt-watch-log \ >>> diff --git a/src/plugins/abrt-action-save-kernel-data >>> b/src/plugins/abrt-action-save-kernel-data >>> new file mode 100755 >>> index 0000000..2a4ce98 >>> --- /dev/null >>> +++ b/src/plugins/abrt-action-save-kernel-data >>> @@ -0,0 +1,27 @@ >>> +#!/bin/bash >>> +# >>> +# Save pkg_{name, arch, version, release} for kernel oopses. >>> +# >>> +# These files are required by reporter-ureporter (mandatory >>> +# in uReport). >>> +# >>> + >>> +test -f kernel || exit 1 >>> + >>> +echo "Looking for kernel package" >>> +package="$( rpm -q kernel kernel-PAE | grep "$( sed 's/ .*//' kernel )")" >>> +if [ $? == 0 ]; then >>> + echo "Kernel package $package found" >>> + rpm -q --qf "%{name}\n" "$package" > pkg_name >>> + rpm -q --qf "%{arch}\n" "$package" > pkg_arch >>> + rpm -q --qf "%{version}\n" "$package" > pkg_version >>> + rpm -q --qf "%{release}\n" "$package" > pkg_release >>> + epoch="$( rpm -q --qf "%{epoch}" "$package" )" >>> + if [ "$epoch" == "(none)" ]; then >>> + echo "0" > pkg_epoch >>> + else >>> + echo "$epoch" > pkg_epoch >>> + fi >>> +else >>> + echo "Kernel package not found" >> System without kernel? :) >> >>> +fi >>> diff --git a/src/plugins/koops_event.conf b/src/plugins/koops_event.conf >>> index 91759b1..9369131 100644 >>> --- a/src/plugins/koops_event.conf >>> +++ b/src/plugins/koops_event.conf >>> @@ -3,6 +3,7 @@ EVENT=post-create analyzer=Kerneloops >>> abrt-action-analyze-oops && >>> dmesg >dmesg && >>> abrt-action-generate-core-backtrace >>> + abrt-action-save-kernel-data >>> >>> # If you want behavior similar to one provided by kerneloops daemon >>> # distributed by kerneloops.org - that is, if you want >> I don't think that is really good idea. >> >> $ rpm -q kernel >> kernel-3.3.0-0.20.el7.x86_64 >> kernel-3.5.0-0.23.el7.x86_64 >> kernel-3.5.0-0.24.el7.x86_64 >> >> Which kernel am I running? >> >> $ uname -r >> 3.6.0-rc3 >> >> don't be lazy and parse it form oops (code which looks for kernel >> version is already there) >> > Well, that actually seems like a good result as we don't really care > about uReports sent from people running custom kernels.
I wanted to point something else. $ rpm -q doesn't give you actually running kernel (only if you have only one installed), and that means your report will contain wrong kernel version. -- Nikola
