nspawn_version,
patch_file,
path_relative_to_cwd,
+ root_home,
run,
run_workspace_command,
set_umask,
btrfs_subvol_create(root)
-def root_home(args: MkosiArgs, root: Path) -> Path:
-
- # If UsrOnly= is turned on the /root/ directory (i.e. the root
- # user's home directory) is not persistent (after all everything
- # outside of /usr/ is not around). In that case let's mount it in
- # from an external place, so that we can have persistency. It is
- # after all where we place our build sources and suchlike.
-
- if args.usr_only:
- return workspace(root) / "home-root"
-
- return root / "root"
-
-
def prepare_tree(args: MkosiArgs, root: Path, do_run_build_script: bool, cached: bool) -> None:
if cached:
# Reuse machine-id from cached image.
stdout = subprocess.PIPE
nspawn += ["--console=pipe"]
+ if args.usr_only:
+ nspawn += [f"--bind={root_home(args, root)}:/root"]
+
if args.nspawn_keep_unit:
nspawn += ["--keep-unit"]
die(f"Workspace command {shell_join(cmd)} returned non-zero exit code {e.returncode}.")
+def root_home(args: MkosiArgs, root: Path) -> Path:
+
+ # If UsrOnly= is turned on the /root/ directory (i.e. the root
+ # user's home directory) is not persistent (after all everything
+ # outside of /usr/ is not around). In that case let's mount it in
+ # from an external place, so that we can have persistency. It is
+ # after all where we place our build sources and suchlike.
+
+ if args.usr_only:
+ return workspace(root) / "home-root"
+
+ return root / "root"
+
+
@contextlib.contextmanager
def do_delay_interrupt() -> Iterator[None]:
# CTRL+C is sent to the entire process group. We delay its handling in mkosi itself so the subprocess can