From 60217d08181660b8d89990318dfd0ca40929e60f Mon Sep 17 00:00:00 2001 From: Minecrell Date: Wed, 22 Jan 2020 19:30:43 +0100 Subject: [PATCH] pmb.flasher/export: Add --no-install option to skip kernel/initfs update (!1863) At the moment, pmbootstrap updates the kernel and the initfs whenever using the flasher or export. This is useful, but sometimes you just want to boot exactly the same kernel several times. In that case, having to wait several seconds for the (redundant) update to complete is quite annoying. Add a --no-install option that allows skipping the kernel/initfs update. --- pmb/export/frontend.py | 5 +++-- pmb/flasher/frontend.py | 5 +++-- pmb/helpers/frontend.py | 5 +++-- pmb/parse/arguments.py | 4 ++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pmb/export/frontend.py b/pmb/export/frontend.py index dc329129..f6771702 100644 --- a/pmb/export/frontend.py +++ b/pmb/export/frontend.py @@ -22,8 +22,9 @@ def frontend(args): " install' first (without the 'sdcard' parameter).") # Rebuild the initramfs, just to make sure (see #69) - flavor = pmb.helpers.frontend._parse_flavor(args) - pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device) + flavor = pmb.helpers.frontend._parse_flavor(args, args.autoinstall) + if args.autoinstall: + pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device) # Do the export, print all files logging.info("Export symlinks to: " + target) diff --git a/pmb/flasher/frontend.py b/pmb/flasher/frontend.py index 71e2452c..0d20c722 100644 --- a/pmb/flasher/frontend.py +++ b/pmb/flasher/frontend.py @@ -31,8 +31,9 @@ import pmb.parse.kconfig def kernel(args): # Rebuild the initramfs, just to make sure (see #69) - flavor = pmb.helpers.frontend._parse_flavor(args) - pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device) + flavor = pmb.helpers.frontend._parse_flavor(args, args.autoinstall) + if args.autoinstall: + pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device) # Check kernel config pmb.parse.kconfig.check(args, flavor) diff --git a/pmb/helpers/frontend.py b/pmb/helpers/frontend.py index bfdcbbee..7812fac3 100644 --- a/pmb/helpers/frontend.py +++ b/pmb/helpers/frontend.py @@ -46,13 +46,14 @@ import pmb.parse import pmb.qemu -def _parse_flavor(args): +def _parse_flavor(args, autoinstall=True): """ Verify the flavor argument if specified, or return a default value. + :param autoinstall: make sure that at least one kernel flavor is installed """ # Install at least one kernel and get installed flavors suffix = "rootfs_" + args.device - flavors = pmb.chroot.other.kernel_flavors_installed(args, suffix) + flavors = pmb.chroot.other.kernel_flavors_installed(args, suffix, autoinstall) # Parse and verify the flavor argument flavor = args.flavor diff --git a/pmb/parse/arguments.py b/pmb/parse/arguments.py index 72d261af..93e292d2 100644 --- a/pmb/parse/arguments.py +++ b/pmb/parse/arguments.py @@ -50,6 +50,8 @@ def arguments_export(subparser): " (boot.img/kernel+initramfs only)", action="store_true", dest="odin_flashable_tar") ret.add_argument("--flavor", default=None) + ret.add_argument("--no-install", dest="autoinstall", default=True, + help="skip updating kernel/initfs", action="store_false") return ret @@ -67,6 +69,8 @@ def arguments_flasher(subparser): flash_kernel = sub.add_parser("flash_kernel", help="flash a kernel") for action in [boot, flash_kernel]: action.add_argument("--flavor", default=None) + action.add_argument("--no-install", dest="autoinstall", default=True, + help="skip updating kernel/initfs", action="store_false") flash_kernel.add_argument("--partition", default=None, help="partition to flash the kernel to (defaults" " to deviceinfo_flash_*_partition_kernel)")