yum-qubes-hooks.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/python
  2. #
  3. # The Qubes OS Project, http://www.qubes-os.org
  4. #
  5. # Copyright (C) 2012 Marek Marczykowski <marmarek@invisiblethingslab.com>
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # as published by the Free Software Foundation; either version 2
  10. # of the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. #
  21. #
  22. from yum.plugins import TYPE_CORE
  23. from yum.constants import *
  24. import subprocess
  25. requires_api_version = '2.4'
  26. plugin_type = (TYPE_CORE,)
  27. def posttrans_hook(conduit):
  28. # Get all updates available _before_ this transaction
  29. pkg_list = conduit._base.doPackageLists(pkgnarrow='updates')
  30. # Get packages installed in this transaction...
  31. ts = conduit.getTsInfo()
  32. all = ts.getMembers()
  33. # ...and filter them out of available updates
  34. filtered_updates = filter(lambda x: x not in all, pkg_list.updates)
  35. # Notify dom0 about left updates count
  36. subprocess.call(['/usr/lib/qubes/qrexec-client-vm', 'dom0', 'qubes.NotifyUpdates', '/bin/echo', str(len(filtered_updates))])