specfile: Replace get_update_types_and_actions function with faster ones

This commit is contained in:
Fatih Aşıcı
2010-03-18 09:33:22 +00:00
parent 4d0d4f33f4
commit b7a13317dd
4 changed files with 59 additions and 16 deletions
+1 -1
View File
@@ -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:
+2 -2
View File
@@ -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
+3 -5
View File
@@ -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":
+53 -8
View File
@@ -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: