Skip to content

Commit

Permalink
minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
russoz committed Jun 17, 2023
1 parent 414ab18 commit dea5986
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/modules/pacman.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ def _build_inventory(self):
installed_pkgs = {}
dummy, stdout, dummy = self.m.run_command([self.pacman_path, "--query"], check_rc=True)
# Format of a line: "pacman 6.0.1-2"
query_re = re.compile(r'^(?P<pkg>\S+)\s+(?P<ver>\S+)\s*$')
query_re = re.compile(r'^\s*(?P<pkg>\S+)\s+(?P<ver>\S+)\s*$')
for l in stdout.splitlines():
query_match = query_re.match(l)
if not query_match:
Expand All @@ -723,7 +723,7 @@ def _build_inventory(self):
# base-devel file
# base-devel findutils
# ...
query_groups_re = re.compile(r'^(?P<group>\S+)\s+(?P<pkg>\S+)\s*$')
query_groups_re = re.compile(r'^\s*(?P<group>\S+)\s+(?P<pkg>\S+)\s*$')
for l in stdout.splitlines():
query_groups_match = query_groups_re.match(l)
if not query_groups_match:
Expand All @@ -750,7 +750,7 @@ def _build_inventory(self):
# vim-plugins vim-airline-themes
# vim-plugins vim-ale
# ...
sync_groups_re = re.compile(r'^(?P<group>\S+)\s+(?P<pkg>\S+)\s*$')
sync_groups_re = re.compile(r'^\s*(?P<group>\S+)\s+(?P<pkg>\S+)\s*$')
for l in stdout.splitlines():
sync_groups_match = sync_groups_re.match(l)
if not sync_groups_match:
Expand All @@ -766,6 +766,7 @@ def _build_inventory(self):
stdout = stdout.splitlines()
if stdout and "Avoid running" in stdout[0]:
stdout = stdout[1:]
stdout = "\n".join(stdout)

# non-zero exit with nothing in stdout -> nothing to upgrade, all good
# stderr can have warnings, so not checked here
Expand All @@ -775,7 +776,7 @@ def _build_inventory(self):
# Format of lines:
# strace 5.14-1 -> 5.15-1
# systemd 249.7-1 -> 249.7-2 [ignored]
for l in stdout:
for l in stdout.splitlines():
l = l.strip()
if not l:
continue
Expand Down

0 comments on commit dea5986

Please sign in to comment.