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
53 coproc git ls-files -z ${@} </dev/null
54 while read -rd $'\000' fnm
62 if [[ ! -f ${fnm} ]] || [[ -L ${fnm} ]] || [[ ! -s ${fnm} ]]
68 for pattern in "${ignores[@]}"
70 if [[ ${fnm} == ${pattern} ]]
75 if [[ ${ignore} = 1 ]]; then continue; fi
78 Makefile | */Makefile \
79 | *.dockerfile | */Dockerfile.* | */Dockerfile | *.dockerignore \
80 | */MANIFEST.in | */fuse.conf | */gitolite.rc \
81 | *.pl | *.pm | *.PL \
82 | *.rb | *.rb.example | *.rake | *.ru \
83 | *.gemspec | */Gemfile | */Rakefile \
84 | services/login-sync/bin/* \
87 | sdk/python/bin/arv-* \
89 | services/nodemanager/bin/* \
90 | services/fuse/bin/* \
91 | tools/crunchstat-summary/bin/* \
93 | *.yaml | *.yml | *.yml.example | *.cwl \
95 | */run | */run-service | */restart-dns-server \
96 | */nodemanager/doc/*.cfg \
97 | */nodemanager/tests/fake*.cfg.template \
99 | build/build.list | *.R)
119 cs=$'{% comment %}\n'
121 ce=$'\n{% endcomment %}'
143 *.go | *.scss | *.java | *.js)
159 hashbang=$(head -n1 ${fnm})
160 if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
166 wantGPL="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
168 ${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}"
169 wantApache="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
171 ${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}"
172 wantBYSA="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
174 ${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}"
175 wantBYSAmd="[comment]: # (Copyright © The Arvados Authors. All rights reserved.)
177 [comment]: # (SPDX-License-Identifier: CC-BY-SA-3.0)"
178 found=$(head -n20 "$fnm" | egrep -A${grepAfter} -B${grepBefore} 'Copyright.*All rights reserved.' || true)
180 Makefile | build/* | lib/* | tools/* | apps/* | services/* | sdk/cli/bin/crunch-job)
183 crunch_scripts/* | backports/* | docker/* | sdk/*)
206 if [[ -z ${found} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
210 echo "missing copyright notice: $fnm"
215 echo "nonstandard copyright notice: $fnm '${found}'"