specfile: Refactor get_update_actions to simplify its usage
This commit is contained in:
+1
-1
@@ -608,7 +608,7 @@ def get_package_requirements(packages):
|
||||
version, release, build = installdb.get_version(i_pkg)
|
||||
pkg_actions = pkg.get_update_actions(release)
|
||||
|
||||
for action_name, action_package in pkg_actions:
|
||||
for action_name in pkg_actions:
|
||||
if action_name in actions:
|
||||
requirements[action_name].append(pkg.name)
|
||||
|
||||
|
||||
@@ -531,12 +531,11 @@ class Install(AtomicOperation):
|
||||
else:
|
||||
actions = self.pkginfo.get_update_actions("1")
|
||||
|
||||
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)
|
||||
for package_name in actions.get("serviceRestart", []):
|
||||
pisi.api.add_needs_restart(package_name)
|
||||
|
||||
for package_name in actions.get("systemRestart", []):
|
||||
pisi.api.add_needs_reboot(package_name)
|
||||
|
||||
# filesdb
|
||||
self.filesdb.add_files(self.metadata.package.name, self.files)
|
||||
|
||||
@@ -41,9 +41,10 @@ def check_update_actions(packages):
|
||||
version, release, build = installdb.get_version(package)
|
||||
pkg_actions = pkg.get_update_actions(release)
|
||||
|
||||
for action_name, action_target in pkg_actions:
|
||||
for action_name, action_targets in pkg_actions.items():
|
||||
item = actions.setdefault(action_name, [])
|
||||
item.append((package, action_target))
|
||||
for action_target in action_targets:
|
||||
item.append((package, action_target))
|
||||
|
||||
has_actions = False
|
||||
|
||||
@@ -284,9 +285,9 @@ def plan_upgrade(A, force_replaced=True, replaces=None):
|
||||
version, release, build = installdb.get_version(pkg.name)
|
||||
actions = pkg.get_update_actions(release)
|
||||
|
||||
for action_name, action_package in actions:
|
||||
if action_name == "reverseDependencyUpdate":
|
||||
target_package = action_package or pkg.name
|
||||
packages = actions.get("reverseDependencyUpdate")
|
||||
if packages:
|
||||
for target_package in packages:
|
||||
for name, dep in installdb.get_rev_deps(target_package):
|
||||
if name in G_f.vertices() or not is_upgradable(name):
|
||||
continue
|
||||
|
||||
+10
-5
@@ -325,17 +325,21 @@ class Package:
|
||||
|
||||
return False
|
||||
|
||||
def get_update_actions(self, old_release):
|
||||
def get_update_actions(self, old_release=None):
|
||||
"""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.
|
||||
@rtype: dict
|
||||
@return: A set of affected packages for each action.
|
||||
"""
|
||||
|
||||
actions = set()
|
||||
if old_release is None:
|
||||
installdb = pisi.db.installdb.InstallDB()
|
||||
version, old_release, build = installdb.get_version(self.name)
|
||||
|
||||
actions = {}
|
||||
|
||||
for update in self.history:
|
||||
if update.release == old_release:
|
||||
@@ -345,7 +349,8 @@ class Package:
|
||||
if action.package and action.package != self.name:
|
||||
continue
|
||||
|
||||
actions.add((action.action, action.target))
|
||||
target = action.target or self.name
|
||||
actions.setdefault(action.action, set()).add(target)
|
||||
|
||||
return actions
|
||||
|
||||
|
||||
Reference in New Issue
Block a user