mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
fixed issue with empty string 'packages'
also cleaned up unused imports/vars fixes #25582
This commit is contained in:
parent
9725e056bc
commit
ff4c308359
1 changed files with 14 additions and 16 deletions
|
@ -143,10 +143,7 @@ EXAMPLES = '''
|
||||||
force: yes
|
force: yes
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import shlex
|
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
def get_version(pacman_output):
|
def get_version(pacman_output):
|
||||||
"""Take pacman -Qi or pacman -Si output and get the Version"""
|
"""Take pacman -Qi or pacman -Si output and get the Version"""
|
||||||
|
@ -212,8 +209,6 @@ def upgrade(module, pacman_path):
|
||||||
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
regex = re.compile('([\w-]+) ((?:\S+)-(?:\S+)) -> ((?:\S+)-(?:\S+))')
|
regex = re.compile('([\w-]+) ((?:\S+)-(?:\S+)) -> ((?:\S+)-(?:\S+))')
|
||||||
b = []
|
|
||||||
a = []
|
|
||||||
for p in data:
|
for p in data:
|
||||||
m = regex.search(p)
|
m = regex.search(p)
|
||||||
packages.append(m.group(1))
|
packages.append(m.group(1))
|
||||||
|
@ -378,17 +373,18 @@ def expand_package_groups(module, pacman_path, pkgs):
|
||||||
expanded = []
|
expanded = []
|
||||||
|
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
cmd = "%s -Sgq %s" % (pacman_path, pkg)
|
if pkg: # avoid empty strings
|
||||||
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
cmd = "%s -Sgq %s" % (pacman_path, pkg)
|
||||||
|
rc, stdout, stderr = module.run_command(cmd, check_rc=False)
|
||||||
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
# A group was found matching the name, so expand it
|
# A group was found matching the name, so expand it
|
||||||
for name in stdout.split('\n'):
|
for name in stdout.split('\n'):
|
||||||
name = name.strip()
|
name = name.strip()
|
||||||
if name:
|
if name:
|
||||||
expanded.append(name)
|
expanded.append(name)
|
||||||
else:
|
else:
|
||||||
expanded.append(pkg)
|
expanded.append(pkg)
|
||||||
|
|
||||||
return expanded
|
return expanded
|
||||||
|
|
||||||
|
@ -432,7 +428,9 @@ def main():
|
||||||
|
|
||||||
pkg_files = []
|
pkg_files = []
|
||||||
for i, pkg in enumerate(pkgs):
|
for i, pkg in enumerate(pkgs):
|
||||||
if re.match(".*\.pkg\.tar(\.(gz|bz2|xz|lrz|lzo|Z))?$", pkg):
|
if not pkg: # avoid empty strings
|
||||||
|
continue
|
||||||
|
elif re.match(".*\.pkg\.tar(\.(gz|bz2|xz|lrz|lzo|Z))?$", pkg):
|
||||||
# The package given is a filename, extract the raw pkg name from
|
# The package given is a filename, extract the raw pkg name from
|
||||||
# it and store the filename
|
# it and store the filename
|
||||||
pkg_files.append(pkg)
|
pkg_files.append(pkg)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue