From: Daan De Meyer Date: Wed, 10 Apr 2024 18:46:39 +0000 (+0200) Subject: Make sure we don't chdir() again when parsing arguments again X-Git-Tag: v23~10^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4e18509a6b540e1ebbe27768942a7cc588595c5;p=thirdparty%2Fmkosi.git Make sure we don't chdir() again when parsing arguments again When we parse arguments again for --append, let's make sure we don't chdir() again as this breaks when using relative paths for --directory --- diff --git a/mkosi/config.py b/mkosi/config.py index 0f13b0059..5bbf16aea 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -2997,7 +2997,7 @@ SPECIFIERS_LOOKUP_BY_CHAR = {s.char: s for s in SPECIFIERS} FALLBACK_NAME_TO_DEST_SPLITTER = re.compile("(?<=[a-z])(?=[A-Z])") -def create_argument_parser(action: type[argparse.Action]) -> argparse.ArgumentParser: +def create_argument_parser(action: type[argparse.Action], chdir: bool = True) -> argparse.ArgumentParser: parser = argparse.ArgumentParser( prog="mkosi", description="Build Bespoke OS Images", @@ -3042,7 +3042,7 @@ def create_argument_parser(action: type[argparse.Action]) -> argparse.ArgumentPa ) parser.add_argument( "-C", "--directory", - type=parse_chdir, + type=parse_chdir if chdir else str, default=Path.cwd(), help="Change to specified directory before doing anything", metavar="PATH", @@ -3567,7 +3567,7 @@ def parse_config(argv: Sequence[str] = (), *, resources: Path = Path("/")) -> tu append = True for ns in images: - argparser.parse_args(argv, ns) + create_argument_parser(ConfigAction, chdir=False).parse_args(argv, ns) for s in vars(cli_ns): if s not in SETTINGS_LOOKUP_BY_DEST: