From 21de5cc43cfedc703e5bc0515507a6dae36afb74 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Fri, 24 Aug 2018 10:59:50 -0400 Subject: classes/kernel-yocto: Cleanup getstatusoutput usage Replace usage of os.utils.getstatusoutput() with direct subprocess calls. Pass a modified environment and working directory where necessary to bypass the need to execute in a shell. Signed-off-by: Joshua Watt Signed-off-by: Bruce Ashfield Signed-off-by: Richard Purdie --- meta/classes/kernel-yocto.bbclass | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'meta/classes/kernel-yocto.bbclass') diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index 077a1ab8ef..19d74a7875 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass @@ -321,7 +321,7 @@ do_kernel_configme() { addtask kernel_configme before do_configure after do_patch python do_kernel_configcheck() { - import re, string, sys + import re, string, sys, subprocess # if KMETA isn't set globally by a recipe using this routine, we need to # set the default to 'meta'. Otherwise, kconf_check is not passed a valid @@ -330,16 +330,26 @@ python do_kernel_configcheck() { if not os.path.exists(kmeta): kmeta = "." + kmeta - pathprefix = "export PATH=%s:%s; " % (d.getVar('PATH'), "${S}/scripts/util/") + s = d.getVar('S') - cmd = d.expand("scc --configs -o ${S}/.kernel-meta") - ret, configs = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + env = os.environ.copy() + env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/") - cmd = d.expand("cd ${S}; kconf_check --report -o ${S}/%s/cfg/ ${B}/.config ${S} %s" % (kmeta,configs)) - ret, result = oe.utils.getstatusoutput("%s%s" % (pathprefix, cmd)) + try: + configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8') + except subprocess.CalledProcessError: + bb.fatal( "Cannot gather config fragments for audit: %s" % configs) + + try: + subprocess.check_call(['kconf_check', '--report', '-o', + '%s/%s/cfg' % (s, kmeta), d.getVar('B') + '/.config', s, configs], cwd=s, env=env) + except subprocess.CalledProcessError: + # The configuration gathering can return different exit codes, but + # we interpret them based on the KCONF_AUDIT_LEVEL variable, so we catch + # everything here, and let the run continue. + pass config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0) - bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0) # if config check visibility is non-zero, report dropped configuration values mismatch_file = d.expand("${S}/%s/cfg/mismatch.txt" % kmeta) -- cgit 1.2.3-korg