Skip to content

Commit

Permalink
[vigiles/kconfig] Make sure there is a kernel config file before copying
Browse files Browse the repository at this point in the history
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().
  • Loading branch information
mochel-timesys committed Dec 3, 2019
1 parent 9d092e9 commit fa428bb
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions classes/vigiles.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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)
}

Expand All @@ -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)} "
Expand All @@ -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)

Expand All @@ -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]

Expand Down

0 comments on commit fa428bb

Please sign in to comment.