arch-image-builder/builder/build/systemd.py
BigfootACA e6c6ab6bf7 Initial commit
Signed-off-by: BigfootACA <bigfoot@classfun.cn>
2024-05-17 23:04:34 +08:00

23 lines
701 B
Python

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}")