From patchwork Sat Feb 22 08:57:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Thiery X-Patchwork-Id: 1242463 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=SqvJPqnU; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48PjH30WFCz9sPk for ; Sat, 22 Feb 2020 20:10:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C796C87FFB; Sat, 22 Feb 2020 09:10:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZY1r3vgDiaXz; Sat, 22 Feb 2020 09:10:52 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 19BE387FFF; Sat, 22 Feb 2020 09:10:52 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 72BEA1BF5D7 for ; Sat, 22 Feb 2020 09:10:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 67EF386DF4 for ; Sat, 22 Feb 2020 09:10:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id l16kzsLCGx6s for ; Sat, 22 Feb 2020 09:10:42 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id 4116A86E33 for ; Sat, 22 Feb 2020 09:10:42 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id p9so4182584wmc.2 for ; Sat, 22 Feb 2020 01:10:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wmmnRUlunBukdg/3vXQ3I1zLIwh0v+Ow8MGNYW3HGgY=; b=SqvJPqnUNgP4iXvVap+ZbyCe+a6T08r1iQiv47qcCFDML4N2b4MZJ144JHAh0RApAZ 7y3oYegys0+UqQUBuMJQ2hZp3/IxtBnyUwT9rlz8soEme0fGz5Ib7XASWyPbyxeLd0Rs XCA1XxuaVg107FEtvXoompU1yx35tS6a5SN23u6xiWUaNyMEtZABXWyBE3lP44z8nI6q NO4trAFOg/JwHX36Rxs5t+83am/QCBIaaEBkTJkIy+ZYDeXY5N3BUQDzmdiCaDKwJZo+ tYdEdTLRm/QroUuPkas+xVE9vuItHJxeg3SNjlwWpLxGI1L+/eaAVBd36fuoEDcVJXGZ vztA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wmmnRUlunBukdg/3vXQ3I1zLIwh0v+Ow8MGNYW3HGgY=; b=Gyvv7NW33ghuZ23wESnTrgVmLW3UTj4YyVtfVSmc/O9Pcozi4tYPiqzlcjwxYvziOB EV7k5YDc6uxqmfep44IDnzG5CGOzYeyaL9K1CSUpaT2fMaQ7XPvEgkrUEqRhF0oTQXiq CP6f/t9gyuN7kzVs5IHZ1Sf/0R2lnQ3zHE0iecQ8peBaQ+oz0NDAwWRaPjvWWRh6HQAx F/4uI7TfCnvv5ONwJgKd50zHYe1guOVkM4Pish4G3GTqUZeRiJL1Ag29EvOsM/k6EooS CMVXn7YGBP7NmtK9KLr7ILf3Ic4e/dIkxkBy2dqSouQOoy9uKsUocM6BrF9cv1aTt1Fq VluQ== X-Gm-Message-State: APjAAAVrxOYeJzjMQPAiIr6Ljjkh3p4bYDSfMMbpas4sepFMem5i4VBg uodDNPd+RJCT5oKe4M3RpPdVAqni X-Google-Smtp-Source: APXvYqxH8i7Y2AqDRldXuxCSYxy1va6mnA2WdB30wLmuMAMPsI6ViJNmDiuncCVkkmuUmHYJqTREgg== X-Received: by 2002:a7b:c14e:: with SMTP id z14mr8929454wmi.58.1582362640101; Sat, 22 Feb 2020 01:10:40 -0800 (PST) Received: from t450s.fritz.box (ip5f589959.dynamic.kabel-deutschland.de. [95.88.153.89]) by smtp.gmail.com with ESMTPSA id l6sm603970wrb.75.2020.02.22.01.10.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Feb 2020 01:10:39 -0800 (PST) From: Heiko Thiery To: buildroot@buildroot.org Date: Sat, 22 Feb 2020 09:57:13 +0100 Message-Id: <20200222085715.23769-10-heiko.thiery@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200222085715.23769-1-heiko.thiery@gmail.com> References: <20200222085715.23769-1-heiko.thiery@gmail.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v3 09/12] support/scripts/pkg-stats: add support for license hash check X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Thiery , Thomas Petazzoni , Titouan Christophe Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Store the names of license files and check if they are in the hash file. Signed-off-by: Heiko Thiery Reviewed-by: Titouan Christophe Tested-by: Titouan Christophe --- support/scripts/pkg-stats | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index ae70f90485..e954dd125e 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -84,7 +84,7 @@ def get_defconfig_list(): class Package: all_licenses = dict() - all_license_files = list() + all_license_files = dict() all_versions = dict() all_ignored_cves = dict() @@ -94,6 +94,7 @@ class Package: self.pkg_path = os.path.dirname(path) self.infras = None self.license = None + self.license_files = None self.patch_count = 0 self.patch_files = [] self.warnings = 0 @@ -152,6 +153,7 @@ class Package: self.license = self.all_licenses[var] self.status['license'] = ("ok", "found") if var in self.all_license_files: + self.license_files = self.all_license_files[var].split(' ') self.status['license-files'] = ("ok", "found") def set_hash_info(self): @@ -159,8 +161,18 @@ class Package: Fills in the .status['hash'] field """ hashpath = self.path.replace(".mk", ".hash") + self.status['hash-license'] = ("na", "no hash file") if os.path.exists(hashpath): self.status['hash'] = ("ok", "found") + self.status['hash-license'] = ("error", "no license in hash file") + # check if license files are in hash file + if self.license_files is not None: + self.status['hash-license'] = ("ok", "found") + with open(hashpath) as f: + content = f.read() + for license in self.license_files: + if content.find(license) == -1: + self.status['hash-license'] = ("error", "license missing in hash file") else: self.status['hash'] = ("error", "missing") @@ -441,7 +453,7 @@ def package_init_make_info(): if pkgvar.endswith("_MANIFEST_LICENSE_FILES"): continue pkgvar = pkgvar[:-14] - Package.all_license_files.append(pkgvar) + Package.all_license_files[pkgvar] = value elif pkgvar.endswith("_VERSION"): if pkgvar.endswith("_DL_VERSION"):