arch-image-builder/builder/build/systemd.py

23 lines
701 B
Python
Raw Normal View History

import os
from logging import getLogger
from builder.lib.context import ArchBuilderContext
from builder.component import systemd as systemd_comp
log = getLogger(__name__)
def proc_systemd(ctx: ArchBuilderContext):
systemd_comp.enable(ctx, ctx.get("systemd.enable", []))
systemd_comp.disable(ctx, ctx.get("systemd.disable", []))
systemd_comp.set_default(ctx, ctx.get("systemd.default", None))
def proc_machine_id(ctx: ArchBuilderContext):
id = ctx.get("machine-id", "")
root = ctx.get_rootfs()
mid = os.path.join(root, "etc/machine-id")
with open(mid, "w") as f:
f.write(id)
f.write(os.linesep)
if len(id) == 0: log.info("removed machine-id")
else: log.info(f"set machine-id to {id}")