mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00

Replace full license headers with SPDX identifiers and adjust all patchtest-related code to use GPL-2.0-only. (From OE-Core rev: 9bea6b39074296bb8d8719a3300636e316f19d1b) Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
81 lines
3.3 KiB
Python
81 lines
3.3 KiB
Python
# Checks related to the patch's LIC_FILES_CHKSUM metadata variable
|
|
#
|
|
# Copyright (C) 2016 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
import base
|
|
import pyparsing
|
|
from data import PatchTestInput, PatchTestDataStore
|
|
|
|
class LicFilesChkSum(base.Metadata):
|
|
metadata = 'LIC_FILES_CHKSUM'
|
|
license = 'LICENSE'
|
|
closed = 'CLOSED'
|
|
lictag = 'License-Update'
|
|
lictag_re = pyparsing.Regex("^%s:" % lictag)
|
|
|
|
def setUp(self):
|
|
# these tests just make sense on patches that can be merged
|
|
if not PatchTestInput.repo.canbemerged:
|
|
self.skip('Patch cannot be merged')
|
|
|
|
def test_lic_files_chksum_presence(self):
|
|
if not self.added:
|
|
self.skip('No added recipes, skipping test')
|
|
|
|
for pn in self.added:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
lic_files_chksum = rd.getVar(self.metadata)
|
|
if rd.getVar(self.license) == self.closed:
|
|
continue
|
|
if not lic_files_chksum:
|
|
self.fail('%s is missing in newly added recipe' % self.metadata)
|
|
|
|
def pretest_lic_files_chksum_modified_not_mentioned(self):
|
|
if not self.modified:
|
|
self.skip('No modified recipes, skipping pretest')
|
|
# get the proper metadata values
|
|
for pn in self.modified:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata,pn)] = rd.getVar(self.metadata)
|
|
|
|
def test_lic_files_chksum_modified_not_mentioned(self):
|
|
if not self.modified:
|
|
self.skip('No modified recipes, skipping test')
|
|
|
|
# get the proper metadata values
|
|
for pn in self.modified:
|
|
rd = self.tinfoil.parse_recipe(pn)
|
|
pathname = rd.getVar('FILE')
|
|
# we are not interested in images
|
|
if '/images/' in pathname:
|
|
continue
|
|
PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata,pn)] = rd.getVar(self.metadata)
|
|
# compare if there were changes between pre-merge and merge
|
|
for pn in self.modified:
|
|
pretest = PatchTestDataStore['pre%s-%s-%s' % (self.shortid(),self.metadata, pn)]
|
|
test = PatchTestDataStore['%s-%s-%s' % (self.shortid(),self.metadata, pn)]
|
|
|
|
# TODO: this is workaround to avoid false-positives when pretest metadata is empty (not reason found yet)
|
|
# For more info, check bug 12284
|
|
if not pretest:
|
|
return
|
|
|
|
if pretest != test:
|
|
# if any patch on the series contain reference on the metadata, fail
|
|
for commit in self.commits:
|
|
if self.lictag_re.search_string(commit.commit_message):
|
|
break
|
|
else:
|
|
self.fail('LIC_FILES_CHKSUM changed on target %s but there is no "%s" tag in commit message. Include it with a brief description' % (pn, self.lictag),
|
|
data=[('Current checksum', pretest), ('New checksum', test)])
|