tools/image-info: deduplicate and sort the services
systemctl list-unit-files doesn't produce machine readable output. parse_unit_files isn't very good at reading it and can produce duplicate records. This commit fixes it by deduplicating and sorting the units. This is a bit hacky solution, but should work just alright. In the future we might dump list-unit-files and do the job ourself, but let's not recreate the systemd logic for now.
This commit is contained in:
parent
9b3375ccca
commit
a040369513
1 changed files with 4 additions and 0 deletions
|
|
@ -67,6 +67,10 @@ def parse_unit_files(s, expected_state):
|
|||
if state != expected_state:
|
||||
continue
|
||||
r.append(unit)
|
||||
|
||||
# deduplicate and sort
|
||||
r = list(set(r))
|
||||
r.sort()
|
||||
return r
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue