From 8023c660208c2ad59fd9d24e7474929d9317fc57 Mon Sep 17 00:00:00 2001 From: Marek Marczykowski Date: Tue, 5 Jun 2012 19:28:59 +0200 Subject: [PATCH] vm: yum plugin to notify dom0 about installed updates (#592) --- misc/Makefile | 7 +++++-- misc/yum-qubes-hooks.py | 42 +++++++++++++++++++++++++++++++++++++++++ rpm_spec/core-vm.spec | 3 +++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 misc/yum-qubes-hooks.py diff --git a/misc/Makefile b/misc/Makefile index 3b015060..e6f653a0 100644 --- a/misc/Makefile +++ b/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 diff --git a/misc/yum-qubes-hooks.py b/misc/yum-qubes-hooks.py new file mode 100644 index 00000000..f49eac2f --- /dev/null +++ b/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 +# +# 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))]) diff --git a/rpm_spec/core-vm.spec b/rpm_spec/core-vm.spec index 88b26870..7b647969 100644 --- a/rpm_spec/core-vm.spec +++ b/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