From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.1808.1587538923164872643 for ; Wed, 22 Apr 2020 00:02:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=Bv0HrffN; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: liming.gao@intel.com) IronPort-SDR: wLS1cBBLA6EO2+AzrhINZsDIFR1OPhJZFicVS9N5QV1Wc4OmWZaveKghsxeXn2ZihXm7K9cCVE j7PMhPJCRpmQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2020 00:02:02 -0700 IronPort-SDR: 0P0RkkBV4kB7V+cbzO68TYYWdNClVfStt3KAj9Zcb1vQPrrxDWBtI00P5ntko2RmI3XPF2M0od OkOU0PJ7R80A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,412,1580803200"; d="scan'208";a="247385462" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by fmsmga008.fm.intel.com with ESMTP; 22 Apr 2020 00:02:02 -0700 Received: from fmsmsx156.amr.corp.intel.com (10.18.116.74) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 22 Apr 2020 00:01:52 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx156.amr.corp.intel.com (10.18.116.74) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 22 Apr 2020 00:01:52 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 22 Apr 2020 00:01:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HkHICGZ0g4zD2q87Bqkd2mmJTdDmTzsHCLKOcFau1JDD5/WWrIQVyNHgy0oSAwwU0Z7Hi413w9xjp9bUp5seVQyGc0RGFXItnOnfMentLXhkl9xckwJJcmZ2EwEUGadGQYPyNSAAgTNrhmkSdE/2dYIz/wELmGmomiPvewWz423zUxysImVEO3H3SUbRKD71BTdPOgDtFmWolaWQ9hth8kNCg6U/A0X7O3yjff8CRSXhvyVgytISgpFvz+q/nNDEp+DMMJlVmcBeA3ERdUbhG8ANmDlWF4D15XKoFrPzOBCK4/AFXr4zYDlJ52zZYrv1JJ4ULXq2TueEruEs1y/6/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+cYqpu1s4PsdUx89QjKZHhC0YmRRXxzjL9hlCEU2yWo=; b=UYLNzgFELgf88PYquuYL4x/cGkzse0XG19NGpC1oSGEj/HlQYEUQFvf4TM8Jn5xICp8pm6AKZ9ApaEeUzFQz0tUxVy0LIYPwfF3gW9C6/6YOK1IaTL8Kiu/HU2JP1Cn3fD9NjbJLGq7L9FuV/BKC096HJQJOVt6lYyILxHAzHxw274Tx+d5Z5ARphGDeHfUMBd5qXzOCWUZvhFFu7AdFIAq1V8E6FQkIpbZKKYJ3xEXWlLZ/uILeVnOMtA9oS8eX3X+Pih3lD7fMJNo02rjdJu8120jZIp4ast8xNt06B9ghV2wWjJbilXTxl62Pc9fc8N1VQX9zv4MA4lb10bRlcw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+cYqpu1s4PsdUx89QjKZHhC0YmRRXxzjL9hlCEU2yWo=; b=Bv0HrffNpgrAR72D71QGl30HQV9jJyw0rSYk1sTsxHp63qYlQGSG0H3i3TdLT9B1sXHn7HFOS3DgteSQjzcXwSD76bh8GP60kIx3ldT/fOPAjo+LQP8GV00tbsgDxqavrjeWkteR9WGnI9ZRq/Ouas+5AiG7PwA0lVO0S5FeSig= Received: from BN6PR11MB3972.namprd11.prod.outlook.com (2603:10b6:405:7f::11) by BN6PR11MB1937.namprd11.prod.outlook.com (2603:10b6:404:106::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.29; Wed, 22 Apr 2020 07:01:50 +0000 Received: from BN6PR11MB3972.namprd11.prod.outlook.com ([fe80::4dcc:bc5c:def:9ae9]) by BN6PR11MB3972.namprd11.prod.outlook.com ([fe80::4dcc:bc5c:def:9ae9%5]) with mapi id 15.20.2921.030; Wed, 22 Apr 2020 07:01:49 +0000 From: "Liming Gao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Feng, Bob C" Subject: Re: [PATCH] BaseTools/PatchCheck.py: Add LicenseCheck Thread-Topic: [PATCH] BaseTools/PatchCheck.py: Add LicenseCheck Thread-Index: AQHWGHNJYIgNQAvnTkSQCgNBOO6qPaiEtnzA Date: Wed, 22 Apr 2020 07:01:49 +0000 Message-ID: References: <20200422065655.75392-1-shenglei.zhang@intel.com> In-Reply-To: <20200422065655.75392-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: spf=none (sender IP is ) smtp.mailfrom=liming.gao@intel.com; x-originating-ip: [192.55.52.209] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 6655ae03-e0e6-4799-8deb-08d7e68b07ae x-ms-traffictypediagnostic: BN6PR11MB1937: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1824; x-forefront-prvs: 03818C953D x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR11MB3972.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(10019020)(346002)(136003)(39860400002)(376002)(366004)(396003)(66946007)(478600001)(66446008)(55016002)(66476007)(64756008)(66556008)(107886003)(9686003)(110136005)(4326008)(316002)(6506007)(53546011)(86362001)(76116006)(52536014)(8676002)(33656002)(8936002)(71200400001)(186003)(7696005)(26005)(5660300002)(2906002)(81156014);DIR:OUT;SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eixVJCbun5lHXM64UpZDNxZ757MPCuPoGN5GI/Llc1X0TcDmWFo4yCtKn9kwd+2mDplHRI32/HKP92Ih8KxO08oDhRj3XFWQo37u8yJj0yL7tVB5K1FxzHZwLBQN2iVVNHswO9kyov7NLkkEgshi4g3bKa1QgMMzF1ZF/P2wVwvcbQB24leIlMU3c7PB9FSnNRr1bQwClqy1PzpMahDsxe0P59gmNPcsZ/mG9sPPNL3rUJM7UOs+yg+xvkt6JkgFZYACdgCoT4aWAICueTgYx092CNshELsNTiCQMxcdBsGW4z3Oe8PGIXSQhtJDV+KmxVM5iRdaRggiUldbWnybnHdGO+sJATK3OrUHjvikZJUrOATH9XH3WGRn/eHUaivMNMmwg23HQ3wUyXKKnI774zpEIhHiIuxc4XRssZHFysD1XRjHUyB1YgMkpiKOYqeJ x-ms-exchange-antispam-messagedata: ngk43Pr01bjfQ103LLVPV3peamGjycG58vecLSwDCuMvrcpkQV0+jQioy+Cc2Z7R9dWn3XuFzw7LlsuPVSL6Sux8B5w4S753l3ST0cqpbqchU7PfeqnITN3rUafJ5NcvSoI7G/uSDm29jma54yEEfg== MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 6655ae03-e0e6-4799-8deb-08d7e68b07ae X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Apr 2020 07:01:49.8288 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: r4fazRJGfxyMSwU1SFyfMluPl4qZJkaCZYVZMl4Rubc7ckCblRHAECDaI0mNf4uuNMFjXjB9EtCs0X9SzT2Z/g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR11MB1937 Return-Path: liming.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Shenglei: Please submit BZ to describe it. The license should be BSD-2-Clause-Paten= t. Thanks Liming > -----Original Message----- > From: Zhang, Shenglei > Sent: Wednesday, April 22, 2020 2:57 PM > To: devel@edk2.groups.io > Cc: Feng, Bob C ; Gao, Liming > Subject: [PATCH] BaseTools/PatchCheck.py: Add LicenseCheck >=20 > For files to be added to the tree, this feature will check > whether it has BSD license. >=20 > Cc: Bob Feng > Cc: Liming Gao > Signed-off-by: Shenglei Zhang > --- > BaseTools/Scripts/PatchCheck.py | 52 ++++++++++++++++++++++++++++++++- > 1 file changed, 51 insertions(+), 1 deletion(-) >=20 > diff --git a/BaseTools/Scripts/PatchCheck.py b/BaseTools/Scripts/PatchChe= ck.py > index 13da6967785d..15663d02a3c0 100755 > --- a/BaseTools/Scripts/PatchCheck.py > +++ b/BaseTools/Scripts/PatchCheck.py > @@ -491,6 +491,53 @@ class GitDiffCheck: > print(prefix, line) > count +=3D 1 >=20 > +class LicenseCheck(): > + > + def __init__(self, diff): > + self.ok =3D True > + self.startcheck =3D False > + self.license =3D True > + lines =3D diff.splitlines(True) > + count =3D len(lines) > + line_index =3D 0 > + for line in lines: > + if line.startswith('--- /dev/null'): > + nextline =3D lines[line_index + 1] > + added_file =3D self.Readdedfileformat.search(nextline).g= roup(1) > + added_file_extension =3D os.path.splitext(added_file)[1] > + if added_file_extension in self.file_extension_list: > + self.startcheck =3D True > + self.license =3D False > + if self.startcheck and self.license_name in line: > + self.license =3D True > + if line_index + 1 =3D=3D count or lines[line_index + 1].star= tswith('diff --') and self.startcheck: > + if not self.license: > + self.error(added_file) > + self.startcheck =3D False > + self.license =3D True > + line_index =3D line_index + 1 > + > + def error(self, *err): > + if self.ok and Verbose.level > Verbose.ONELINE: > + print('License is missing!') > + self.ok =3D False > + if Verbose.level < Verbose.NORMAL: > + return > + count =3D 0 > + for line in err: > + prefix =3D (' *', ' ')[count > 0] > + error_format =3D 'Missing license in:' > + print(prefix, error_format, line) > + count +=3D 1 > + > + > + license_name =3D 'BSD-2-Clause-Patent' > + > + Readdedfileformat =3D re.compile(r'\+\+\+ b\/(.*)\n') > + > + file_extension_list =3D [".c", ".h", ".inf", ".dsc", ".dec", ".py", = ".bat", ".sh", ".uni", ".yaml", ".fdf", ".inc"] > + > + > class CheckOnePatch: > """Checks the contents of a git email formatted patch. >=20 > @@ -508,12 +555,15 @@ class CheckOnePatch: > msg_check =3D CommitMessageCheck(self.commit_subject, self.commi= t_msg) > msg_ok =3D msg_check.ok >=20 > + license_check =3D LicenseCheck(self.diff) > + license_ok =3D license_check.ok > + > diff_ok =3D True > if self.diff is not None: > diff_check =3D GitDiffCheck(self.diff) > diff_ok =3D diff_check.ok >=20 > - self.ok =3D email_ok and msg_ok and diff_ok > + self.ok =3D email_ok and msg_ok and diff_ok and license_ok >=20 > if Verbose.level =3D=3D Verbose.ONELINE: > if self.ok: > -- > 2.18.0.windows.1