[abrt/f16] fixed update from abrt1 to abrt2
Jiří Moskovčák
jmoskovc at fedoraproject.org
Tue Sep 13 13:51:58 UTC 2011
commit 8c03ba1f2e171471f870951119fbdbd3d34c58b6
Author: Jiri Moskovcak <jmoskovc at redhat.com>
Date: Tue Sep 13 12:50:39 2011 +0200
fixed update from abrt1 to abrt2
abrt.spec | 32 +++++++++++++++-
abrt1_to_abrt2 | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 146 insertions(+), 1 deletions(-)
---
diff --git a/abrt.spec b/abrt.spec
index 91a5360..5424a12 100644
--- a/abrt.spec
+++ b/abrt.spec
@@ -10,7 +10,7 @@
Summary: Automatic bug detection and reporting tool
Name: abrt
Version: 2.0.4
-Release: 2%{?dist}
+Release: 3%{?dist}
License: GPLv2+
Group: Applications/System
URL: https://fedorahosted.org/abrt/
@@ -18,6 +18,7 @@ Source: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.gz
Source1: abrt.init
Source2: abrt-ccpp.init
Source3: abrt-oops.init
+Source4: abrt1_to_abrt2
Patch0: 0001-abrt-gui-launch-reporter-children-with-LIBREPORT_GET.patch
Patch1: 0002-gui-split-the-main-window-in-2-panes-reported-not-re.patch
Patch2: 0004-install-debuginfo-ask-before-downloading.patch
@@ -191,6 +192,7 @@ install -m 755 %SOURCE1 ${RPM_BUILD_ROOT}/%{_initrddir}/abrtd
install -m 755 %SOURCE2 ${RPM_BUILD_ROOT}/%{_initrddir}/abrt-ccpp
install -m 755 %SOURCE3 ${RPM_BUILD_ROOT}/%{_initrddir}/abrt-oops
%endif
+install -m 755 %SOURCE4 ${RPM_BUILD_ROOT}/%{_libexecdir}/abrt1-to-abrt2
mkdir -p $RPM_BUILD_ROOT/var/cache/abrt-di
mkdir -p $RPM_BUILD_ROOT/var/run/abrt
mkdir -p $RPM_BUILD_ROOT/var/spool/abrt
@@ -230,6 +232,7 @@ if [ $1 -eq 1 ]; then
/sbin/chkconfig --add abrtd
%endif
fi
+%{_libexecdir}/abrt1-to-abrt2 || :
%post addon-ccpp
# this is required for transition from 1.1.x to 2.x
@@ -244,6 +247,18 @@ if [ $1 -eq 1 ]; then
/sbin/chkconfig --add abrt-ccpp
%endif
fi
+# FIXME: Workaround for update from abrt-1.1.x, can be removed in
+# F17(18) update. When we are updating from ABRT 1 to ABRT 2, assume
+# that abrtd service is enabled and thus enable the new abrt-ccpp
+# service. If abrtd is running on the system, run abrt-ccpp service
+# as well, because what was a part of abrtd became a separate service.
+if [ $1 -gt 1 ]; then # Is this an upgrade?
+ /sbin/chkconfig --add abrt-ccpp
+ /sbin/pidof abrtd >/dev/null 2>&1
+ if [ $? -eq 0 ]; then # Is abrtd running?
+ service abrt-ccpp restart >/dev/null 2>&1 || :
+ fi
+fi
%post addon-kerneloops
if [ $1 -eq 1 ]; then
@@ -254,6 +269,18 @@ if [ $1 -eq 1 ]; then
/sbin/chkconfig --add abrt-oops
%endif
fi
+# FIXME: Workaround for update from abrt-1.1.x, can be removed in
+# F17(18) update. When we are updating from ABRT 1 to ABRT 2, assume
+# that abrtd service is enabled and thus enable the new abrt-oops
+# service. If abrtd is running on the system, run abrt-ccpp service
+# as well, because what was a part of abrtd became a separate service.
+if [ $1 -gt 1 ]; then # Is this an upgrade?
+ /sbin/chkconfig --add abrt-oops
+ /sbin/pidof abrtd >/dev/null 2>&1
+ if [ $? -eq 0 ]; then # Is abrtd running?
+ service abrt-oops restart >/dev/null 2>&1 || :
+ fi
+fi
%preun
if [ "$1" -eq "0" ] ; then
@@ -444,6 +471,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%defattr(-,root,root,-)
%changelog
+* Tue Aug 30 2011 Jiri Moskovcak <jmoskovc at redhat.com> - 2.0.4-3
+- fixed abrt1-abrt2 update
+
* Fri Aug 19 2011 Jiri Moskovcak <jmoskovc at redhat.com> - 2.0.4-2
- enable bugzilla for kerneloops rhbz#725970
- Resolves: #725970
diff --git a/abrt1_to_abrt2 b/abrt1_to_abrt2
new file mode 100755
index 0000000..978c38f
--- /dev/null
+++ b/abrt1_to_abrt2
@@ -0,0 +1,115 @@
+#! /usr/bin/python
+#-*- coding: utf-8 -*-
+
+import os
+
+# abrt_v4 TABLE columns:
+UUID = 0
+UID = 1
+INFORMALL = 2
+DUMPDIR_PATH = 3
+COUNT = 4
+REPORTED = 5
+TIME = 6
+MESSAGE = 7
+
+# abrt_v4_reportresult columns:
+#UUID = 0
+#UID = 1
+REPORTER = 2
+RESULT_MESSAGE = 3
+
+def get_db_path():
+ path = "/var/spool/abrt/abrt-db"
+ try:
+ with open("/etc/abrt/plugins/SQLite3.conf") as f:
+ for line in f:
+ line = line.split('=', 1)
+ if len(line) == 2 and line[0].strip() == "DBPath":
+ path = line[1].strip()
+ except Exception, ex:
+ pass
+ return path
+
+def get_url_from_text(text):
+ url_marks = ["http://", "https://", "ftp://", "ftps://", "file://"]
+ lines = text.split('\n')
+ url = ""
+ for mark in url_marks:
+ for line in lines:
+ last_mark = line.find(mark)
+ if last_mark != -1:
+ url_end = line.find(' ',last_mark)
+ if url_end == -1:
+ url_end = len(line)
+ url = "URL=" + line[last_mark:url_end]
+ return url
+
+def format_reported_to(reported_to):
+ reporter = reported_to[REPORTER]
+ url = get_url_from_text(reported_to[RESULT_MESSAGE])
+ if not url:
+ url = reported_to[RESULT_MESSAGE]
+ return reporter + ": " + url
+
+if __name__ == "__main__":
+ try:
+ from sqlite3 import dbapi2 as sqlite
+ db = sqlite.connect(get_db_path())
+ crashes = db.execute("SELECT * FROM abrt_v4")
+ # abrt_v4 TABLE columns:
+ # UUID | UID | INFORMALL | DUMPDIR_PATH | COUNT | REPORTED | TIME | MESSAGE
+ for crash in crashes:
+ # abrt_v4_reportresult columns:
+ # UUID | UID | REPORTER | MESSAGE
+ report_results = db.execute("SELECT * FROM abrt_v4_reportresult WHERE UUID='%s'" % crash[UUID])
+
+ # save count from db to file
+ count_file = "%s/count" % crash[DUMPDIR_PATH]
+ # don't overwrite
+ if not os.path.exists(count_file):
+ try:
+ fout = open(count_file, "w")
+ fout.write(str(crash[COUNT]))
+ fout.close()
+ except Exception, ex:
+ # silently ignore errors -> probably stalled db, but we can't
+ # do much about it, so it's better to not polute the rpm output
+ pass
+
+ # save uuid from db to file
+ uuid_file = "%s/uuid" % crash[DUMPDIR_PATH]
+ # don't overwrite
+ if not os.path.exists(uuid_file):
+ try:
+ fout = open(uuid_file, "w")
+ fout.write(str(crash[UUID]))
+ fout.close()
+ except Exception, ex:
+ # silently ignore errors -> probably stalled db, but we can't
+ # do much about it, so it's better to not polute the rpm output
+ pass
+
+ results = report_results.fetchall()
+ if results:
+ # save report results from db to file
+ reported_to_file = "%s/reported_to" % crash[DUMPDIR_PATH]
+ if not os.path.exists(reported_to_file):
+ try:
+ fout = open(reported_to_file, "w")
+ except Exception, ex:
+ # silently ignore errors -> probably stalled db, but we can't
+ # do much about it, so it's better to not polute the rpm output
+ continue
+
+ for report_result in results:
+ # print "\t", format_reported_to(report_result)
+ # I know, it adds a '\n' to the end, but it's not a problem
+ fout.write("%s\n" % format_reported_to(report_result))
+ fout.close()
+ db.close()
+ except Exception, ex:
+ # in case of any unhandled error, just ignore it, the worst, what
+ # can happen is that the old reports are marked as unreported
+ #print ex
+ pass
More information about the scm-commits
mailing list