[packagekit] [RFE] Reboot on upgrade ???
Luke Macken
lmacken at redhat.com
Mon Nov 19 08:50:52 PST 2007
On Sat, Nov 17, 2007 at 09:07:01PM -0500, Matthias Clasen wrote:
> On Nov 17, 2007 8:34 PM, Ray Strode <halfline at gmail.com> wrote:
> > Hi,
> >
> > On Nov 16, 2007 10:51 AM, Richard Hughes <hughsient at gmail.com> wrote:
> > > On Fri, 2007-11-16 at 16:34 +0100, Matej Cepl wrote:
> > > > pup has a nice functionality in having dialog box "Rebooting
> > > > required? [Now] [Later]" when some low-level important packages
> > > > (e.g., kernel, glibc, hal, etc.) are upgraded. I am not sure
> > > > (will investigate) whether pup gets information about which
> > > > packages requires restart somewhere from some metada or it has
> > > > hard-wired list in its code
> > >
> > > hard coded IIRC.
> > It's in the metadata, too, but pup (until recently) ignored the
> > metadata and just used a hard coded list. Now I think it checks
> > against metadata AND the list.
>
> Really ? How do I put it in the metadata ? Bodhi doesn't seem to
> expose that, at least.
Bodhi has been putting the reboot_suggested field into the
updateinfo.xml for a long time now, which was based on a hardcoded list.
The other day I added a "Suggest Reboot" checkbox to the new update form as
well. Although, looking at the RequireRestart signal, I could
potentially allow people to choose between restarting the
application/session/system. This will require some modifications to the
yum.update_md module to handle these different types.
After a quick look at the yumBackend code, it seems that the
reboot_suggested field is only being pulled from the UpdateMetadata
during get_update_detail(). _check_for_reboot() is called during
_runYumTransaction, but it looks like it only checks if the package is
listed in the hardcoded list, without looking at the UpdateMetadata.
Attached is a patch that turns the updateMetadata into a property(), and
updates the rebootpkgs on the fly with any packages that are flagged
with reboot_suggested in the updateinfo. Aside from running the
backend test suite, I have not performed any further testing with it.
Tim, what are your thoughts on it ?
Once/If yum/bodhi starts to handle different restart types
(session/system/application), this code will have to change as well.
luke
-------------- next part --------------
>From 6e48dd68e70b0ee324ca5db2ef6d3622da7eba37 Mon Sep 17 00:00:00 2001
From: lmacken at redhat.com <lmacken at redhat.com>
Date: Mon, 19 Nov 2007 11:46:37 -0500
Subject: [PATCH] - Create a PackageKitYumBackend.updateMetadata property, which parses the updateinfo.xml.gz from the repodata on the fly.
- Dynamically update the rebootpkgs list with any updates that are flagged with reboot_suggested in the updateinfo.
---
backends/yum/helpers/yumBackend.py | 47 +++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 5b8fe18..e523b8b 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -201,9 +201,9 @@ def sigquit(signum, frame):
class PackageKitYumBackend(PackageKitBaseBackend):
# Packages there require a reboot
- rebootpkgs = ("kernel", "kernel-smp", "kernel-xen-hypervisor", "kernel-PAE",
- "kernel-xen0", "kernel-xenU", "kernel-xen", "kernel-xen-guest",
- "glibc", "hal", "dbus", "xen")
+ rebootpkgs = ["kernel", "kernel-smp", "kernel-xen-hypervisor", "kernel-PAE",
+ "kernel-xen0", "kernel-xenU", "kernel-xen", "kernel-xen-guest",
+ "glibc", "hal", "dbus", "xen"]
def __init__(self,args,lock=True):
signal.signal(signal.SIGQUIT, sigquit)
@@ -836,8 +836,12 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.error(ERROR_PACKAGE_ALREADY_INSTALLED,"No available updates")
def _check_for_reboot(self):
+ md = self.updateMetadata
for txmbr in self.yumbase.tsInfo:
pkg = txmbr.po
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice and notice['reboot_suggested']:
+ self.rebootpkgs.append(pkg.name)
# check if package is in reboot list and is installed/updated etc
print pkg.name,txmbr.output_state
if pkg.name in self.rebootpkgs and txmbr.ts_state in TS_INSTALL_STATES:
@@ -982,14 +986,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
self.allow_interrupt(True)
self.percentage(None)
self.status(STATUS_INFO)
- md = UpdateMetadata()
- # Added extra Update Metadata
- for repo in self.yumbase.repos.listEnabled():
- try:
- md.add(repo)
- except:
- pass # No updateinfo.xml.gz in repo
-
+ md = self.updateMetadata
ygl = self.yumbase.doPackageLists(pkgnarrow='updates')
for pkg in ygl.updates:
# Get info about package in updates info
@@ -1043,15 +1040,27 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
return ""
+ def _get_update_metadata(self):
+ if not self._updateMetadata:
+ self._updateMetadata = UpdateMetadata()
+ for repo in self.yumbase.repos.listEnabled():
+ try:
+ md.add(repo)
+ except:
+ pass # No updateinfo.xml.gz in repo
+ return self._updateMetadata
+
+ _updateMetadata = None
+ updateMetadata = property(fget=_get_update_metadata)
+
def _get_update_extras(self,pkg):
- md = UpdateMetadata()
- if md:
- notice = md.get_notice((pkg.name, pkg.version, pkg.release))
- if notice:
- desc = notice['description']
- url = notice['references']
- reboot = notice['reboot_suggested']
- return desc.replace('\n',';'),url,reboot
+ md = self.updateMetadata
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if notice:
+ desc = notice['description']
+ url = notice['references']
+ reboot = notice['reboot_suggested']
+ return desc.replace('\n',';'),url,reboot
return "","",""
def get_update_detail(self,package):
--
1.5.3.4
More information about the PackageKit
mailing list