From: "André Draszik" <git@andred.net>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2 1/2] cve-check-tool: convert do_populate_cve_db() from python to sh
Date: Wed, 28 Sep 2016 13:05:44 +0100 [thread overview]
Message-ID: <20160928120545.28679-1-git@andred.net> (raw)
In-Reply-To: <20160926154228.30567-1-git@andred.net>
This will allow us to easily incorporate progress support
via bb.process.run()
Signed-off-by: André Draszik <git@andred.net>
---
.../cve-check-tool/cve-check-tool_5.6.4.bb | 45 +++++++++-------------
1 file 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 1165559..5bb22d1 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
EXTRA_OECONF = "--disable-coverage"
CFLAGS_append = " -Wno-error=pedantic"
-python do_populate_cve_db () {
- import subprocess
- import time
-
- if d.getVar("BB_NO_NETWORK", True) == "1":
- bb.error("BB_NO_NETWORK is set; Can't update cve-check-tool database, "
- "CVEs won't be checked")
+do_populate_cve_db() {
+ if [ "${BB_NO_NETWORK}" = "1" ] ; then
+ bberror "BB_NO_NETWORK is set; Can't update cve-check-tool database, CVEs won't be checked"
return
+ fi
- bb.utils.export_proxies(d)
# In case we don't inherit cve-check class, use default values defined in the class.
- cve_dir = d.getVar("CVE_CHECK_DB_DIR", True) or d.expand("${DL_DIR}/CVE_CHECK")
- cve_file = d.getVar("CVE_CHECK_TMP_FILE", True) or d.expand("${TMPDIR}/cve_check")
- cve_cmd = "cve-check-update"
- cmd = [cve_cmd, "-d", cve_dir]
- bb.debug(1, "Updating cve-check-tool database located in %s" % cve_dir)
- try:
- output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
- bb.debug(2, "Command '%s' returned:\n%s" % ("\n".join(cmd), output))
- time_utc = time.gmtime(time.time())
- time_format = "%Y-%m-%d %H:%M:%S"
- with open(cve_file, "w") as f:
- f.write("CVE database was updated on %s UTC\n\n"
- % time.strftime(time_format, time_utc))
-
- except subprocess.CalledProcessError as e:
- bb.warn("Error in executing cve-check-update: %s (output %s)" % (e, e.output))
- if bb.data.inherits_class('cve-check', d):
- bb.warn("Failed to update cve-check-tool database, CVEs won't be checked")
+ cve_dir="${CVE_CHECK_DB_DIR}"
+ cve_file="${CVE_CHECK_TMP_FILE}"
+
+ [ -z "${cve_dir}" ] && cve_dir="${DL_DIR}/CVE_CHECK"
+ [ -z "${cve_file}" ] && cve_file="${TMPDIR}/cve_check"
+
+ bbdebug 2 "Updating cve-check-tool database located in $cve_dir"
+ if cve-check-update -d "$cve_dir" ; then
+ printf "CVE database was updated on %s UTC\n\n" "$(LANG=C date --utc +'%F %T')" > "$cve_file"
+ else
+ bbwarn "Error in executing cve-check-update"
+ if [ "${@'1' if bb.data.inherits_class('cve-check', d) else '0'}" -ne 0 ] ; then
+ bbwarn "Failed to update cve-check-tool database, CVEs won't be checked"
+ fi
+ fi
}
addtask populate_cve_db after do_populate_sysroot
--
2.9.3
next prev parent reply other threads:[~2016-09-28 12:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-26 15:42 [PATCH 0/2] cve-check-tool progress reporting André Draszik
2016-09-26 15:42 ` [PATCH 1/2] cve-check-tool: convert do_populate_cve_db() from python to sh André Draszik
2016-09-26 15:42 ` [PATCH 2/2] cve-check-tool: report progress when downloading CVE database André Draszik
2016-09-28 10:54 ` Burton, Ross
2016-09-28 11:56 ` André Draszik
2016-09-28 11:57 ` Burton, Ross
2016-09-28 12:05 ` André Draszik [this message]
2016-09-28 12:05 ` [PATCH v2 " André Draszik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160928120545.28679-1-git@andred.net \
--to=git@andred.net \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.