From: "Zhang, Shenglei" <shenglei.zhang@intel.com>
To: "Kinney, Michael D" <michael.d.kinney@intel.com>,
"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: Sean Brogan <sean.brogan@microsoft.com>,
Bret Barkelew <Bret.Barkelew@microsoft.com>,
"Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH 01/15] .pytool/Plugin: Add a plugin LicenseCheck
Date: Wed, 29 Jul 2020 06:06:31 +0000 [thread overview]
Message-ID: <BL0PR11MB3506A0ED03C281ABA7178F808C700@BL0PR11MB3506.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MN2PR11MB446112F62173314B7000DD34D2730@MN2PR11MB4461.namprd11.prod.outlook.com>
Five sorts of license are accepted in edk2(described in readme). They are BSD (2-clause), BSD (3-clause), MIT, Python-2.0 and zlib.
Minus non bsd plus patent license, they are BSD (2-clause) and BSD (3-clause).
Thanks,
Shenglei
> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Wednesday, July 29, 2020 7:29 AM
> To: Zhang, Shenglei <shenglei.zhang@intel.com>; devel@edk2.groups.io;
> Kinney, Michael D <michael.d.kinney@intel.com>
> Cc: Sean Brogan <sean.brogan@microsoft.com>; Bret Barkelew
> <Bret.Barkelew@microsoft.com>; Gao, Liming <liming.gao@intel.com>
> Subject: RE: [PATCH 01/15] .pytool/Plugin: Add a plugin LicenseCheck
>
> Where did the requirement for BSD-3-Clause-Patent come from?
>
> Thanks,
>
> Mike
>
> > -----Original Message-----
> > From: Zhang, Shenglei <shenglei.zhang@intel.com>
> > Sent: Monday, July 20, 2020 1:37 AM
> > To: devel@edk2.groups.io
> > Cc: Sean Brogan <sean.brogan@microsoft.com>; Bret
> > Barkelew <Bret.Barkelew@microsoft.com>; Kinney, Michael
> > D <michael.d.kinney@intel.com>; Gao, Liming
> > <liming.gao@intel.com>
> > Subject: [PATCH 01/15] .pytool/Plugin: Add a plugin
> > LicenseCheck
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2691
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2833
> > Add a plugin to check license conflict for new added
> > files in a patch. It will report out errors when meeting
> > files which are now contributed under BSD-2-Clause-
> > Patent
> > or BSD-3-Clause-Patent.
> >
> > Cc: Sean Brogan <sean.brogan@microsoft.com>
> > Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> > ---
> > .pytool/Plugin/LicenseCheck/LicenseCheck.py | 118
> > ++++++++++++++++++
> > .../LicenseCheck/LicenseCheck_plug_in.yaml | 11 ++
> > .pytool/Plugin/LicenseCheck/Readme.md | 17 +++
> > 3 files changed, 146 insertions(+)
> > create mode 100644
> > .pytool/Plugin/LicenseCheck/LicenseCheck.py
> > create mode 100644
> > .pytool/Plugin/LicenseCheck/LicenseCheck_plug_in.yaml
> > create mode 100644
> > .pytool/Plugin/LicenseCheck/Readme.md
> >
> > diff --git a/.pytool/Plugin/LicenseCheck/LicenseCheck.py
> > b/.pytool/Plugin/LicenseCheck/LicenseCheck.py
> > new file mode 100644
> > index 000000000000..98941ddda758
> > --- /dev/null
> > +++ b/.pytool/Plugin/LicenseCheck/LicenseCheck.py
> > @@ -0,0 +1,118 @@
> > +# @file LicenseCheck.py
> > +#
> > +# Copyright (c) 2020, Intel Corporation. All rights
> > reserved.<BR>
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent
> > +##
> > +
> > +import os
> > +import logging
> > +import re
> > +from io import StringIO
> > +from typing import List, Tuple
> > +from
> > edk2toolext.environment.plugintypes.ci_build_plugin
> > import ICiBuildPlugin
> > +from edk2toolext.environment.var_dict import VarDict
> > +from edk2toollib.utility_functions import RunCmd
> > +
> > +
> > +class LicenseCheck(ICiBuildPlugin):
> > +
> > + """
> > + A CiBuildPlugin to check the license for new added
> > files.
> > +
> > + Configuration options:
> > + "LicenseCheck": {
> > + "IgnoreFiles": []
> > + },
> > + """
> > +
> > + license_format_preflix = 'SPDX-License-Identifier'
> > +
> > + bsd2_patent = 'BSD-2-Clause-Patent'
> > +
> > + bsd3_patent = 'BSD-3-Clause-Patent'
> > +
> > + Readdedfileformat = re.compile(r'\+\+\+ b\/(.*)')
> > +
> > + file_extension_list = [".c", ".h", ".inf", ".dsc",
> > ".dec", ".py", ".bat", ".sh", ".uni", ".yaml",
> > + ".fdf", ".inc", "yml",
> > ".asm", ".asm16", ".asl", ".vfr", ".s", ".S", ".aslc",
> > + ".nasm", ".nasmb", ".idf",
> > ".Vfr", ".H"]
> > +
> > + def GetTestName(self, packagename: str,
> > environment: VarDict) -> tuple:
> > + """ Provide the testcase name and classname for
> > use in reporting
> > + testclassname: a descriptive string for the
> > testcase can include whitespace
> > + classname: should be patterned
> > <packagename>.<plugin>.<optionally any unique condition>
> > +
> > + Args:
> > + packagename: string containing name of
> > package to build
> > + environment: The VarDict for the test to
> > run in
> > + Returns:
> > + a tuple containing the testcase name
> > and the classname
> > + (testcasename, classname)
> > + """
> > + return ("Check for license for " + packagename,
> > packagename + ".LicenseCheck")
> > +
> > + ##
> > + # External function of plugin. This function is
> > used to perform the task of the ci_build_plugin Plugin
> > + #
> > + # - package is the edk2 path to package. This
> > means workspace/packagepath relative.
> > + # - edk2path object configured with workspace and
> > packages path
> > + # - PkgConfig Object (dict) for the pkg
> > + # - EnvConfig Object
> > + # - Plugin Manager Instance
> > + # - Plugin Helper Obj Instance
> > + # - Junit Logger
> > + # - output_stream the StringIO output stream from
> > this plugin via logging
> > + def RunBuildPlugin(self, packagename, Edk2pathObj,
> > pkgconfig, environment, PLM, PLMHelper, tc,
> > output_stream=None):
> > + return_buffer = StringIO()
> > + params = "diff --unified=0 origin/master HEAD"
> > + RunCmd("git", params, outstream=return_buffer)
> > + p = return_buffer.getvalue().strip()
> > + patch = p.split("\n")
> > + return_buffer.close()
> > +
> > + ignore_files = []
> > + if "IgnoreFiles" in pkgconfig:
> > + ignore_files = pkgconfig["IgnoreFiles"]
> > +
> > + self.ok = True
> > + self.startcheck = False
> > + self.license = True
> > + self.all_file_pass = True
> > + count = len(patch)
> > + line_index = 0
> > + for line in patch:
> > + if line.startswith('--- /dev/null'):
> > + nextline = patch[line_index + 1]
> > + added_file =
> > self.Readdedfileformat.search(nextline).group(1)
> > + added_file_extension =
> > os.path.splitext(added_file)[1]
> > + if added_file_extension in
> > self.file_extension_list and packagename in added_file:
> > + if (self.IsIgnoreFile(added_file,
> > ignore_files)):
> > + line_index = line_index + 1
> > + continue
> > + self.startcheck = True
> > + self.license = False
> > + if self.startcheck and
> > self.license_format_preflix in line:
> > + if self.bsd2_patent in line or
> > self.bsd3_patent in line:
> > + self.license = True
> > + if line_index + 1 == count or
> > patch[line_index + 1].startswith('diff --') and
> > self.startcheck:
> > + if not self.license:
> > + self.all_file_pass = False
> > + error_message = "Invalid license
> > in: " + added_file + " Hint: Only BSD-2-Clause-Patent
> > and" + \
> > + " BSD-3-Clause-
> > Patent are accepted."
> > + logging.error(error_message)
> > + self.startcheck = False
> > + self.license = True
> > + line_index = line_index + 1
> > +
> > + if self.all_file_pass:
> > + tc.SetSuccess()
> > + return 0
> > + else:
> > + tc.SetFailed("License Check {0} Failed.
> > ".format(packagename), "LICENSE_CHECK_FAILED")
> > + return 1
> > +
> > + def IsIgnoreFile(self, file: str, ignore_files:
> > List[str]) -> bool:
> > + for f in ignore_files:
> > + if f in file:
> > + return True
> > + return False
> > diff --git
> > a/.pytool/Plugin/LicenseCheck/LicenseCheck_plug_in.yaml
> > b/.pytool/Plugin/LicenseCheck/LicenseCheck_plug_in.yaml
> > new file mode 100644
> > index 000000000000..1d02f6da5a69
> > --- /dev/null
> > +++
> > b/.pytool/Plugin/LicenseCheck/LicenseCheck_plug_in.yaml
> > @@ -0,0 +1,11 @@
> > +## @file
> > +# CiBuildPlugin used to check license issues for new
> > added files
> > +#
> > +# Copyright (c) Microsoft Corporation.
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent
> > +##
> > +{
> > + "scope": "cibuild",
> > + "name": "License Check Test",
> > + "module": "LicenseCheck"
> > +}
> > diff --git a/.pytool/Plugin/LicenseCheck/Readme.md
> > b/.pytool/Plugin/LicenseCheck/Readme.md
> > new file mode 100644
> > index 000000000000..57d9db6769fa
> > --- /dev/null
> > +++ b/.pytool/Plugin/LicenseCheck/Readme.md
> > @@ -0,0 +1,17 @@
> > +# License Check Plugin
> > +
> > +This CiBuildPlugin scans all new added files in a
> > package to make sure code
> > +is contributed under BSD-2-Clause-Patent or BSD-3-
> > Clause-Patent.
> > +
> > +## Configuration
> > +
> > +The plugin can be configured to ignore certain files.
> > +
> > +``` yaml
> > +"LicenseCheck": {
> > + "IgnoreFiles": []
> > +}
> > +```
> > +### IgnoreFiles
> > +
> > +OPTIONAL List of file to ignore.
> > --
> > 2.18.0.windows.1
next prev parent reply other threads:[~2020-07-29 6:06 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-20 8:36 [PATCH 00/15] Add a plugin LicenseCheck in open ci Zhang, Shenglei
2020-07-20 8:36 ` [PATCH 01/15] .pytool/Plugin: Add a plugin LicenseCheck Zhang, Shenglei
2020-07-28 23:29 ` Michael D Kinney
2020-07-29 6:06 ` Zhang, Shenglei [this message]
2020-07-29 7:29 ` Liming Gao
2020-07-20 8:36 ` [PATCH 02/15] FatPkg/FatPkg.ci.yaml: Add configuration for LicenseCheck Zhang, Shenglei
2020-07-20 8:36 ` [PATCH 03/15] ArmVirtPkg/ArmVirtPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 21:59 ` Laszlo Ersek
2020-07-20 8:36 ` [PATCH 04/15] CryptoPkg/CryptoPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 14:23 ` [edk2-devel] " Yao, Jiewen
2020-07-21 1:31 ` Guomin Jiang
2020-07-20 8:36 ` [PATCH 05/15] EmulatorPkg/EmulatorPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 8:37 ` [PATCH 06/15] FmpDevicePkg/FmpDevicePkg.ci.yaml: " Zhang, Shenglei
2020-07-21 1:31 ` [edk2-devel] " Guomin Jiang
2020-07-28 23:30 ` Michael D Kinney
2020-07-20 8:37 ` [PATCH 07/15] MdeModulePkg/MdeModulePkg.ci.yaml: " Zhang, Shenglei
2020-07-21 0:34 ` [edk2-devel] " Wu, Hao A
2020-07-20 8:37 ` [PATCH 08/15] MdePkg/MdePkg.ci.yaml: " Zhang, Shenglei
2020-07-20 8:37 ` [PATCH 09/15] NetworkPkg/NetworkPkg.ci.yaml: " Zhang, Shenglei
2020-07-21 16:42 ` [edk2-devel] " Maciej Rabeda
2020-07-20 8:37 ` [PATCH 10/15] OvmfPkg/OvmfPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 22:01 ` Laszlo Ersek
2020-07-27 6:21 ` Zhang, Shenglei
2020-07-27 9:50 ` Laszlo Ersek
2020-07-28 1:11 ` Zhang, Shenglei
2020-07-28 9:56 ` Laszlo Ersek
2020-07-20 8:37 ` [PATCH 11/15] PcAtChipsetPkg/PcAtChipsetPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 8:37 ` [PATCH 12/15] SecurityPkg/SecurityPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 14:24 ` Yao, Jiewen
2020-07-20 8:37 ` [PATCH 13/15] ShellPkg/ShellPkg.ci.yaml: " Zhang, Shenglei
2020-07-27 6:28 ` [edk2-devel] " Gao, Zhichao
2020-07-20 8:37 ` [PATCH 14/15] UefiCpuPkg/UefiCpuPkg.ci.yaml: " Zhang, Shenglei
2020-07-20 21:59 ` Laszlo Ersek
2020-07-21 0:24 ` Dong, Eric
2020-07-20 8:37 ` [PATCH 15/15] UnitTestFrameworkPkg: Add configuration for LicenseCheck in yaml file Zhang, Shenglei
2020-07-28 23:29 ` [edk2-devel] " Michael D Kinney
2020-07-25 1:38 ` [edk2-devel] [PATCH 00/15] Add a plugin LicenseCheck in open ci Rebecca Cran
2020-07-27 2:34 ` Liming Gao
[not found] ` <16257B609DB8C7F6.7401@groups.io>
2020-07-31 3:50 ` Liming Gao
2020-07-31 4:17 ` Rebecca Cran
2020-07-27 3:00 ` Liming Gao
[not found] ` <1623691E419E189F.16344@groups.io>
2020-07-27 6:26 ` [edk2-devel] [PATCH 15/15] UnitTestFrameworkPkg: Add configuration for LicenseCheck in yaml file Zhang, Shenglei
2020-07-28 23:33 ` [PATCH 00/15] Add a plugin LicenseCheck in open ci Michael D Kinney
2020-07-29 1:11 ` Liming Gao
2020-07-29 1:32 ` Michael D Kinney
2020-07-29 7:37 ` Liming Gao
2020-07-29 9:21 ` Laszlo Ersek
2020-07-29 15:21 ` [edk2-devel] " Andrew Fish
2020-07-30 0:59 ` Liming Gao
2020-07-29 9:12 ` Laszlo Ersek
2020-07-29 12:12 ` Leif Lindholm
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-list 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=BL0PR11MB3506A0ED03C281ABA7178F808C700@BL0PR11MB3506.namprd11.prod.outlook.com \
--to=devel@edk2.groups.io \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox