diff --git a/pisi/api.py b/pisi/api.py index 82580e37..22a5fe72 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -606,7 +606,7 @@ def get_package_requirements(packages): pass version, release, build = installdb.get_version(i_pkg) - pkg_types, pkg_actions = pkg.get_update_types_and_actions(release) + pkg_actions = pkg.get_update_actions(release) for action_name, action_package in pkg_actions: if action_name in actions: diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index f9732867..7e1f3de2 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -517,9 +517,9 @@ class Install(AtomicOperation): # need service or system restart? if self.installdb.has_package(self.pkginfo.name): (version, release, build) = self.installdb.get_version(self.pkginfo.name) - types, actions = self.pkginfo.get_update_types_and_actions(release) + actions = self.pkginfo.get_update_actions(release) else: - types, actions = self.pkginfo.get_update_types_and_actions("1") + actions = self.pkginfo.get_update_actions("1") for action_name, action_package in actions: package_name = action_package or self.pkginfo.name diff --git a/pisi/operations/upgrade.py b/pisi/operations/upgrade.py index 3d8d78df..c4420fa4 100644 --- a/pisi/operations/upgrade.py +++ b/pisi/operations/upgrade.py @@ -56,10 +56,8 @@ def find_upgrades(packages, replaces): pkg = packagedb.get_package(i_pkg) (version, release, build, distro, distro_release) = installdb.get_version_and_distro_release(i_pkg) - if security_only: - types, actions = pkg.get_update_types_and_actions(release) - if "security" not in types: - continue + if security_only and not pkg.has_update_type("security", release): + continue if pkg.distribution == distro and \ pisi.version.make_version(pkg.distributionRelease) > pisi.version.make_version(distro_release): @@ -250,7 +248,7 @@ 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) - types, actions = pkg.get_update_types_and_actions(release) + actions = pkg.get_update_actions(release) for action_name, action_package in actions: if action_name == "reverseDependencyUpdate": diff --git a/pisi/specfile.py b/pisi/specfile.py index 151216bd..40d440ab 100644 --- a/pisi/specfile.py +++ b/pisi/specfile.py @@ -269,18 +269,17 @@ class Package: """calculate if pkg is installable currently""" return self.satisfies_runtime_dependencies() - def get_update_types_and_actions(self, old_release): - """Return update types and actions effective for the binary package + def get_update_types(self, old_release): + """Returns update types for the releases greater than old_release. - get_update_types_and_actions(self, old_release) -> (types, actions) + @type old_release: string + @param old_release: The release of the installed package. - old_release: Release of the installed package - types: Set of type strings - actions: Set of (action name, package) pairs + @rtype: set of strings + @return: Update types. """ types = set() - actions = set() for update in self.history: if update.release == old_release: @@ -295,13 +294,59 @@ class Package: types.add(type_.type) + return types + + def has_update_type(self, type_name, old_release): + """Checks whether the package has the given update type. + + @type type_name: string + @param type_name: Name of the update type. + @type old_release: string + @param old_release: The release of the installed package. + + @rtype: bool + @return: True if the type exists, else False. + """ + + for update in self.history: + if update.release == old_release: + break + + if update.type == type_name: + return True + + for type_ in update.types: + if type_.package and type_.package != self.name: + continue + + if type_.type == type_name: + return True + + return False + + def get_update_actions(self, old_release): + """Returns update actions for the releases greater than old_release. + + @type old_release: string + @param old_release: The release of the installed package. + + @rtype: set of tuples + @return: A set of (action name, target package) tuples. + """ + + actions = set() + + for update in self.history: + if update.release == old_release: + break + for action in update.requires: if action.package and action.package != self.name: continue actions.add((action.action, action.targetPackage)) - return types, actions + return actions def __str__(self): if self.build: