summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/cve-check-tool
diff options
context:
space:
mode:
authorAndré Draszik <git@andred.net>2016-09-28 13:05:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-30 16:51:15 +0100
commit0466c81f91dc5ed425c2971b9ed882ab31b8d461 (patch)
treec5abe6d7a24d37bff2df13204670b202825445f2 /meta/recipes-devtools/cve-check-tool
parent5d8a968ecdf40babe452b0ac63d94a7a163710ae (diff)
downloadpoky-0466c81f91dc5ed425c2971b9ed882ab31b8d461.tar.gz
cve-check-tool: convert do_populate_cve_db() from python to sh
This will allow us to easily incorporate progress support via bb.process.run() (From OE-Core rev: 1bf0137ac84e5d324fd84dadfa962fbc166b5d4b) Signed-off-by: André Draszik <git@andred.net> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/cve-check-tool')
-rw-r--r--meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb45
1 files changed, 19 insertions, 26 deletions
diff --git a/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb b/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
index 116555962c..5bb22d16db 100644
--- a/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
+++ b/meta/recipes-devtools/cve-check-tool/cve-check-tool_5.6.4.bb
@@ -22,35 +22,28 @@ inherit pkgconfig autotools
22EXTRA_OECONF = "--disable-coverage" 22EXTRA_OECONF = "--disable-coverage"
23CFLAGS_append = " -Wno-error=pedantic" 23CFLAGS_append = " -Wno-error=pedantic"
24 24
25python do_populate_cve_db () { 25do_populate_cve_db() {
26 import subprocess 26 if [ "${BB_NO_NETWORK}" = "1" ] ; then
27 import time 27 bberror "BB_NO_NETWORK is set; Can't update cve-check-tool database, CVEs won't be checked"
28
29 if d.getVar("BB_NO_NETWORK", True) == "1":
30 bb.error("BB_NO_NETWORK is set; Can't update cve-check-tool database, "
31 "CVEs won't be checked")
32 return 28 return
29 fi
33 30
34 bb.utils.export_proxies(d)
35 # In case we don't inherit cve-check class, use default values defined in the class. 31 # In case we don't inherit cve-check class, use default values defined in the class.
36 cve_dir = d.getVar("CVE_CHECK_DB_DIR", True) or d.expand("${DL_DIR}/CVE_CHECK") 32 cve_dir="${CVE_CHECK_DB_DIR}"
37 cve_file = d.getVar("CVE_CHECK_TMP_FILE", True) or d.expand("${TMPDIR}/cve_check") 33 cve_file="${CVE_CHECK_TMP_FILE}"
38 cve_cmd = "cve-check-update" 34
39 cmd = [cve_cmd, "-d", cve_dir] 35 [ -z "${cve_dir}" ] && cve_dir="${DL_DIR}/CVE_CHECK"
40 bb.debug(1, "Updating cve-check-tool database located in %s" % cve_dir) 36 [ -z "${cve_file}" ] && cve_file="${TMPDIR}/cve_check"
41 try: 37
42 output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) 38 bbdebug 2 "Updating cve-check-tool database located in $cve_dir"
43 bb.debug(2, "Command '%s' returned:\n%s" % ("\n".join(cmd), output)) 39 if cve-check-update -d "$cve_dir" ; then
44 time_utc = time.gmtime(time.time()) 40 printf "CVE database was updated on %s UTC\n\n" "$(LANG=C date --utc +'%F %T')" > "$cve_file"
45 time_format = "%Y-%m-%d %H:%M:%S" 41 else
46 with open(cve_file, "w") as f: 42 bbwarn "Error in executing cve-check-update"
47 f.write("CVE database was updated on %s UTC\n\n" 43 if [ "${@'1' if bb.data.inherits_class('cve-check', d) else '0'}" -ne 0 ] ; then
48 % time.strftime(time_format, time_utc)) 44 bbwarn "Failed to update cve-check-tool database, CVEs won't be checked"
49 45 fi
50 except subprocess.CalledProcessError as e: 46 fi
51 bb.warn("Error in executing cve-check-update: %s (output %s)" % (e, e.output))
52 if bb.data.inherits_class('cve-check', d):
53 bb.warn("Failed to update cve-check-tool database, CVEs won't be checked")
54} 47}
55 48
56addtask populate_cve_db after do_populate_sysroot 49addtask populate_cve_db after do_populate_sysroot