53 lines
1.7 KiB
Diff
53 lines
1.7 KiB
Diff
diff --git a/etckeeper-dnf/etckeeper.py b/etckeeper-dnf/etckeeper.py
|
|
index e8a1a51..7c3210b 100644
|
|
--- a/etckeeper-dnf/etckeeper.py
|
|
+++ b/etckeeper-dnf/etckeeper.py
|
|
@@ -7,30 +7,34 @@
|
|
# Distutils code below was copied from etckeeper-bzr distributed with v1.15
|
|
#
|
|
|
|
-from dnfpluginscore import logger
|
|
-
|
|
-import os
|
|
+import logging
|
|
+import subprocess
|
|
import dnf
|
|
|
|
+logger = logging.getLogger('dnf.plugin')
|
|
+
|
|
|
|
class Etckeeper(dnf.Plugin):
|
|
|
|
name = 'etckeeper'
|
|
|
|
- def _out(self, msg):
|
|
- logger.debug('Etckeeper plugin: %s', msg)
|
|
+ def _run_command(self, command):
|
|
+ logger.debug('Etckeeper plugin: %s', command)
|
|
+ try:
|
|
+ with open("/dev/null", "wb") as devnull:
|
|
+ ret = subprocess.call(("etckeeper", command),
|
|
+ stdout=devnull, stderr=devnull,
|
|
+ close_fds=True)
|
|
+ if ret != 0:
|
|
+ raise dnf.exceptions.Error('"etckeeper %s" returned: %d' % (command, ret))
|
|
+ except OSError as err:
|
|
+ logger.warning('Failed to run "etckeeper %s": %s' % (command, err))
|
|
|
|
def resolved(self):
|
|
- self._out('pre transaction commit')
|
|
- command = '%s %s' % ('etckeeper', " pre-install")
|
|
- ret = os.system(command)
|
|
- if ret != 0:
|
|
- raise dnf.exceptions.Error('etckeeper returned %d' % (ret >> 8))
|
|
+ self._run_command("pre-install")
|
|
|
|
def transaction(self):
|
|
- self._out('post transaction commit')
|
|
- command = '%s %s > /dev/null' % ('etckeeper', "post-install")
|
|
- os.system(command)
|
|
+ self._run_command("post-install")
|
|
|
|
if __name__ == "__main__":
|
|
from distutils.core import setup
|