From patchwork Wed Feb 26 01:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 66044 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B1A7CA055E; Wed, 26 Feb 2020 02:14:43 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 098441BF8D; Wed, 26 Feb 2020 02:14:43 +0100 (CET) Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by dpdk.org (Postfix) with ESMTP id 3A199B62 for ; Wed, 26 Feb 2020 02:14:42 +0100 (CET) Received: by mail-pl1-f170.google.com with SMTP id g6so568169plp.6 for ; Tue, 25 Feb 2020 17:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YEyUUD1jrwsH6EUJcguDgjGMKwL0vO4dGf0mrskpenI=; b=bvBW7JUBHYaKactMnRE904fOSy9x/W3O49zWkocGmoi0GuYq3BYqYkuz8NT/hFwJp/ OXa9Fm8hF0DcEh5qPQp43n+lWn9CInggZFh1VgMk0iaLLncVP5H1s/r2fxQ+M+Aknlzk aemZB1+q0kJL7RUlYH59kl0jShBvr6x+NTI3KJk4Hl+XdCfmvSMmKfNv4ufy+Lsg426T hKz2+IMdfEguCS5colD1IAYBnmnadE5k37Ff4BfeY7mjO236YsP1DcVpYbIpIttnd0p8 hTk+tZBagLB5xobmfPpil29+c/u2+8FAkAMrB9jetGgn48Tv66Et6MZjPU57+RNSGO8n KkTw== 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=YEyUUD1jrwsH6EUJcguDgjGMKwL0vO4dGf0mrskpenI=; b=Gc/VRyxh/miq2zZHKqd0X47Zkek1qIQbTgxoKwmbeDNb4VfUKyzDJAdiDmLxL389eK fTqnO2GFjBP5F5PjFry+czV6BVC/PD+HzHcKmYhX44MSM1JoDCDpuydCsJw4pgWJF8Mm 3fIKO/q8aQSa6sTjBvty1WsWAcz1IuxjUORzzZnR0ItOJkHFRJlCnaT4h4J991GxIHtR XYI8HvG/mT2GzfgEJTiWUjsZF50w/N9fJ/Riy4E/Hx1GWG42ycstki6N76CkuZX0/tCz d49L9Es1MiIDIV2XF8BQOJo9FuWQJOjKocowXgxfXSMas5xEx856BC6t6nASOw/QApe4 HR2A== X-Gm-Message-State: APjAAAVmlKblOK9Mdj8P8CSgXr+yO6CF5F7cccaebtuEkHFMYwuyuMSI MRNLvSg+OKIBGwgHFP33PaqEA9k4nT8= X-Google-Smtp-Source: APXvYqz7oBHvPM3o+I15deLZJp5LGjlPiToE0mMvQn8QQpjaNxNM2NJIYwd3pFxIl/oSi+GGH1e2PA== X-Received: by 2002:a17:902:fe91:: with SMTP id x17mr1302429plm.250.1582679680629; Tue, 25 Feb 2020 17:14:40 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id q66sm213095pgq.50.2020.02.25.17.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 17:14:39 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 25 Feb 2020 17:14:31 -0800 Message-Id: <20200226011431.5968-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200129155907.20556-1-stephen@networkplumber.org> References: <20200129155907.20556-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] devtools: add new SPDX license compliance checker X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Simple script to look for drivers and scripts that are missing requires SPDX header. Signed-off-by: Stephen Hemminger --- v5 - fix issue in counting warnings update Copyright date MAINTAINERS | 1 + devtools/check-spdx-tag.sh | 73 ++++++++++++++++++++++++ doc/guides/contributing/coding_style.rst | 9 ++- 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100755 devtools/check-spdx-tag.sh diff --git a/MAINTAINERS b/MAINTAINERS index f4e0ed8e056c..75e0dc75f887 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -96,6 +96,7 @@ F: devtools/check-maintainers.sh F: devtools/check-forbidden-tokens.awk F: devtools/check-git-log.sh F: devtools/check-includes.sh +F: devtools/check-spdx-tag.sh F: devtools/check-symbol-maps.sh F: devtools/checkpatches.sh F: devtools/get-maintainer.sh diff --git a/devtools/check-spdx-tag.sh b/devtools/check-spdx-tag.sh new file mode 100755 index 000000000000..fc3d962ec647 --- /dev/null +++ b/devtools/check-spdx-tag.sh @@ -0,0 +1,73 @@ +#! /bin/sh +# SPDX-License-Identifier: BSD-3-Clause +# Copyright 2020 Microsoft Corporation +# +# Produce a list of files with incorrect license tags + +print_usage () { + echo "usage: $(basename $0) [-q] [-v]" + exit 1 +} + +check_spdx() { + if $verbose; then + echo "Files without SPDX License" + echo "--------------------------" + fi + git grep -L SPDX-License-Identifier -- \ + ':^.git*' ':^.ci/*' ':^.travis.yml' \ + ':^README' ':^MAINTAINERS' ':^VERSION' ':^ABI_VERSION' \ + ':^*/Kbuild' ':^*/README' \ + ':^license/' ':^doc/' ':^config/' ':^buildtools/' \ + ':^*.cocci' ':^*.abignore' \ + ':^*.def' ':^*.map' ':^*.ini' ':^*.data' ':^*.cfg' ':^*.txt' \ + > $tmpfile + + errors=0 + while read -r line + do $quiet || echo $line + errors=$((errors + 1)) + done < $tmpfile +} + +check_boilerplate() { + if $verbose ; then + echo + echo "Files with redundant license text" + echo "---------------------------------" + fi + + git grep -l Redistribution -- \ + ':^license/' ':^/devtools/check-spdx-tag.sh' > $tmpfile + + warnings=0 + while read -r line + do $quiet || echo $line + warnings=$((warnings + 1)) + done < $tmpfile +} + +quiet=false +verbose=false + +while getopts qvh ARG ; do + case $ARG in + q ) quiet=true ;; + v ) verbose=true ;; + h ) print_usage ; exit 0 ;; + ? ) print_usage ; exit 1 ;; + esac +done +shift $(($OPTIND - 1)) + +tmpfile=$(mktemp) +trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT + +check_spdx +$quiet || echo + +check_boilerplate + +$quiet || echo +echo "total: $errors errors, $warnings warnings" +exit $errors diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst index 841ef6d5c829..04626667dc18 100644 --- a/doc/guides/contributing/coding_style.rst +++ b/doc/guides/contributing/coding_style.rst @@ -54,8 +54,13 @@ To document a public API, a doxygen-like format must be used: refer to :ref:`dox License Header ~~~~~~~~~~~~~~ -Each file should begin with a special comment containing the appropriate copyright and license for the file. -Generally this is the BSD License, except for code for Linux Kernel modules. +Each file must begin with a special comment containing the +`Software Package Data Exchange (SPDX) License Identfier `_. + +Generally this is the BSD License, except for code granted special exceptions. +The SPDX licences identifier is sufficient, a file should not contain +an additional text version of the license (boilerplate). + After any copyright header, a blank line should be left before any other contents, e.g. include statements in a C file. C Preprocessor Directives