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