format_tree,
parse_config,
summary,
+ systemd_tool_version,
want_selinux_relabel,
yes_no,
)
die(f"Output path {f} exists already. (Consider invocation with --force.)")
-def systemd_tool_version(config: Config, tool: PathString) -> GenericVersion:
- return GenericVersion(
- run([tool, "--version"], stdout=subprocess.PIPE, sandbox=config.sandbox()).stdout.split()[2].strip("()")
- )
-
-
def check_tool(config: Config, *tools: PathString, reason: str, hint: Optional[str] = None) -> Path:
tool = find_binary(*tools, root=config.tools())
if not tool:
binpolicy = sorted(policies, key=lambda p: GenericVersion(p.name), reverse=True)[0]
return policy, fc, binpolicy
+
+
+def systemd_tool_version(config: Config, tool: PathString) -> GenericVersion:
+ return GenericVersion(
+ run([tool, "--version"], stdout=subprocess.PIPE, sandbox=config.sandbox()).stdout.split()[2].strip("()")
+ )
QemuFirmware,
QemuVsockCID,
format_bytes,
+ systemd_tool_version,
want_selinux_relabel,
)
from mkosi.log import die
@classmethod
def identify(cls, config: Config, path: Path) -> "KernelType":
- type = run(["bootctl", "kernel-identify", path],
- stdout=subprocess.PIPE, sandbox=config.sandbox(options=["--ro-bind", path, path])).stdout.strip()
+ if systemd_tool_version(config, "bootctl") < 253:
+ logging.warning("bootctl doesn't know kernel-identify verb, assuming 'unknown' kernel type")
+ return KernelType.unknown
+
+ type = run(
+ ["bootctl", "kernel-identify", path],
+ stdout=subprocess.PIPE,
+ sandbox=config.sandbox(options=["--ro-bind", path, path]),
+ ).stdout.strip()
try:
return cls(type)