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