Zack Williams | 4f2b80f | 2018-03-12 15:11:37 -0700 | [diff] [blame] | 1 | #!/usr/bin/env sh |
| 2 | |
| 3 | # licensecheck.sh |
| 4 | # checks for copyright/license headers on files |
| 5 | # excludes filename extensions where this check isn't pertinent |
| 6 | |
| 7 | # this could be rewritten with better form. Currently is a cut/paste from the |
| 8 | # Jenkins job with minimal changes (BSD/OS X xargs params compat, sort of |
| 9 | # excluded file extensions). |
| 10 | |
| 11 | find . -name ".git" -prune -o -type f \ |
| 12 | -name "*.*" \ |
| 13 | ! -name "*.PNG" \ |
| 14 | ! -name "*.asc" \ |
| 15 | ! -name "*.bat" \ |
| 16 | ! -name "*.cfg" \ |
| 17 | ! -name "*.cnf" \ |
| 18 | ! -name "*.conf" \ |
| 19 | ! -name "*.cql" \ |
| 20 | ! -name "*.crt" \ |
| 21 | ! -name "*.csr" \ |
| 22 | ! -name "*.csv" \ |
| 23 | ! -name "*.ctmpl" \ |
| 24 | ! -name "*.curl" \ |
| 25 | ! -name "*.db" \ |
| 26 | ! -name "*.der" \ |
| 27 | ! -name "*.diff" \ |
| 28 | ! -name "*.dnsmasq" \ |
| 29 | ! -name "*.do" \ |
| 30 | ! -name "*.docx" \ |
| 31 | ! -name "*.eot" \ |
| 32 | ! -name "*.gif" \ |
| 33 | ! -name "*.gpg" \ |
| 34 | ! -name "*.graffle" \ |
| 35 | ! -name "*.iml" \ |
| 36 | ! -name "*.in" \ |
| 37 | ! -name "*.inc" \ |
| 38 | ! -name "*.j2" \ |
| 39 | ! -name "*.jar" \ |
| 40 | ! -name "*.jks" \ |
| 41 | ! -name "*.jpg" \ |
| 42 | ! -name "*.json" \ |
| 43 | ! -name "*.key" \ |
| 44 | ! -name "*.list" \ |
| 45 | ! -name "*.local" \ |
| 46 | ! -name "*.log" \ |
| 47 | ! -name "*.mak" \ |
| 48 | ! -name "*.md" \ |
| 49 | ! -name "*.mk" \ |
| 50 | ! -name "*.oar" \ |
| 51 | ! -name "*.p12" \ |
| 52 | ! -name "*.patch" \ |
| 53 | ! -name "*.pcap" \ |
| 54 | ! -name "*.pem" \ |
| 55 | ! -name "*.png" \ |
| 56 | ! -name "*.properties" \ |
| 57 | ! -name "*.proto" \ |
| 58 | ! -name "*.pyc" \ |
| 59 | ! -name "*.repo" \ |
| 60 | ! -name "*.robot" \ |
| 61 | ! -name "*.rst" \ |
| 62 | ! -name "*.rules" \ |
| 63 | ! -name "*.service" \ |
| 64 | ! -name "*.svg" \ |
| 65 | ! -name "*.swp" \ |
| 66 | ! -name "*.tar" \ |
| 67 | ! -name "*.tar.gz" \ |
| 68 | ! -name "*.toml" \ |
| 69 | ! -name "*.ttf" \ |
| 70 | ! -name "*.txt" \ |
| 71 | ! -name "*.woff" \ |
| 72 | ! -name "*.xproto" \ |
| 73 | ! -name "*.xtarget" \ |
| 74 | ! -name "*ignore" \ |
| 75 | ! -name "*rc" \ |
| 76 | ! -name "Dockerfile" \ |
| 77 | ! -name "Dockerfile.*" \ |
| 78 | ! -name "Makefile" \ |
| 79 | ! -name "Makefile.*" \ |
| 80 | ! -name "README" \ |
| 81 | ! -path "*/vendor/*.go" \ |
| 82 | ! -path "*conf*" \ |
| 83 | ! -path "*git*" \ |
| 84 | ! -path "*swagger*" \ |
| 85 | -print0 | \ |
| 86 | xargs -0 -n1 sh -c 'if ! grep -q "Copyright\|Apache License" $0; then echo "ERROR: $0 does not contain Copyright header"; exit 1; fi;' |
| 87 | |