2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 # T2 SDE: scripts/Create-CopyPatch
6 # Copyright (C) 2004 - 2014 The T2 SDE Project
7 # Copyright (C) 1998 - 2003 ROCK Linux Project
9 # More information can be found in the files COPYING and README.
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License. A copy of the
14 # GNU General Public License can be found in the file COPYING.
15 # --- T2-COPYRIGHT-NOTE-END ---
18 copynotepatch
=`mktemp`
24 cat << EOT > $copynote
28 This Copyright note is generated by scripts/Create-CopyPatch,
29 more information can be found in the files COPYING and README.
33 cp $copynote $copynotepatch
35 cat << EOT >> $copynote
36 This program is free software; you can redistribute it and/or modify
37 it under the terms of the GNU General Public License version 2.
40 cat << EOT >> $copynotepatch
41 This patch file is dual-licensed. It is available under the license the
42 patched project is licensed under, as long as it is an OpenSource license
43 as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
44 of the GNU General Public License version 2 as used by the T2 SDE.
47 echo "Creating copy.patch ..." >&2
50 if [ "$1" = "-svn" ]; then
55 set architecture
/. misc
/. package
/.
scripts
/. target
/.
57 # check if file or package name was given
60 if [ -f $i -o -d $i ]; then
61 files
="$files ${i#./}"
62 elif [ -d package
/*/$i ]; then
63 for each
in `echo package/*/$i`; do
64 [[ $each = *~
]] && continue
65 files
="$files $each/."
68 echo Cannot
find \'$i\', ignoring.
1>&2
75 bash
scripts
/xfind.sh $
* -type f
! -name "*~" \
76 ! -name Create-CopyPatch |
sed 's,/\./,/,g' |
77 while read filename
; do
78 # determine the comment mode first
82 */Makefile|
*.sh|
*.pl|
*.
in|
*.hlp|
*.conf
) mode
=sh
;;
83 *.cron|
*.postinstall|
*.init
) mode
=sh
;;
84 *.h|
*.c|
*.cc|
*.cpp|
*.
lex|
*.y|
*.spec|
*.tcx|
*.tmpl|
*.tcc
) mode
=c
;;
87 *scripts
/[A-Z
][a-z-
]*|
*/parse-config
*) mode
=sh
;;
88 *patch|
*diff|
*patch.
*) mode
=sh
;;
92 #echo "Mode type: $mode"
94 grep -q -- '--- NO-\(T2\|ROCK\)-COPYRIGHT-NOTE ---' "$filename" &&
100 if head -n 1 "$filename" |
grep -q '^#!'; then
103 case "`sed -n 's/^ *\([^ ]\+\) .*COPYRIGHT-NOTE-BEGIN .*/\1/p' "$filename"`" in
109 if [ "$mode" == none
]; then
110 echo "Unknown type for $filename" 1>&2
115 # make a copy in the case we have no matching conditional below
116 sed 's,ROCK-COPYRIGHT-NOTE,T2-COPYRIGHT-NOTE,g' "$filename" > $oldfile
118 tag
=$
( sed -n -e '/^\(.*\)--- \(T2\|ROCK\)-COPYRIGHT-NOTE-BEGIN ---.*/{s//\1/;p;q;}' "$filename" )
121 if [ -n "$tag" ]; then
122 # has a note, catch copyrights
123 oldcopyright
=`sed -e '/--- T2-COPYRIGHT-NOTE-BEGIN ---/,/--- T2-COPYRIGHT-NOTE-END ---/!d' \
124 -e '/.*\(Copyright (C) .*\)/!d;s//\1/;' \
125 -e 's/Clifford Wolf/ROCK Linux Project/' \
131 if echo "$oldcopyright" |
grep -q 'T2 SDE'; then
132 # if has T2 copyright, renew if necesary
133 since
=$
( echo "$oldcopyright" |
sed -n -e 's,.* (C) \([^ ]*\) .*T2 SDE.*,\1,p' )
135 if [ $since -lt $thisyear ]; then
136 copyright
=`echo "$oldcopyright" | sed -e \
137 "s,.*T2 SDE.*,Copyright (C) $since - $thisyear The T2 SDE Project,"`
139 copyright
="$oldcopyright"
143 if [ "$usesvn" = 1 ]; then
144 since
=`TZ=UTC svn log -q "$filename" 2> /dev/null |
145 grep -a '^r' | tail -n 1 | cut -d'|' -f3 | cut -c2-5`
147 # but until 2003 we were ROCK Linux, so
148 if [ ${since:-2004} -lt 2004 ]; then
149 oldcopyright
="Copyright (C) $since - 2003 ROCK Linux Project"
156 # prepare a copyright tag
157 if [ ${since:-1} -lt $thisyear ]; then
158 copyright
="Copyright (C) ${since:-ESVNTO} - $thisyear The T2 SDE Project"
160 copyright
="Copyright (C) $thisyear The T2 SDE Project"
162 copyright
="$copyright${oldcopyright:+\\n$oldcopyright}"
167 if [ -z "$tag" ]; then
168 # doesn't have a note
169 if head -n 1 "$filename" |
grep -a -q '^#!'; then
180 pretag
='/*' posttag
=' */'
194 }$tag--- T2-COPYRIGHT-NOTE-BEGIN ---\\
195 $tag--- T2-COPYRIGHT-NOTE-END ---\\
196 ${posttag:+$posttag\\
200 mangled_filename
=`echo "$filename" |
201 sed 's,package/\([^/]*\)/\(.*\),package/*/\2,'`
207 # implant T2 copy note
209 grep -a -B 100000 -- '--- T2-COPYRIGHT-NOTE-BEGIN ---' $oldfile
211 if [ "$filename" != "${filename%/*.diff}" -o \
212 "$filename" != "${filename%/*.patch}" -o \
213 "$filename" != "${filename%/*.patch.*}" ]; then
214 sed -e "s,@@FILENAME@@,$mangled_filename,; \
215 s,@@COPYRIGHT@@,${copyright//
216 /\\n},;" $copynotepatch
218 sed -e "s,@@FILENAME@@,$mangled_filename,; \
219 s,@@COPYRIGHT@@,${copyright//
222 # we need a separated sed call because $rockcopyright adds a new line
223 } |
sed -e "s,^,$tag,"
225 grep -a -A 100000 -- '--- T2-COPYRIGHT-NOTE-END ---' $oldfile
228 # create the difference
229 if ! cmp -s $oldfile $newfile; then
230 echo "Creating patch for $filename." >&2
231 diff -ua "./$filename" $newfile |
232 sed -e "2 s,$newfile,./$filename,"
235 echo "WARNING: No Copyright tags in $filename found!" >&2
239 rm -f $copynote $copynotepatch $newfile