From: Lennart Poettering Date: Sat, 15 Dec 2018 09:44:55 +0000 (+0100) Subject: mkosi: add "-a" switch for building everything in mkosi.files/ X-Git-Tag: v5~16^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F309%2Fhead;p=thirdparty%2Fmkosi.git mkosi: add "-a" switch for building everything in mkosi.files/ Let's add a one-stop solution for building a set of files all in one go. For that, simply place "mkosi.default"-style files in mkosi.files/ and use "mkosi -a" to build them all. Fixes: #176 --- diff --git a/ci/semaphore.sh b/ci/semaphore.sh index dff783124..759b908dd 100755 --- a/ci/semaphore.sh +++ b/ci/semaphore.sh @@ -8,4 +8,4 @@ sudo apt --yes install python3.6 debootstrap systemd-container squashfs-tools sudo python3.6 ./mkosi --default ./mkosi.files/mkosi.ubuntu -test -f image.raw +test -f ubuntu.raw diff --git a/mkosi b/mkosi index a8e8c3e73..a2392651a 100755 --- a/mkosi +++ b/mkosi @@ -6,6 +6,7 @@ import argparse import collections import configparser import contextlib +import copy import crypt import ctypes import ctypes.util @@ -3053,6 +3054,8 @@ def parse_args() -> CommandLineArguments: group = parser.add_argument_group("Additional Configuration") group.add_argument('-C', "--directory", help='Change to specified directory before doing anything', metavar='PATH') group.add_argument("--default", dest='default_path', help='Read configuration data from file', metavar='PATH') + group.add_argument('-a', "--all", action='store_true', dest='all', default=False, help='Build all settings files in mkosi.files/') + group.add_argument("--all-directory", dest='all_directory', help='Specify path to directory to read settings files from', metavar='PATH') group.add_argument("--kernel-commandline", help='Set the kernel command line (only bootable images)') group.add_argument("--hostname", help="Set hostname") @@ -3074,6 +3077,11 @@ def parse_args() -> CommandLineArguments: parser.print_help() sys.exit(0) + if args.all and args.default_path: + die("--all and --default= may not be combined.") + + args_find_path(args, 'all_directory', "mkosi.files/") + return args @@ -3615,12 +3623,7 @@ def build_root_hash_file_path(path: str) -> str: return strip_suffixes(path) + ".roothash" -def load_args() -> CommandLineArguments: - args = parse_args() - - if args.directory is not None: - os.chdir(args.directory) - +def load_args(args) -> CommandLineArguments: global arg_debug arg_debug = args.debug @@ -4416,8 +4419,8 @@ def prepend_to_environ_path(paths: List[str]) -> None: os.environ["PATH"] = new_path + ":" + original_path -def main() -> None: - args = load_args() +def run_verb(args): + load_args(args) if args.verb in ("build", "clean", "shell", "boot", "qemu"): check_root() @@ -4431,8 +4434,6 @@ def main() -> None: if args.verb == "summary" or needs_build: print_summary(args) - prepend_to_environ_path(args.extra_search_paths) - if needs_build: check_root() check_native(args) @@ -4447,5 +4448,28 @@ def main() -> None: run_qemu(args) +def main() -> None: + args = parse_args() + + if args.directory is not None: + os.chdir(args.directory) + + prepend_to_environ_path(args.extra_search_paths) + + if args.all: + for f in os.scandir(args.all_directory): + + if not f.name.startswith("mkosi."): + continue + + a = copy.deepcopy(args) + a.default_path = f.path + + with complete_step('Processing ' + f.path): + run_verb(a) + else: + run_verb(args) + + if __name__ == "__main__": main() diff --git a/mkosi.files/mkosi.fedora b/mkosi.files/mkosi.fedora index d04d0e9ad..6bc292f7c 100644 --- a/mkosi.files/mkosi.fedora +++ b/mkosi.files/mkosi.fedora @@ -6,8 +6,9 @@ Distribution=fedora Release=29 [Output] -Format=raw_squashfs +Format=gpt_ext4 Bootable=yes +Output=fedora.raw [Packages] Packages= diff --git a/mkosi.files/mkosi.ubuntu b/mkosi.files/mkosi.ubuntu index 5706da46a..98f33f915 100644 --- a/mkosi.files/mkosi.ubuntu +++ b/mkosi.files/mkosi.ubuntu @@ -5,7 +5,8 @@ Distribution=ubuntu Release=xenial [Output] -Format=raw_squashfs +Format=gpt_ext4 +Output=ubuntu.raw [Packages] Packages=