summaryrefslogtreecommitdiff
path: root/yum-etckeeper.py
diff options
context:
space:
mode:
authorJoey Hess <joeyh@debian.org>2013-07-31 11:33:45 -0400
committerJoey Hess <joeyh@debian.org>2013-07-31 11:33:45 -0400
commitfdeec420b54e252e611c353ce39fe61c924e3e7d (patch)
tree2a1974e6c8cc56263e3903f49ea2a841ea895c6d /yum-etckeeper.py
etckeeper (1.7) unstable; urgency=low
* Fix hilarious typo hardcoding my name. Closes: #718425 # imported from the archive
Diffstat (limited to 'yum-etckeeper.py')
-rw-r--r--yum-etckeeper.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/yum-etckeeper.py b/yum-etckeeper.py
new file mode 100644
index 0000000..b77a93b
--- /dev/null
+++ b/yum-etckeeper.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+#
+# author: jtang@tchpc.tcd.ie
+#
+# this plugin is based on the hello world example
+# from http://yum.baseurl.org/wiki/WritingYumPlugins
+#
+# to install, copy this file to /usr/lib/yum-plugins/etckeeper.py
+# and then create /etc/yum/pluginconf.d/etckeeper.conf with the contents
+# below.
+#
+# /etc/yum/pluginconf.d/etckeeper.conf:
+# [main]
+# enabled=1
+#
+
+import os
+from glob import fnmatch
+
+import yum
+from yum.plugins import PluginYumExit, TYPE_CORE
+
+requires_api_version = '2.1'
+plugin_type = (TYPE_CORE,)
+
+def pretrans_hook(conduit):
+ conduit.info(2, 'etckeeper: pre transaction commit')
+ servicecmd = conduit.confString('main', 'servicecmd', '/usr/bin/etckeeper')
+ command = '%s %s' % (servicecmd, " pre-install")
+ ret = os.system(command)
+ if ret != 0:
+ raise PluginYumExit('etckeeper returned %d' % (ret >> 8))
+
+def posttrans_hook(conduit):
+ conduit.info(2, 'etckeeper: post transaction commit')
+ if os.path.exists('/usr/bin/etckeeper'):
+ servicecmd = conduit.confString('main', 'servicecmd', '/usr/bin/etckeeper')
+ command = '%s %s > /dev/null' % (servicecmd, "post-install")
+ os.system(command)