From f1cbcb7b3b00c548a3324e18ae263883b51a91a4 Mon Sep 17 00:00:00 2001 From: Minecrell Date: Sat, 28 May 2022 13:53:51 +0200 Subject: [PATCH] pmb: flasher: frontend: don't fail if kernel config cannot be found (MR 2184) When using a kernel from Alpine the kernel configuration cannot be found in pmaports. We cannot check the kernel config for missing options in that case, but that's no reason to break the flasher entirely. --- pmb/flasher/frontend.py | 2 +- pmb/parse/kconfig.py | 8 ++++++-- test/test_kconfig_check.py | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pmb/flasher/frontend.py b/pmb/flasher/frontend.py index 14f0c7fe..a76b424f 100644 --- a/pmb/flasher/frontend.py +++ b/pmb/flasher/frontend.py @@ -20,7 +20,7 @@ def kernel(args): pmb.chroot.initfs.build(args, flavor, "rootfs_" + args.device) # Check kernel config - pmb.parse.kconfig.check(args, flavor) + pmb.parse.kconfig.check(args, flavor, must_exist=False) # Generate the paths and run the flasher if args.action_flasher == "boot": diff --git a/pmb/parse/kconfig.py b/pmb/parse/kconfig.py index c649cdc1..ee7eaef4 100644 --- a/pmb/parse/kconfig.py +++ b/pmb/parse/kconfig.py @@ -167,11 +167,13 @@ def check(args, pkgname, force_zram_check=False, force_netboot_check=False, force_uefi_check=False, - details=False): + details=False, + must_exist=True): """ Check for necessary kernel config options in a package. :returns: True when the check was successful, False otherwise + None if the aport cannot be found (only if must_exist=False) """ # Pkgname: allow omitting "linux-" prefix if pkgname.startswith("linux-"): @@ -181,7 +183,9 @@ def check(args, pkgname, # Read all kernel configs in the aport ret = True - aport = pmb.helpers.pmaports.find(args, "linux-" + flavor) + aport = pmb.helpers.pmaports.find(args, "linux-" + flavor, must_exist=must_exist) + if aport is None: + return None apkbuild = pmb.parse.apkbuild(f"{aport}/APKBUILD") pkgver = apkbuild["pkgver"] check_anbox = force_anbox_check or ( diff --git a/test/test_kconfig_check.py b/test/test_kconfig_check.py index 116c9768..da8ebd51 100644 --- a/test/test_kconfig_check.py +++ b/test/test_kconfig_check.py @@ -21,6 +21,10 @@ def args(tmpdir, request): def test_kconfig_check(args): + # non-existing package + assert pmb.parse.kconfig.check(args, "non-existing-kernel-package", + must_exist=False) is None + # basic checks, from easiers to hard-ish dir = f"{pmb_test.const.testdata}/kconfig_check/" assert not pmb.parse.kconfig.check_file(dir +