Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | #!/bin/bash -x |
| 2 | |
| 3 | # This script will search all copyrights dates from source files, and update these if |
| 4 | # the file has been modified at a later date. |
| 5 | |
| 6 | if [ ! -f include/freeDiameter/libfdcore.h ]; |
| 7 | then echo "This script must be run from the source top directory" |
| 8 | exit 1; |
| 9 | fi; |
| 10 | |
| 11 | # Create a clean working copy |
| 12 | TMPDIR=`mktemp -d up_cop.XXXXXXX` || exit 1 |
| 13 | hg clone . $TMPDIR/fD || exit 1 |
| 14 | pushd $TMPDIR/fD |
| 15 | |
| 16 | # Now, for each file with a copyright |
| 17 | for SRC_FILE in `find . -name .hg -prune -or -type f -exec grep -q 'Copyright (c) 20.., WIDE Project and NICT' {} \; -print`; |
| 18 | do |
| 19 | HG_YEAR=`hg log --template '{date|shortdate}' $SRC_FILE | tr - ' ' | awk '{print \$1}'` |
| 20 | CPY_YEAR=`grep 'Copyright (c) 20.., WIDE Project and NICT' $SRC_FILE | awk '{print substr(\$4, 1, 4) }'` |
| 21 | if [ $HG_YEAR -gt $CPY_YEAR ]; |
| 22 | then |
| 23 | echo "Updating copyright $CPY_YEAR -> $HG_YEAR in $SRC_FILE"; |
| 24 | sed -i -e "s/Copyright (c) $CPY_YEAR, WIDE Project and NICT/Copyright (c) $HG_YEAR, WIDE Project and NICT/" $SRC_FILE |
| 25 | fi; |
| 26 | done |
| 27 | |
| 28 | hg commit -m"Updated copyright information" |
| 29 | hg push |
| 30 | popd |
| 31 | rm -rf $TMPDIR |
| 32 | hg update |
| 33 | |