stages/systemd: add -- before unit names

Units can start with a -, for example, -.mount.  Trying to enable,
disable, or mask a service like that fails with

  systemctl: invalid option -- '.'
  Hint: to specify units starting with a dash, use "--":
        systemctl [OPTIONS...] COMMAND -- -.mount ...

Adding -- to all 'systemctl' calls lets us specify unit files that start
with -.
This commit is contained in:
Achilleas Koutsou 2024-04-22 21:35:23 +02:00
parent 106a9af937
commit 901fa24905

View file

@ -14,13 +14,13 @@ def main(tree, options):
default_target = options.get("default_target")
for service in enabled_services:
subprocess.run(["systemctl", "--root", tree, "enable", service], check=True)
subprocess.run(["systemctl", "--root", tree, "enable", "--", service], check=True)
for service in disabled_services:
subprocess.run(["systemctl", "--root", tree, "disable", service], check=True)
subprocess.run(["systemctl", "--root", tree, "disable", "--", service], check=True)
for service in masked_services:
subprocess.run(["systemctl", "--root", tree, "mask", service], check=True)
subprocess.run(["systemctl", "--root", tree, "mask", "--", service], check=True)
if masked_generators:
# systemctl can't mask generators, so manually create the mask