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:
Ondřej Budai 2020-03-25 13:58:39 +01:00 committed by Tom Gundersen
parent 9b3375ccca
commit a040369513

View file

@ -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