from yum.plugins import TYPE_INTERACTIVE
import subprocess
requires_api_version = '2.3'
plugin_type = (TYPE_INTERACTIVE)
check_needed = False
def posttrans_hook(conduit):
check_needed = True
# acting in posttrans_hook is too early, we need to be sure the RPMDB is closed to avoid things like:
# « Rpmdb changed underneath us » followed by failure to open the database on the next YUM call
def close_hook(conduit):
if not check_needed:
return
try:
subprocess.call(['needrestart'])
except OSError:
# this tool is being removed
pass