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/fuse/bin/* \
90 | tools/crunchstat-summary/bin/* \
92 | *.yaml | *.yml | *.yml.example | *.cwl \
94 | */run | */run-service | */restart-dns-server \
96 | build/build.list | *.R)
116 cs=$'{% comment %}\n'
118 ce=$'\n{% endcomment %}'
140 *.go | *.scss | *.java | *.js)
156 hashbang=$(head -n1 ${fnm})
157 if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
163 wantGPL="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
165 ${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}"
166 wantApache="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
168 ${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}"
169 wantBYSA="${cs:-${cc}${cc:+ }}Copyright (C) The Arvados Authors. All rights reserved.
171 ${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}"
172 wantBYSAmd="[comment]: # (Copyright © The Arvados Authors. All rights reserved.)
174 [comment]: # (SPDX-License-Identifier: CC-BY-SA-3.0)"
175 found=$(head -n20 "$fnm" | egrep -A${grepAfter} -B${grepBefore} 'Copyright.*All rights reserved.' || true)
177 Makefile | build/* | lib/* | tools/* | apps/* | services/* | sdk/cli/bin/crunch-job)
180 crunch_scripts/* | docker/* | sdk/*)
203 if [[ -z ${found} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
207 echo "missing copyright notice: $fnm"
212 echo "nonstandard copyright notice: $fnm '${found}'"