only supported on images that contain a boot loader, i.e. those
built with `Bootable=yes` (see below). This command must be executed
as `root` unless the image already exists and `-f` is not specified.
+ Some qemu arguments (such as those set by `Netdev=yes`) may also
+ prevent qemu from starting when this command is executed by a
+ non-root user.
`ssh`
PathString = Union[Path, str]
MKOSI_COMMANDS_NEED_BUILD = (Verb.shell, Verb.boot, Verb.qemu, Verb.serve)
-MKOSI_COMMANDS_SUDO = (Verb.build, Verb.clean, Verb.shell, Verb.boot, Verb.qemu, Verb.serve)
+MKOSI_COMMANDS_SUDO = (Verb.build, Verb.clean, Verb.shell, Verb.boot, Verb.serve)
MKOSI_COMMANDS_CMDLINE = (Verb.build, Verb.shell, Verb.boot, Verb.qemu, Verb.ssh)
DRACUT_SYSTEMD_EXTRAS = [
def unlink_output(args: MkosiArgs) -> None:
- if not args.force and args.verb != Verb.clean:
- return
-
if not args.skip_final_phase:
with complete_step("Removing output files…"):
unlink_try_hard(args.output)
if args.verb in MKOSI_COMMANDS_SUDO:
check_root()
- unlink_output(args)
- if args.verb == Verb.build:
+ if args.verb == Verb.build and not args.force:
check_output(args)
+ if needs_build(args) or args.verb == Verb.clean:
+ check_root()
+ unlink_output(args)
+
if args.verb == Verb.summary:
print_summary(args)
if needs_build(args):
- check_root()
check_native(args)
init_namespace(args)
manifest = build_stuff(args)
import pexpect # type: ignore
from . import (
- MKOSI_COMMANDS_SUDO,
+ MKOSI_COMMANDS_NEED_BUILD,
CompletedProcess,
build_stuff,
check_native,
assert self._serial is not None or self.args.verb == Verb.shell
def build(self) -> None:
- if self.args.verb in MKOSI_COMMANDS_SUDO:
+ if self.args.verb in MKOSI_COMMANDS_NEED_BUILD + (Verb.build, Verb.clean):
check_root()
unlink_output(self.args)