From fa428bb2a7566c681fffbd2893caa725ba537802 Mon Sep 17 00:00:00 2001 From: Patrick Mochel Date: Wed, 27 Nov 2019 08:19:16 -0800 Subject: [PATCH] [vigiles/kconfig] Make sure there is a kernel config file before copying In the event that we can't find a kernel config, even if VIGILES_KERNEL_CONFIG is set (even to 'auto'), we don't want to tail if it ain't there. This will happen if 'linux-dummy' is used for the 'virtual/kernel' target (i.e. if the build is set up to use a kernel from an external tree) and VIGILES_KERNEL_CONFIG is set to 'auto', since we'll attempt to check in that build directory. In order to correctly enable kernel config checking when using an external kernel tree, VIGILES_KERNEL_CONFIG must be set to the path of the .config. In addition to checking for the .config exists, this change also cleans the symlink in the vigiles/ directory (if present) to prevent us from picking it up and sending it during vigiles_check(). --- classes/vigiles.bbclass | 48 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/classes/vigiles.bbclass b/classes/vigiles.bbclass index 0429ef6..a7334f1 100644 --- a/classes/vigiles.bbclass +++ b/classes/vigiles.bbclass @@ -265,9 +265,6 @@ python do_vigiles_kconfig() { import shutil from oe import recipeutils as oe - build_dir = os.path.relpath(d.getVar('B')) - kconfig_in = os.path.join(build_dir, '.config') - vgls_pf = _get_kernel_pf(d) vgls_timestamp = d.getVar('VIGILES_TIMESTAMP') @@ -277,20 +274,37 @@ python do_vigiles_kconfig() { bb.debug(1, "Translation: %s -> %s" % (kconfig_fname, kconfig_lname)) - vigiles_kconfig = d.getVar('VIGILES_DIR_KCONFIG') + vigiles_kconfig_dir = d.getVar('VIGILES_DIR_KCONFIG') vigiles_dir = d.getVar('VIGILES_DIR') - kconfig_out = os.path.join(vigiles_kconfig, kconfig_fname) + kconfig_out = os.path.join(vigiles_kconfig_dir, kconfig_fname) kconfig_link = os.path.join(vigiles_dir, kconfig_lname) - if not os.path.exists(vigiles_kconfig): - bb.utils.mkdirhier(vigiles_kconfig) + if os.path.exists(kconfig_link): + os.remove(kconfig_link) + + kconfig_in = d.getVar('VIGILES_KERNEL_CONFIG') or '' - bb.debug(1, "Copy: %s -> %s" % (os.path.relpath(kconfig_in), os.path.relpath(kconfig_out))) + if not kconfig_in: + return + + if kconfig_in == 'auto': + build_dir = os.path.relpath(d.getVar('B')) + kconfig_in = os.path.join(build_dir, '.config') + + if not os.path.exists(kconfig_in): + bb.warn("kernel config does not exist, skipping.") + bb.warn("kconfig path: %s" % kconfig_in) + return + + if not os.path.exists(vigiles_kconfig_dir): + bb.utils.mkdirhier(vigiles_kconfig_dir) + + bb.debug(1, "Copy: %s -> %s" % + (os.path.relpath(kconfig_in), os.path.relpath(kconfig_out))) shutil.copy(kconfig_in, kconfig_out) - if os.path.exists(kconfig_link): - os.remove(kconfig_link) - bb.debug(1, "Link: %s -> %s" % (os.path.relpath(kconfig_link), os.path.relpath(kconfig_out))) + bb.debug(1, "Link: %s -> %s" % + (os.path.relpath(kconfig_link), os.path.relpath(kconfig_out))) os.symlink(os.path.relpath(kconfig_out, vigiles_dir), kconfig_link) } @@ -305,6 +319,7 @@ def vigiles_kconfig_depends(d)->str: kpref = d.getVar('PREFERRED_PROVIDER_virtual/kernel') if pn == kpref: deps = ("%s:do_configure" % pn) + return deps do_vigiles_kconfig[depends] += " ${@vigiles_kconfig_depends(d)} " @@ -319,13 +334,8 @@ python do_vigiles_check() { vigiles_in = d.getVar('VIGILES_MANIFEST_LINK') vigiles_out = d.getVar('VIGILES_REPORT') vigiles_link = d.getVar('VIGILES_REPORT_LINK') - - - vigiles_kconfig = d.getVar("VIGILES_KERNEL_CONFIG") or "" - if vigiles_kconfig == "auto": - kconfig_lname = '.'.join([_get_kernel_pf(d), 'config']) - kconfig_path = os.path.join(d.getVar('VIGILES_DIR'), kconfig_lname) - vigiles_kconfig = kconfig_path if os.path.exists(kconfig_path) else "" + vigiles_kconfig = os.path.join(d.getVar('VIGILES_DIR'), + '.'.join([_get_kernel_pf(d), 'config'])) bb.utils.export_proxies(d) @@ -334,7 +344,7 @@ python do_vigiles_check() { bb.debug(1, "Using Manifest at: %s" % os.path.relpath(vigiles_in)) bb.debug(1, "Writing Report to: %s" % os.path.relpath(vigiles_link)) - if vigiles_kconfig: + if os.path.exists(vigiles_kconfig): bb.debug(1, "Using Kernel Config: %s" % os.path.relpath(vigiles_kconfig)) args = args + ['-k', vigiles_kconfig]