2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: AGPL-3.0
9 while [[ "${@}" != "" ]]
16 Usage: $0 [--fix] [-- git-ls-args...]
20 --fix Insert missing copyright notices where possible.
24 Arguments after "--" are passed to \`git ls-files\`; this can be used to
25 restrict the set of files to check.
37 echo >&2 "Unrecognized argument '${arg}'. Try $0 --help"
44 want="${want}" perl -pi~ -e 'if ($. == 1) { s{^(\#\!.*\n)?}{${1}$ENV{want}\n\n} }' "${1}"
47 IFS=$'\n' read -a ignores -r -d $'\000' <.licenseignore || true
49 git ls-files -z ${@} | \
50 while read -rd $'\000' fnm
58 if [[ ! -f ${fnm} ]] || [[ -L ${fnm} ]] || [[ ! -s ${fnm} ]]
64 for pattern in "${ignores[@]}"
66 if [[ ${fnm} == ${pattern} ]]
71 if [[ ${ignore} = 1 ]]; then continue; fi
74 Makefile | */Makefile \
75 | *.dockerfile | */Dockerfile.* | */Dockerfile | *.dockerignore \
76 | */MANIFEST.in | */fuse.conf | */gitolite.rc \
77 | *.pl | *.pm | *.PL \
78 | *.rb | *.rb.example | *.rake | *.ru \
79 | *.gemspec | */Gemfile | */Rakefile \
80 | services/login-sync/bin/* \
83 | sdk/python/bin/arv-* \
85 | services/nodemanager/bin/* \
86 | services/fuse/bin/* \
87 | tools/crunchstat-summary/bin/* \
89 | *.yaml | *.yml | *.yml.example | *.cwl \
91 | */run | */run-service | */restart-dns-server \
92 | */nodemanager/doc/*.cfg \
114 cs=$'{% comment %}\n'
116 ce=$'\n%{% endcomment %}'
132 *.go | *.scss | *.java | *.js | *.coffee)
148 hashbang=$(head -n1 ${fnm})
149 if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
155 wantGPL="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
157 ${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}"
158 wantApache="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
160 ${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}"
161 wantBYSA="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
163 ${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}"
164 found=$(head "$fnm" | egrep -A${grepAfter} -B${grepBefore} 'Copyright.*Arvados' || true)
166 Makefile | build/* | lib/* | tools/* | apps/* | services/*)
169 crunch_scripts/* | backports/* | docker/* | sdk/*)
187 if [[ -z ${found} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
191 echo "missing copyright notice: $fnm"
196 echo "nonstandard copyright notice: $fnm '${found}'"