summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/dist/s_copyright
blob: 9ff6c20492eeb92ace5f3cc5ac1c798b1f8953a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#! /bin/sh

# Only run when building a release
test -z "$WT_RELEASE_BUILD" && exit 0

# Check the copyrights.

c1=__wt.copyright.1
c2=__wt.copyright.2
c3=__wt.copyright.3
c4=__wt.copyright.4
c5=__wt.copyright.5

check()
{
	# Skip files in which WiredTiger holds no rights.
	if `egrep "skip	$1" dist/s_copyright.list > /dev/null`; then
		return;
	fi

	# It's okay if the file doesn't exist: we may be running in a release
	# tree with some files removed.
	test -f $1 || return

	# Check for a correct copyright header.
	if `sed -e 2,5p -e 6q -e d $1 | diff - dist/$c1 > /dev/null` ; then
		return;
	fi
	if `sed -e 2,4p -e 5q -e d $1 | diff - dist/$c2 > /dev/null` ; then
		return;
	fi
	if `sed -e 3,6p -e 7q -e d $1 | diff - dist/$c3 > /dev/null` ; then
		return;
	fi
	if `sed -e 3,5p -e 6q -e d $1 | diff - dist/$c4 > /dev/null` ; then
		return;
	fi
	if `sed -e 1,3p -e 4q -e d $1 | diff - dist/$c4 > /dev/null` ; then
		return;
	fi
	if `sed -e 2,7p -e 8q -e d $1 | diff - dist/$c5 > /dev/null` ; then
		return;
	fi

	echo "$1: copyright information is incorrect"
	exit 1
}

# s_copyright is re-entrant, calling itself with individual file names.
# Any single argument call is a file name, check its copyright.
if [ $# -ne 0 ]; then
	check $1
	exit 0
fi

trap 'rm -f $c1 $c2 $c3 $c4' 0 1 2 3 13 15

year=`date +%Y`

cat > $c1 <<ENDOFTEXT
 * Copyright (c) 2014-$year MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
ENDOFTEXT

# Copyright for files WiredTiger does not own.
cat > $c2 <<ENDOFTEXT
 * Public Domain 2014-$year MongoDB, Inc.
 * Public Domain 2008-2014 WiredTiger, Inc.
 *
 * This is free and unencumbered software released into the public domain.
ENDOFTEXT

cat > $c3 <<ENDOFTEXT
# Copyright (c) 2014-$year MongoDB, Inc.
# Copyright (c) 2008-2014 WiredTiger, Inc.
#	All rights reserved.
#
# See the file LICENSE for redistribution information.
ENDOFTEXT

cat > $c4 <<ENDOFTEXT
# Public Domain 2014-$year MongoDB, Inc.
# Public Domain 2008-2014 WiredTiger, Inc.
#
# This is free and unencumbered software released into the public domain.
ENDOFTEXT

cat > $c5 <<ENDOFTEXT
 * Copyright (c) 2014-$year MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
ENDOFTEXT

# Parallelize if possible.
xp=""
echo date | xargs -P 20 >/dev/null 2>&1
if test $? -eq 0; then
	xp="-P 20"
fi

# Search for files, skipping some well-known 3rd party directories.
(cd .. && find [a-z]* -name '*.[chi]' \
	-o -name '*.cxx' \
	-o -name '*.in' \
	-o -name '*.java' \
	-o -name '*.py' |
    sed	-e '/Makefile.in/d' \
	-e '/^build_posix\//d' \
	-e '/api\/leveldb\/basho\//d' \
	-e '/api\/leveldb\/hyperleveldb\//d' \
	-e '/api\/leveldb\/leveldb\//d' \
	-e '/api\/leveldb\/rocksdb\//d' \
	-e '/\/3rdparty\//d' \
	-e '/\/node_modules\//d' \
	-e '/dist\/__/d' \
	-e 's/^\.\///' |
    xargs $xp -n 1 -I{} sh dist/s_copyright {})

# A few special cases: LICENSE, documentation, wt utility, some of which have
# more than one copyright notice in the file. For files that have only a single
# copyright notice, we give it to MongoDB, from 2008 to now.
string1="Copyright \(c\) 2014-$year MongoDB, Inc."
string2="Copyright \(c\) 2008-$year MongoDB, Inc."
string3="printf.*Copyright \(c\) 2008-$year MongoDB, Inc."
special_copyright()
{
	cnt=`egrep "$3" ../$1 | wc -l`
	if test $cnt -ne $2; then
		echo "$1: copyright information is incorrect"
	fi
}

special_copyright LICENSE 1 "$string1"
special_copyright src/docs/build-javadoc.sh 1 "$string2"
special_copyright src/docs/style/footer.html 2 "$string2"
special_copyright src/utilities/util_cpyright.c 1 "$string3"

exit 0