Browse Source

vm: yum plugin to notify dom0 about installed updates (#592)

Marek Marczykowski 12 years ago
parent
commit
06c4d57b60
3 changed files with 50 additions and 2 deletions
  1. 5 2
      misc/Makefile
  2. 42 0
      misc/yum-qubes-hooks.py
  3. 3 0
      rpm_spec/core-vm.spec

+ 5 - 2
misc/Makefile

@@ -1,9 +1,12 @@
 CC=gcc
 CFLAGS=-Wall -g -O3
-all:	meminfo-writer xenstore-watch
+all:	meminfo-writer xenstore-watch python
 meminfo-writer: meminfo-writer.o
 	$(CC) -g -o meminfo-writer meminfo-writer.o -lxenstore
 xenstore-watch: xenstore-watch.o
 	$(CC) -o xenstore-watch xenstore-watch.o -lxenstore
+python:
+	python -m compileall .
+	python -O -m compileall .
 clean:
-	rm -f meminfo-writer xenstore-watch *.o *~
+	rm -f meminfo-writer xenstore-watch *.o *~ *.pyc *.pyo

+ 42 - 0
misc/yum-qubes-hooks.py

@@ -0,0 +1,42 @@
+#!/usr/bin/python
+#
+# The Qubes OS Project, http://www.qubes-os.org
+#
+# Copyright (C) 2012  Marek Marczykowski <marmarek@invisiblethingslab.com>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#
+#
+
+
+from yum.plugins import TYPE_CORE
+from yum.constants import *
+import subprocess
+
+requires_api_version = '2.4'
+plugin_type = (TYPE_CORE,)
+            
+def posttrans_hook(conduit):
+    # Get all updates available _before_ this transaction
+    pkg_list = conduit._base.doPackageLists(pkgnarrow='updates')
+
+    # Get packages installed in this transaction...
+    ts = conduit.getTsInfo()
+    all = ts.getMembers()
+    # ...and filter them out of available updates
+    filtered_updates = filter(lambda x: x not in all, pkg_list.updates)
+
+    # Notify dom0 about left updates count
+    subprocess.call(['/usr/lib/qubes/qrexec_client_vm', 'dom0', 'qubes.NotifyUpdates', 'echo', str(len(filtered_updates))])

+ 3 - 0
rpm_spec/core-vm.spec

@@ -99,6 +99,8 @@ install -D -m 0644 misc/serial.conf $RPM_BUILD_ROOT/usr/lib/qubes/serial.conf
 install -D misc/qubes_serial_login $RPM_BUILD_ROOT/sbin/qubes_serial_login
 install -d $RPM_BUILD_ROOT/usr/share/glib-2.0/schemas/
 install -m 0644 misc/org.gnome.settings-daemon.plugins.updates.gschema.override $RPM_BUILD_ROOT/usr/share/glib-2.0/schemas/
+install -d $RPM_BUILD_ROOT/usr/lib/yum-plugins/
+install -m 0644 misc/yum-qubes-hooks.py* $RPM_BUILD_ROOT/usr/lib/yum-plugins/
 
 install -d $RPM_BUILD_ROOT/var/lib/qubes
 
@@ -386,6 +388,7 @@ rm -rf $RPM_BUILD_ROOT
 /usr/lib/qubes/vm-file-editor
 /usr/lib/qubes/vm-shell
 /usr/lib/qubes/wrap_in_html_if_url.sh
+/usr/lib/yum-plugins/yum-qubes-hooks.py*
 /usr/sbin/qubes_firewall
 /usr/sbin/qubes_netwatcher
 /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override