From: Zbigniew Jędrzejewski-Szmek Date: Sat, 8 Oct 2016 19:15:33 +0000 (-0400) Subject: Fix argument parsing for --boolean and --use-git-files X-Git-Tag: v1~11^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F29%2Fhead;p=thirdparty%2Fmkosi.git Fix argument parsing for --boolean and --use-git-files bool('0') evaluates to True, so type=bool does not work as expected. It is necessary to use a helper function which converts strings to True/False as expected. Also, fix parse_boolean(). --- diff --git a/mkosi b/mkosi index afbbbdb46..75ac1852d 100755 --- a/mkosi +++ b/mkosi @@ -1003,7 +1003,8 @@ def parse_args(): group.add_argument('-t', "--format", dest='output_format', choices=OutputFormat.__members__, help='Output Format') group.add_argument('-o', "--output", help='Output image path', metavar='PATH') group.add_argument('-f', "--force", action='store_true', help='Remove existing image file before operation') - group.add_argument('-b', "--bootable", action='store_true', help='Make image bootable on EFI (only raw_gpt, raw_btrfs)') + group.add_argument('-b', "--bootable", type=parse_boolean, nargs='?', const=True, + help='Make image bootable on EFI (only raw_gpt, raw_btrfs)') group.add_argument("--read-only", action='store_true', help='Make root volume read-only (only raw_btrfs, subvolume)') group.add_argument("--compress", action='store_true', help='Enable compression in file system (only raw_btrfs, subvolume)') group.add_argument("--xz", action='store_true', help='Compress resulting image with xz (only raw_gpt, raw_btrfs, implied on tar)') @@ -1016,7 +1017,7 @@ def parse_args(): group.add_argument("--build-script", help='Build script to run inside image', metavar='PATH') group.add_argument("--build-sources", help='Path for sources to build', metavar='PATH') group.add_argument("--build-package", action=PackageAction, dest='build_packages', help='Additional packages needed for build script', metavar='PACKAGE') - group.add_argument('--use-git-files', type=bool, + group.add_argument('--use-git-files', type=parse_boolean, help='Ignore any files that git itself ignores (default: guess)') group.add_argument("--settings", dest='nspawn_settings', help='Add in .spawn settings file', metavar='PATH') @@ -1130,7 +1131,7 @@ def parse_boolean(s): if s in {"0", "false", "no"}: return False - return KeyError("Unknown setting") + raise ValueError("invalid literal for bool(): {!r}".format(s)) def process_setting(args, section, key, value): if section == "Distribution":