mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
For each package check membership in the list instead of checking each
package individually using pacman to see if it is a pacman group.
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 08b81b570e
)
Co-authored-by: Jürgen Hötzel <juergen@hoetzel.info>
This commit is contained in:
parent
c0971e41b0
commit
97507b50b5
2 changed files with 10 additions and 9 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- "pacman - improve group expansion speed: query list of pacman groups once (https://github.com/ansible-collections/community.general/pull/349)."
|
|
@ -396,17 +396,16 @@ def check_packages(module, pacman_path, packages, state):
|
|||
def expand_package_groups(module, pacman_path, pkgs):
|
||||
expanded = []
|
||||
|
||||
__, stdout, __ = module.run_command([pacman_path, "--sync", "--groups", "--quiet"], check_rc=True)
|
||||
available_groups = stdout.splitlines()
|
||||
|
||||
for pkg in pkgs:
|
||||
if pkg: # avoid empty strings
|
||||
cmd = "%s --sync --groups --quiet %s" % (pacman_path, pkg)
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||
|
||||
if rc == 0:
|
||||
# A group was found matching the name, so expand it
|
||||
for name in stdout.split('\n'):
|
||||
name = name.strip()
|
||||
if name:
|
||||
expanded.append(name)
|
||||
if pkg in available_groups:
|
||||
# A group was found matching the package name: expand it
|
||||
cmd = [pacman_path, "--sync", "--groups", "--quiet", pkg]
|
||||
rc, stdout, stderr = module.run_command(cmd, check_rc=True)
|
||||
expanded.extend([name.strip() for name in stdout.splitlines()])
|
||||
else:
|
||||
expanded.append(pkg)
|
||||
|
||||
|
|
Loading…
Reference in a new issue