[packagekit] [RFE] Reboot on upgrade ???
Luke Macken
lmacken at redhat.com
Mon Nov 19 11:42:29 PST 2007
On Mon, Nov 19, 2007 at 12:34:34PM -0500, Ray Strode wrote:
> Hi,
>
> > 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 ?
>
> @@ -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:
>
> Skimming the patch,
>
> + if notice and notice['reboot_suggested']:
>
> should probably be
>
> + if notice and notice.has_key('reboot_suggested') and
> notice['reboot_suggested']:
Not really necessary, as every UpdateNotice will always have this field.
But being extra paranoid is probably not a bad thing :)
> Although, maybe you don't want to edit the rebootpkgs list and instead
> keep it hardcoded and readonly?
Works for me. Attached is a reworked patch that leaves the rebootpkgs
tuple alone, makes sure the notice has the reboot_suggested field, and
utilizes it in the "pkg.name in self.rebootpkgs" conditional.
luke
-------------- next part --------------
>From 99b6507bafd34fc7842c2e879de693f731426bd8 Mon Sep 17 00:00:00 2001
From: Luke Macken <lmacken at redhat.com>
Date: Mon, 19 Nov 2007 14:39:05 -0500
Subject: [PATCH] Improved yum UpdateMetadata handling
- Create a PackageKitYumBackend.updateMetadata property, which parses the updateinfo.xml.gz from the repodata on the fly.
- Utilize the reboot_suggested field in the UpdateMetadata
---
backends/yum/helpers/yumBackend.py | 46 ++++++++++++++++++++++--------------
1 files changed, 28 insertions(+), 18 deletions(-)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 5b8fe18..451d24e 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -836,11 +836,16 @@ 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
- # check if package is in reboot list and is installed/updated etc
+ # check if package is in reboot list or flagged with reboot_suggested
+ # in the update metadata 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:
+ notice = md.get_notice((pkg.name, pkg.version, pkg.release))
+ if (pkg.name in self.rebootpkgs or (notice and
+ notice.has_key('reboot_suggested') and notice['reboot_suggested']))\
+ and txmbr.ts_state in TS_INSTALL_STATES:
self.require_restart(RESTART_SYSTEM,"")
break
@@ -982,14 +987,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 +1041,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