2024-05-17 23:04:34 +08:00
|
|
|
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):
|
2024-05-20 09:56:42 +08:00
|
|
|
"""
|
|
|
|
Enable or disable systemd units files, and set default target
|
|
|
|
"""
|
2024-05-17 23:04:34 +08:00
|
|
|
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):
|
2024-05-20 09:56:42 +08:00
|
|
|
"""
|
|
|
|
Remove or set machine-id
|
|
|
|
Never duplicate machine id, it should generate when first boot
|
|
|
|
"""
|
2024-05-17 23:04:34 +08:00
|
|
|
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}")
|