aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2020-11-19 15:53:51 +0100
committerGravatar Thomas Petazzoni <thomas.petazzoni@bootlin.com>2021-01-17 15:32:04 +0100
commit824032d16854ae3c0e6e67c534a7e8850199091a (patch)
treee0e3af36dc14b18fcd1d643c5262af90e06c351c
parent52154e52069d20105f62191e6c9f903f188a5129 (diff)
downloadbuildroot-824032d16854ae3c0e6e67c534a7e8850199091a.tar.gz
buildroot-824032d16854ae3c0e6e67c534a7e8850199091a.tar.bz2
support/scripts/pkg-stats: import cve module only when needed
The cve module needs ijson, which may not be installed. Since cve matching is only enabled when --nvd-path is passed, it is a bit silly to error out about ijson being missing if it's not used. So instead of unconditionally importing the cve module, only do it conditionally. However, instead of doing it right at the point where it is used, we do it at the beginning of the main() function. Indeed, if the cve module is needed but cannot be imported, we want to error out immediately rather than doing a whole bunch of things, and failing on the user later on in the middle of the pkg-stats execution. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Tested-by: Heiko Thiery <heiko.thiery@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
-rwxr-xr-xsupport/scripts/pkg-stats7
1 files changed, 6 insertions, 1 deletions
diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 4a9ff1ffa0..99e0ecb828 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -32,7 +32,6 @@ brpath = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
sys.path.append(os.path.join(brpath, "utils"))
from getdeveloperlib import parse_developers # noqa: E402
-import cve as cvecheck # noqa: E402
INFRA_RE = re.compile(r"\$\(eval \$\(([a-z-]*)-package\)\)")
@@ -1060,7 +1059,13 @@ def cpeid_name(pkg):
def __main__():
+ global cvecheck
+
args = parse_args()
+
+ if args.nvd_path:
+ import cve as cvecheck
+
if args.packages:
package_list = args.packages.split(",")
elif args.configpackages: