4
# Copyright (C) 2013 Canonical Ltd
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License version 3 as
8
# published by the Free Software Foundation.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
# Authored by: Michi Henning <michi.henning@canonical.com>
22
# Check that, somewhere in the first 30 lines of each file, the string "Copyright" (case independent) appears.
23
# Print out a messsage for each file without a copyright notice and exit with non-zero status
24
# if any such file is found.
29
echo "usage: check_copyright dir [ignore_dir]" >&2
39
# We don't use the -i option of licensecheck to add ignore_dir to the pattern because Jenkins creates directories
40
# with names that contain regex meta-characters, such as "." and "+". Instead, if ingnore_dir is set, we post-filter
41
# the output with grep -F, so we don't get false positives from licensecheck.
44
[ $# -eq 2 ] && ignore_dir="$2"
46
if [ -n "$ignore_dir" ]
48
licensecheck -i "$ignore_pat" -r "$1" | grep -F "$ignore_dir" -v | grep 'No copyright'
50
licensecheck -i "$ignore_pat" -r "$1" | grep 'No copyright'
53
[ $? -eq 0 ] && exit 1