1#! /bin/sh 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright 2020 Microsoft Corporation 4# 5# Produce a list of files with incorrect license tags 6 7errors=0 8warnings=0 9quiet=false 10verbose=false 11 12print_usage () { 13 echo "usage: $(basename $0) [-q] [-v]" 14 exit 1 15} 16 17check_spdx() { 18 if $verbose; then 19 echo "Files without SPDX License" 20 echo "--------------------------" 21 fi 22 git grep -L SPDX-License-Identifier -- \ 23 ':^.git*' ':^.mailmap' ':^.ci/*' \ 24 ':^README' ':^MAINTAINERS' ':^VERSION' ':^ABI_VERSION' \ 25 ':^*/Kbuild' ':^*/README*' \ 26 ':^license/' ':^config/' ':^buildtools/' ':^*/poetry.lock' \ 27 ':^kernel/linux/uapi/.gitignore' ':^kernel/linux/uapi/version' \ 28 ':^*.cocci' ':^*.abignore' \ 29 ':^*.map' ':^*.ini' ':^*.data' ':^*.json' ':^*.cfg' ':^*.txt' \ 30 ':^*.svg' ':^*.png' \ 31 > $tmpfile 32 33 errors=$(wc -l < $tmpfile) 34 $quiet || cat $tmpfile 35} 36 37check_boilerplate() { 38 if $verbose ; then 39 echo 40 echo "Files with redundant license text" 41 echo "---------------------------------" 42 fi 43 44 git grep -l Redistribution -- \ 45 ':^license/' ':^/devtools/check-spdx-tag.sh' > $tmpfile 46 47 warnings=$(wc -l <$tmpfile) 48 $quiet || cat $tmpfile 49} 50 51while getopts qvh ARG ; do 52 case $ARG in 53 q ) quiet=true ;; 54 v ) verbose=true ;; 55 h ) print_usage ; exit 0 ;; 56 ? ) print_usage ; exit 1 ;; 57 esac 58done 59shift $(($OPTIND - 1)) 60 61tmpfile=$(mktemp -t dpdk.checkspdx.XXXXXX) 62trap 'rm -f -- "$tmpfile"' INT TERM HUP EXIT 63 64check_spdx 65$quiet || echo 66 67check_boilerplate 68 69$quiet || echo 70echo "total: $errors errors, $warnings warnings" 71exit $errors 72