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)
|
version, release, build = installdb.get_version(i_pkg)
|
||||||
pkg_actions = pkg.get_update_actions(release)
|
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:
|
if action_name in actions:
|
||||||
requirements[action_name].append(pkg.name)
|
requirements[action_name].append(pkg.name)
|
||||||
|
|
||||||
|
|||||||
@@ -531,12 +531,11 @@ class Install(AtomicOperation):
|
|||||||
else:
|
else:
|
||||||
actions = self.pkginfo.get_update_actions("1")
|
actions = self.pkginfo.get_update_actions("1")
|
||||||
|
|
||||||
for action_name, action_package in actions:
|
for package_name in actions.get("serviceRestart", []):
|
||||||
package_name = action_package or self.pkginfo.name
|
pisi.api.add_needs_restart(package_name)
|
||||||
if action_name == "serviceRestart":
|
|
||||||
pisi.api.add_needs_restart(package_name)
|
for package_name in actions.get("systemRestart", []):
|
||||||
elif action_name == "systemRestart":
|
pisi.api.add_needs_reboot(package_name)
|
||||||
pisi.api.add_needs_reboot(package_name)
|
|
||||||
|
|
||||||
# filesdb
|
# filesdb
|
||||||
self.filesdb.add_files(self.metadata.package.name, self.files)
|
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)
|
version, release, build = installdb.get_version(package)
|
||||||
pkg_actions = pkg.get_update_actions(release)
|
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 = actions.setdefault(action_name, [])
|
||||||
item.append((package, action_target))
|
for action_target in action_targets:
|
||||||
|
item.append((package, action_target))
|
||||||
|
|
||||||
has_actions = False
|
has_actions = False
|
||||||
|
|
||||||
@@ -284,9 +285,9 @@ def plan_upgrade(A, force_replaced=True, replaces=None):
|
|||||||
version, release, build = installdb.get_version(pkg.name)
|
version, release, build = installdb.get_version(pkg.name)
|
||||||
actions = pkg.get_update_actions(release)
|
actions = pkg.get_update_actions(release)
|
||||||
|
|
||||||
for action_name, action_package in actions:
|
packages = actions.get("reverseDependencyUpdate")
|
||||||
if action_name == "reverseDependencyUpdate":
|
if packages:
|
||||||
target_package = action_package or pkg.name
|
for target_package in packages:
|
||||||
for name, dep in installdb.get_rev_deps(target_package):
|
for name, dep in installdb.get_rev_deps(target_package):
|
||||||
if name in G_f.vertices() or not is_upgradable(name):
|
if name in G_f.vertices() or not is_upgradable(name):
|
||||||
continue
|
continue
|
||||||
|
|||||||
+10
-5
@@ -325,17 +325,21 @@ class Package:
|
|||||||
|
|
||||||
return False
|
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.
|
"""Returns update actions for the releases greater than old_release.
|
||||||
|
|
||||||
@type old_release: string
|
@type old_release: string
|
||||||
@param old_release: The release of the installed package.
|
@param old_release: The release of the installed package.
|
||||||
|
|
||||||
@rtype: set of tuples
|
@rtype: dict
|
||||||
@return: A set of (action name, target package) tuples.
|
@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:
|
for update in self.history:
|
||||||
if update.release == old_release:
|
if update.release == old_release:
|
||||||
@@ -345,7 +349,8 @@ class Package:
|
|||||||
if action.package and action.package != self.name:
|
if action.package and action.package != self.name:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
actions.add((action.action, action.target))
|
target = action.target or self.name
|
||||||
|
actions.setdefault(action.action, set()).add(target)
|
||||||
|
|
||||||
return actions
|
return actions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user