with complete_step("Copying in skeleton file trees…"):
for tree in state.config.skeleton_trees:
- source, target = tree.with_prefix()
- install_tree(source, state.root, target, use_subvolumes=state.config.use_subvolumes)
+ install_tree(tree.source, state.root, tree.target, use_subvolumes=state.config.use_subvolumes)
def install_package_manager_trees(state: MkosiState) -> None:
with complete_step("Copying in package manager file trees…"):
for tree in state.config.package_manager_trees:
- source, target = tree.with_prefix()
- install_tree(source, state.workspace / "pkgmngr", target, use_subvolumes=state.config.use_subvolumes)
+ install_tree(
+ tree.source,
+ state.workspace / "pkgmngr",
+ tree.target,
+ use_subvolumes=state.config.use_subvolumes
+ )
def install_extra_trees(state: MkosiState) -> None:
with complete_step("Copying in extra file trees…"):
for tree in state.config.extra_trees:
- source, target = tree.with_prefix()
- install_tree(source, state.root, target, use_subvolumes=state.config.use_subvolumes)
+ install_tree(tree.source, state.root, tree.target, use_subvolumes=state.config.use_subvolumes)
def install_build_dest(state: MkosiState) -> None:
executable: bool = False,
expanduser: bool = True,
expandvars: bool = True,
- secret: bool = False) -> Path:
+ secret: bool = False,
+ absolute: bool = False) -> Path:
if expandvars:
value = os.path.expandvars(value)
if required and not path.exists():
die(f"{value} does not exist")
+ if absolute and not path.is_absolute():
+ die(f"{value} must be an absolute path")
+
if resolve:
path = path.resolve()
return path
-def parse_tree(value: str) -> ConfigTree:
- src, sep, tgt = value.partition(':')
+def make_tree_parser(absolute: bool = True) -> Callable[[str], ConfigTree]:
+ def parse_tree(value: str) -> ConfigTree:
+ src, sep, tgt = value.partition(':')
- return ConfigTree(
- source=parse_path(src, required=False),
- target=parse_path(tgt, required=False, resolve=False, expanduser=False) if sep else None,
- )
+ return ConfigTree(
+ source=parse_path(src, required=False),
+ target=parse_path(
+ tgt,
+ required=False,
+ resolve=False,
+ expanduser=False,
+ absolute=absolute,
+ ) if sep else None,
+ )
+
+ return parse_tree
def config_match_build_sources(match: str, value: list[ConfigTree]) -> bool:
long="--package-manager-tree",
metavar="PATH",
section="Distribution",
- parse=config_make_list_parser(delimiter=",", parse=parse_tree),
+ parse=config_make_list_parser(delimiter=",", parse=make_tree_parser()),
default_factory=lambda ns: ns.skeleton_trees,
default_factory_depends=("skeleton_trees",),
help="Use a package manager tree to configure the package manager",
long="--skeleton-tree",
metavar="PATH",
section="Content",
- parse=config_make_list_parser(delimiter=",", parse=parse_tree),
+ parse=config_make_list_parser(delimiter=",", parse=make_tree_parser()),
paths=("mkosi.skeleton", "mkosi.skeleton.tar"),
path_default=False,
help="Use a skeleton tree to bootstrap the image before installing anything",
long="--extra-tree",
metavar="PATH",
section="Content",
- parse=config_make_list_parser(delimiter=",", parse=parse_tree),
+ parse=config_make_list_parser(delimiter=",", parse=make_tree_parser()),
paths=("mkosi.extra", "mkosi.extra.tar"),
path_default=False,
help="Copy an extra tree on top of image",
dest="build_sources",
metavar="PATH",
section="Content",
- parse=config_make_list_parser(delimiter=",", parse=parse_tree),
+ parse=config_make_list_parser(delimiter=",", parse=make_tree_parser(absolute=False)),
match=config_match_build_sources,
help="Path for sources to build",
),
long="--runtime-tree",
metavar="SOURCE:[TARGET]",
section="Host",
- parse=config_make_list_parser(delimiter=",", parse=parse_tree),
+ parse=config_make_list_parser(delimiter=",", parse=make_tree_parser(absolute=False)),
help="Additional mounts to add when booting the image",
),
MkosiConfigSetting(