1#!/bin/sh -eu
2
3## This file is part of the aMule Project
4##
5## Copyright (c) 2011 Dévai Tamás ( gonosztopi@amule.org )
6## Copyright (c) 2011 aMule Team ( admin@amule.org / http://www.amule.org )
7##
8## This program is free software; you can redistribute it and/or
9## modify it under the terms of the GNU General Public License
10## as published by the Free Software Foundation; either
11## version 2 of the License, or (at your option) any later version.
12##
13## This program is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17##
18## You should have received a copy of the GNU General Public License
19## along with this program; if not, write to the Free Software
20## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
21
22# Usage:
23#	year_bumper [oldyear [newyear]]
24#
25#	oldyear defaults to the year found in configure.ac
26#	newyear defaults to the current year
27
28if [ ! -f ./configure.ac ]; then
29	echo "This script must be run from the source root directory!"
30	exit 1
31fi
32
33if [ $# -ge 1 ]; then
34	oldyear="$1"
35else
36	oldyear=`sed -e 's/# Copyright (c) 2003-\([0-9]\{4\}\).*/\1/;t;d' ./configure.ac`
37fi
38
39if [ $# -ge 2 ]; then
40	newyear="$2"
41else
42	newyear=`date "+%Y"`
43fi
44
45echo "Bumping from ${oldyear} to ${newyear}..."
46
47if [ "$newyear" = "$oldyear" ]; then
48	echo "Nothing to do."
49	exit
50fi
51
52find '.' \
53	'(' \
54		-name '.svn' -o	\
55		-name '.hg' -o	\
56		-name '.git' -o	\
57		-name '*.wdr'	\
58	')' -prune -o \
59	-type f -print | \
60while read f; do
61	if file "$f" | grep -q text ; then
62		if grep -q "$oldyear" "$f" ; then
63			echo $f
64			sed -i -e "/Copyright/{s/-${oldyear}/-${newyear}/g;s/${oldyear}/${oldyear}-${newyear}/g;}" "$f"
65		fi
66	fi
67done
68