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\n?)?}{${1}$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 \
117 cs=$'{% comment %}\n'
119 ce=$'\n{% endcomment %}'
135 *.go | *.scss | *.java | *.js | *.coffee)
151 hashbang=$(head -n1 ${fnm})
152 if [[ ${hashbang} = "#!/bin/sh" ]] || [[ ${hashbang} = "#!/bin/bash" ]]
158 wantGPL="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
160 ${cc}${cc:+ }SPDX-License-Identifier: AGPL-3.0${ce}"
161 wantApache="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
163 ${cc}${cc:+ }SPDX-License-Identifier: Apache-2.0${ce}"
164 wantBYSA="${cs:-${cc}} Copyright (C) The Arvados Authors. All rights reserved.
166 ${cc}${cc:+ }SPDX-License-Identifier: CC-BY-SA-3.0${ce}"
167 found=$(head "$fnm" | egrep -A${grepAfter} -B${grepBefore} 'Copyright.*Arvados' || true)
169 Makefile | build/* | lib/* | tools/* | apps/* | services/*)
172 crunch_scripts/* | backports/* | docker/* | sdk/*)
190 if [[ -z ${found} ]] && [[ -n ${want} ]] && [[ $fix = true ]] && [[ $fixer != "" ]]
194 echo "missing copyright notice: $fnm"
199 echo "nonstandard copyright notice: $fnm '${found}'"