diff --git a/pisi/api.py b/pisi/api.py index 9d59f859..82580e37 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -605,16 +605,12 @@ def get_package_requirements(packages): except Exception: #FIXME: Should catch RepoItemNotFound exception pass - (version, release, build) = installdb.get_version(i_pkg) - release = int(release) + version, release, build = installdb.get_version(i_pkg) + pkg_types, pkg_actions = pkg.get_update_types_and_actions(release) - for update in pkg.history: - if int(update.release) <= release: - break - - for action in update.required_actions(): - if action in actions: - requirements[action].append(pkg.name) + for action_name, action_package in pkg_actions: + if action_name in actions: + requirements[action_name].append(pkg.name) return requirements diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index cc047e7d..f9732867 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -514,22 +514,19 @@ class Install(AtomicOperation): if self.config_later: self.installdb.mark_pending(self.pkginfo.name) - # get update history + # need service or system restart? if self.installdb.has_package(self.pkginfo.name): (version, release, build) = self.installdb.get_version(self.pkginfo.name) - updates = [] - for update in self.pkginfo.history: - if update.release == release: - break - updates.append(update) + types, actions = self.pkginfo.get_update_types_and_actions(release) else: - updates = self.pkginfo.history + types, actions = self.pkginfo.get_update_types_and_actions("1") - # 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) + for action_name, action_package in actions: + package_name = action_package or self.pkginfo.name + if action_name == "serviceRestart": + pisi.api.add_needs_restart(package_name) + elif action_name == "systemRestart": + pisi.api.add_needs_reboot(package_name) # filesdb self.filesdb.add_files(self.metadata.package.name, self.files) diff --git a/pisi/operations/upgrade.py b/pisi/operations/upgrade.py index f533bba0..3d8d78df 100644 --- a/pisi/operations/upgrade.py +++ b/pisi/operations/upgrade.py @@ -57,14 +57,8 @@ def find_upgrades(packages, replaces): (version, release, build, distro, distro_release) = installdb.get_version_and_distro_release(i_pkg) if security_only: - security_update = False - for update in pkg.history: - if update.release == release: - break - if update.type == "security": - security_update = True - break - if not security_update: + types, actions = pkg.get_update_types_and_actions(release) + if "security" not in types: continue if pkg.distribution == distro and \ @@ -256,17 +250,18 @@ def plan_upgrade(A, force_replaced=True, replaces=None): for x in B: pkg = packagedb.get_package(x) (version, release, build) = installdb.get_version(x) - for update in pkg.history: - if update.release == release: - break + types, actions = pkg.get_update_types_and_actions(release) - if "reverseDependencyUpdate" in update.required_actions(): - for name, dep in packagedb.get_rev_deps(x): + for action_name, action_package in actions: + if action_name == "reverseDependencyUpdate": + target_package = action_package or x + for name, dep in packagedb.get_rev_deps(target_package): if name in G_f.vertices() or not is_upgradable(name): continue Bp.add(name) - G_f.add_plain_dep(name, x) + G_f.add_plain_dep(name, target_package) + B = Bp if ctx.config.get_option('debug'): diff --git a/pisi/specfile.py b/pisi/specfile.py index 80bc0612..151216bd 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -118,12 +118,6 @@ class Update: t_Email = [autoxml.String, autoxml.optional] t_Requires = [[Action], autoxml.optional] - def required_actions(self): - if self.requires != None: - return map(lambda x:str(x), self.requires) - else: - return [] - def __str__(self): s = self.date s += ", ver=" + self.version