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>
This commit is contained in:
parent
08c96d94e6
commit
08b81b570e
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):
|
def expand_package_groups(module, pacman_path, pkgs):
|
||||||
expanded = []
|
expanded = []
|
||||||
|
|
||||||
|
__, stdout, __ = module.run_command([pacman_path, "--sync", "--groups", "--quiet"], check_rc=True)
|
||||||
|
available_groups = stdout.splitlines()
|
||||||
|
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
if pkg: # avoid empty strings
|
if pkg: # avoid empty strings
|
||||||
cmd = "%s --sync --groups --quiet %s" % (pacman_path, pkg)
|
if pkg in available_groups:
|
||||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
# A group was found matching the package name: expand it
|
||||||
|
cmd = [pacman_path, "--sync", "--groups", "--quiet", pkg]
|
||||||
if rc == 0:
|
rc, stdout, stderr = module.run_command(cmd, check_rc=True)
|
||||||
# A group was found matching the name, so expand it
|
expanded.extend([name.strip() for name in stdout.splitlines()])
|
||||||
for name in stdout.split('\n'):
|
|
||||||
name = name.strip()
|
|
||||||
if name:
|
|
||||||
expanded.append(name)
|
|
||||||
else:
|
else:
|
||||||
expanded.append(pkg)
|
expanded.append(pkg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue