From 26d14982c7f09be8f4276241e9fe3ae947d6a653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bahad=C4=B1r=20Kandemir?= Date: Tue, 8 Dec 2009 15:20:35 +0000 Subject: [PATCH] Add package name to needs{Restart,Reboot} list if an update requires one of these actions. IMHO, update_databases() method in Install class is suitable for this operation, feel free to move/refactor code if I'm wrong. --- ChangeLog | 4 ++++ pisi/atomicoperations.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 42a0d2fe..ddb5cfd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-12-08 Bahadır Kandemir + * pisi/atomicoperations.py: Add package name to needs{Restart,Reboot} + list if an update requires one of these actions. + 2009-12-07 Bahadır Kandemir * pisi/api.py, pisi/db/install.db, pisi/constants.py: Install DB changes and API methods for needs{Restart,Reboot} feature. diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 985060a1..7c63a534 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -449,6 +449,19 @@ class Install(AtomicOperation): if self.config_later: self.installdb.mark_pending(self.pkginfo.name) + # get update history + if self.installdb.has_package(self.pkginfo.name): + (version, release, build) = self.installdb.get_version(self.pkginfo.name) + updates = [i for i in self.pkginfo.history if pisi.version.Version(i.release) > pisi.version.Version(release)] + else: + updates = self.pkginfo.history + + # need service or system restart? + if pisi.util.any(lambda u:"serviceRestart" in u.required_actions(), updates): + pisi.api.add_needs_restart(self.pkginfo.name) + if pisi.util.any(lambda u:"systemRestart" in u.required_actions(), updates): + pisi.api.add_needs_reboot(self.pkginfo.name) + # filesdb self.filesdb.add_files(self.metadata.package.name, self.files)