[debian-mysql] [RFC PATCH 6/9] - Add Apport hook

Robie Basak robie.basak at canonical.com
Wed Aug 13 17:03:48 UTC 2014


---
 debian/mysql-server-5.6.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 debian/rules               |  2 ++
 2 files changed, 54 insertions(+)
 create mode 100644 debian/mysql-server-5.6.py

diff --git a/debian/mysql-server-5.6.py b/debian/mysql-server-5.6.py
new file mode 100644
index 0000000..07f4f05
--- /dev/null
+++ b/debian/mysql-server-5.6.py
@@ -0,0 +1,52 @@
+'''apport package hook for mysql-5.5
+
+(c) 2009 Canonical Ltd.
+Author: Mathias Gug <mathias.gug at canonical.com>
+'''
+
+from __future__ import print_function, unicode_literals
+import os, os.path
+
+from apport.hookutils import *
+
+def _add_my_conf_files(report, filename):
+    key = 'MySQLConf' + path_to_key(filename)
+    report[key] = ""
+    for line in read_file(filename).split('\n'):
+        try:
+            if 'password' in line.split('=')[0]:
+                line = "%s = @@APPORTREPLACED@@" % (line.split('=')[0])
+            report[key] += line + '\n'
+        except IndexError:
+            continue
+
+def add_info(report):
+    attach_conffiles(report, 'mysql-server-5.5', conffiles=None)
+    key = 'Logs' + path_to_key('/var/log/daemon.log')
+    report[key] = ""
+    for line in read_file('/var/log/daemon.log').split('\n'):
+        try:
+            if 'mysqld' in line.split()[4]:
+                report[key] += line + '\n'
+        except IndexError:
+            continue
+    if os.path.exists('/var/log/mysql/error.log'):
+        key = 'Logs' + path_to_key('/var/log/mysql/error.log')
+        report[key] = ""
+        for line in read_file('/var/log/mysql/error.log').split('\n'):
+            report[key] += line + '\n'
+    attach_mac_events(report, '/usr/sbin/mysqld')
+    attach_file(report,'/etc/apparmor.d/usr.sbin.mysqld')
+    _add_my_conf_files(report, '/etc/mysql/my.cnf')
+    for f in os.listdir('/etc/mysql/conf.d'):
+        _add_my_conf_files(report, os.path.join('/etc/mysql/conf.d', f))
+    try:
+        report['MySQLVarLibDirListing'] = str(os.listdir('/var/lib/mysql'))
+    except OSError:
+        report['MySQLVarLibDirListing'] = str(False)
+
+if __name__ == '__main__':
+    report = {}
+    add_info(report)
+    for key in report:
+        print('%s: %s' % (key, report[key].split('\n', 1)[0]))
diff --git a/debian/rules b/debian/rules
index 53da4cf..6de5125 100755
--- a/debian/rules
+++ b/debian/rules
@@ -179,6 +179,8 @@ auto_install-stamp:
 	# install AppArmor profile
 	install -D -m 644 debian/apparmor-profile $(TMP)/etc/apparmor.d/usr.sbin.mysqld
 	chmod 0755 $(TMP)/usr/share/mysql-test/std_data/checkDBI_DBD-mysql.pl
+	# install Apport hook
+	install -D -m 644 debian/mysql-server-5.6.py $(TMP)/usr/share/apport/package-hooks/source_mysql-5.6.py
 	# chmod 0644 $(TMP)/usr/share/mysql/*.ini
 	chmod 0644 $(TMP)/usr/share/mysql-test/[rt]/*
 	chmod 0644 $(TMP)/usr/share/mysql-test/collections/default.weekly
-- 
1.9.1




More information about the pkg-mysql-maint mailing list