yum-qubes-hooks.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/python2
  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. import subprocess
  24. requires_api_version = '2.4'
  25. plugin_type = (TYPE_CORE,)
  26. def posttrans_hook(conduit):
  27. if conduit.confBool('main', 'notify-updates', default=True):
  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_transactions = ts.getMembers()
  33. # ...and filter them out of available updates
  34. filtered_updates = list(
  35. filter(lambda x: x not in all_transactions, pkg_list.updates))
  36. # Notify dom0 about left updates count
  37. subprocess.call(
  38. ['/usr/lib/qubes/qrexec-client-vm', 'dom0', 'qubes.NotifyUpdates',
  39. '/bin/echo', str(len(filtered_updates))])
  40. conduit.info(1, "Notifying dom0 about installed/removed applications")
  41. # Notify and add app to app-menus
  42. subprocess.call(['/etc/qubes-rpc/qubes.PostInstall'])