2 # Update existing Sun copyright notices to Oracle copyright notices
3 # Does not add copyright notices to files that are missing them
5 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
9 TMPFILE=$(mktemp $TMP/updatecopy.XXXXXX)
12 SUNCOPY="Copyright.*Sun Micro.*"
13 ORACOPY="Copyright.*Oracle.*"
16 git ls-files build ldiskfs libcfs lnet lustre snmp |grep -v ${0##*/} | while read FILE; do
17 # Pick only files that have changed since LECDATE
18 if [ -n "$(git log -n1 --since=$LECDATE $FILE)" ]; then
19 OLDCOPY="$(egrep "$SUNCOPY|$ORACOPY" $FILE | sed 's/.*Copy/Copy/')"
20 if [ -z "$OLDCOPY" ]; then
22 *.[ch]) echo "$FILE: no Copyright" && continue ;;
26 # skip files that already have a copyright for this year
27 echo "$OLDCOPY" | grep -q "$NOW.*Oracle" && continue
31 git log --follow --pretty=format:%ci $FILE | cut -d- -f1 > $TMPFILE
32 NEWYEAR=$(head -1 $TMPFILE)
33 OLDYEAR=$(tail -1 $TMPFILE)
36 [ $NEWYEAR == $OLDYEAR ] && YEAR="$NEWYEAR" || YEAR="$OLDYEAR, $NEWYEAR"
38 NEWCOPY="Copyright (c) $YEAR, Oracle and/or its affiliates. All rights reserved."
40 # If the copyright isn't different (excluding whitespace), don't change it.
41 [ "$OLDCOPY" == "$NEWCOPY" ] && continue
43 [ ! -w $FILE ] && echo "Unable to write to $FILE" && exit 1
45 echo "$FILE: Copyright $YEAR"
46 sed -e "s#$ORACOPY#$NEWCOPY#" -e "s#$SUNCOPY#$NEWCOPY#" $FILE > $FILE.tmp
47 cp $FILE.tmp $FILE # preserve owner/mode