/
addcopyright.sh
executable file
·279 lines (240 loc) · 8.71 KB
/
addcopyright.sh
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#!/bin/bash
###########################################################################
# addcopyright.sh
# ---------------------
# Date : May 2012
# Copyright : (C) 2012 by Juergen E. Fischer
# Email : jef at norbit dot de
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
# licensecheck -r src
set -e
for i in $(<files); do
echo $i >&2
author=
authordate=
eval $(git log --reverse --pretty="export author='%an' authordate=\"\$(date --date='%ai' +'%%B %Y')\"" $i | head -1)
basename=$(basename $i)
authoryear=${authordate#* }
case $i in
# Override author if initial commit was by someone else
python/plugins/sextante/*)
author=volayaf
;;
src/app/gps/qwtpolar-*|src/app/qtmain_android.cpp|src/core/spatialite/*|src/core/spatialindex/src/*|src/core/gps/qextserialport/*|src/plugins/grass/qtermwidget/*|src/astyle/*|python/pyspatialite/*|src/providers/sqlanywhere/sqlanyconnection/*)
# Skip third party files
echo $f skipped
continue
;;
esac
case $author in
morb_au)
authorname="Brendan Morley"
authoremail="morb at ozemail dot com dot au"
;;
endmax)
authorname="Massimo Endrighi"
authoremail="massimo dot endrighi at geopartner dot it"
;;
rugginoso)
authorname="Lorenzo Masini"
authoremail="rugginoso at develer dot com"
;;
homann)
authorname="Magnus Homann"
authoremail="magnus at homann dot se"
;;
gsherman)
authorname="Gary Sherman"
authoremail="gsherman at geoapt dot com"
;;
kyngchaos)
authorname="William Kyngesburye"
authoremail="kyngchaos at kyngchaos dot com"
;;
volayaf)
authorname="Victor Olaya"
authoremail="volayaf at gmail dot com"
;;
jef|"Juergen E. Fischer")
authorname="Juergen E. Fischer"
authoremail="jef at norbit dot de"
;;
"Salvatore Larosa")
authorname="Salvatore Larosa"
authoremail="lrssvtml at gmail dot com"
;;
wonder|"Martin Dobias")
authorname="Martin Dobias"
authoremail="wonder dot sk at gmail dot com"
;;
"Marco Hugentobler"|mhugent)
authorname="Marco Hugentobler"
authoremail="marco dot hugentobler at sourcepole dot ch"
;;
"Pirmin Kalberer")
authorname="Pirmin Kalberer"
authoremail="pka at sourcepole dot ch"
;;
"Alexander Bruy")
authorname="Alexander Bruy"
authoremail="alexander dot bruy at gmail dot com"
;;
brushtyler|"Giuseppe Sucameli")
authorname="Giuseppe Sucameli"
authoremail="brush dot tyler at gmail dot com"
;;
pcav)
authorname="Paolo Cavallini"
authoremail="cavallini at faunalia dot it"
;;
"cfarmer")
authorname="Carson J. Q. Farmer"
authoremail="carson dot farmer at gmail dot com"
;;
rblazek|"Radim Blazek")
authorname="Radim Blazek"
authoremail="radim dot blazek at gmail dot com"
;;
marcopx)
authorname="Marco Pasetti"
authoremail="marco dot pasetti at alice dot it"
;;
timlinux|"Tim Sutton")
authorname="Tim Sutton"
authoremail="tim at linfiniti dot com"
;;
*)
echo "Author $author not found."
exit 1
;;
esac
origsrc=$i
if [ -f "$i.nocopyright" ]; then
origsrc=$i.nocopyright
fi
src=$origsrc
dst=$src.new
shebang=$(head -1 $src)
case "$shebang" in
'#!'*)
shebang="$shebang
"
src="<(tail -n +2 $src)"
;;
*)
shebang=
;;
esac
case "$origsrc" in
*.sh)
eval cat - $src >$dst <<EOF
$shebang###########################################################################
# $basename
# ---------------------
# Date : $authordate
# Copyright : (C) $authoryear by $authorname
# Email : $authoremail
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
EOF
;;
*.py)
eval cat - $src >$dst <<EOF
$shebang# -*- coding: utf-8 -*-
"""
***************************************************************************
$basename
---------------------
Date : $authordate
Copyright : (C) $authoryear by $authorname
Email : $authoremail
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
__author__ = '$authorname'
__date__ = '$authordate'
__copyright__ = '(C) $authoryear, $authorname'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '\$Format:%H$'
EOF
;;
*.cpp|*.h)
cat - $src >$dst <<EOF
/***************************************************************************
$basename
---------------------
begin : $authordate
copyright : (C) $authoryear by $authorname
email : $authoremail
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
EOF
;;
*.pl)
eval cat - $src >$dst <<EOF
$shebang###########################################################################
# $basename
# ---------------------
# begin : $authordate
# copyright : (C) $authoryear by $authorname
# email : $authoremail
###########################################################################
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
###########################################################################
EOF
;;
*.bat|*.cmd)
cat - $src >$dst <<EOF
REM ***************************************************************************
REM $basename
REM ---------------------
REM begin : $authordate
REM copyright : (C) $authoryear by $authorname
REM email : $authoremail
REM ***************************************************************************
REM * *
REM * This program is free software; you can redistribute it and/or modify *
REM * it under the terms of the GNU General Public License as published by *
REM * the Free Software Foundation; either version 2 of the License, or *
REM * (at your option) any later version. *
REM * *
REM ***************************************************************************
EOF
;;
*)
echo "$i skipped"
continue
esac
[ -f $i.nocopyright ] || mv $i $i.nocopyright
cp $dst $origsrc
done