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~ - "${1}" <<'EOF'
46 s{^((\#\!.*?\n|\n*---\n.*?\n\.\.\.\n|<\?xml.*?>\n)\n?)?}{${2}$ENV{want}\n\n}ms
50 IFS=$'\n' read -a ignores -r -d $'\000' <.licenseignore || true
52 git ls-files -z ${@} | \
53 while read -rd $'\000' fnm
61 if [[ ! -f ${fnm} ]] || [[ -L ${fnm} ]] || [[ ! -s ${fnm} ]]
67 for pattern in "${ignores[@]}"
69 if [[ ${fnm} == ${pattern} ]]
74 if [[ ${ignore} = 1 ]]; then continue; fi
77 Makefile | */Makefile \
78 | *.dockerfile | */Dockerfile.* | */Dockerfile | *.dockerignore \
79 | */MANIFEST.in | */fuse.conf | */gitolite.rc \
80 | *.pl | *.pm | *.PL \
81 | *.rb | *.rb.example | *.rake | *.ru \
82 | *.gemspec | */Gemfile | */Rakefile \
83 | services/login-sync/bin/* \
86 | sdk/python/bin/arv-* \
88 | services/nodemanager/bin/* \
89 | services/fuse/bin/* \
90 | tools/crunchstat-summary/bin/* \
92 | *.yaml | *.yml | *.yml.example | *.cwl \
94 | */run | */run-service | */restart-dns-server \
95 | */nodemanager/doc/*.cfg \
96 | */nodemanager/tests/fake*.cfg.template \
118 cs=$'{% comment %}\n'
120 ce=$'\n{% endcomment %}'
142 *.go | *.scss | *.java | *.js)
158 hashbang=$(head -n1 ${fnm})
159 if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
165 wantGPL="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
167 ${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}"
168 wantApache="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
170 ${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}"
171 wantBYSA="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
173 ${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}"
174 found=$(head -n20 "$fnm" | egrep -A${grepAfter} -B${grepBefore} 'Copyright.*Arvados' || true)
176 Makefile | build/* | lib/* | tools/* | apps/* | services/*)
179 crunch_scripts/* | backports/* | docker/* | sdk/*)
197 if [[ -z ${found} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
201 echo "missing copyright notice: $fnm"
206 echo "nonstandard copyright notice: $fnm '${found}'"