specfile: Replace get_update_types_and_actions function with faster ones
This commit is contained in:
+1
-1
@@ -606,7 +606,7 @@ def get_package_requirements(packages):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
version, release, build = installdb.get_version(i_pkg)
|
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:
|
for action_name, action_package in pkg_actions:
|
||||||
if action_name in actions:
|
if action_name in actions:
|
||||||
|
|||||||
@@ -517,9 +517,9 @@ class Install(AtomicOperation):
|
|||||||
# need service or system restart?
|
# need service or system restart?
|
||||||
if self.installdb.has_package(self.pkginfo.name):
|
if self.installdb.has_package(self.pkginfo.name):
|
||||||
(version, release, build) = self.installdb.get_version(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:
|
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:
|
for action_name, action_package in actions:
|
||||||
package_name = action_package or self.pkginfo.name
|
package_name = action_package or self.pkginfo.name
|
||||||
|
|||||||
@@ -56,9 +56,7 @@ def find_upgrades(packages, replaces):
|
|||||||
pkg = packagedb.get_package(i_pkg)
|
pkg = packagedb.get_package(i_pkg)
|
||||||
(version, release, build, distro, distro_release) = installdb.get_version_and_distro_release(i_pkg)
|
(version, release, build, distro, distro_release) = installdb.get_version_and_distro_release(i_pkg)
|
||||||
|
|
||||||
if security_only:
|
if security_only and not pkg.has_update_type("security", release):
|
||||||
types, actions = pkg.get_update_types_and_actions(release)
|
|
||||||
if "security" not in types:
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if pkg.distribution == distro and \
|
if pkg.distribution == distro and \
|
||||||
@@ -250,7 +248,7 @@ def plan_upgrade(A, force_replaced=True, replaces=None):
|
|||||||
for x in B:
|
for x in B:
|
||||||
pkg = packagedb.get_package(x)
|
pkg = packagedb.get_package(x)
|
||||||
(version, release, build) = installdb.get_version(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:
|
for action_name, action_package in actions:
|
||||||
if action_name == "reverseDependencyUpdate":
|
if action_name == "reverseDependencyUpdate":
|
||||||
|
|||||||
+53
-8
@@ -269,18 +269,17 @@ class Package:
|
|||||||
"""calculate if pkg is installable currently"""
|
"""calculate if pkg is installable currently"""
|
||||||
return self.satisfies_runtime_dependencies()
|
return self.satisfies_runtime_dependencies()
|
||||||
|
|
||||||
def get_update_types_and_actions(self, old_release):
|
def get_update_types(self, old_release):
|
||||||
"""Return update types and actions effective for the binary package
|
"""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
|
@rtype: set of strings
|
||||||
types: Set of type strings
|
@return: Update types.
|
||||||
actions: Set of (action name, package) pairs
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
types = set()
|
types = set()
|
||||||
actions = set()
|
|
||||||
|
|
||||||
for update in self.history:
|
for update in self.history:
|
||||||
if update.release == old_release:
|
if update.release == old_release:
|
||||||
@@ -295,13 +294,59 @@ class Package:
|
|||||||
|
|
||||||
types.add(type_.type)
|
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:
|
for action in update.requires:
|
||||||
if action.package and action.package != self.name:
|
if action.package and action.package != self.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
actions.add((action.action, action.targetPackage))
|
actions.add((action.action, action.targetPackage))
|
||||||
|
|
||||||
return types, actions
|
return actions
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.build:
|
if self.build:
|
||||||
|
|||||||
Reference in New Issue
Block a user