update nearly all FSF copyright year lists to include 2010
[gnulib.git] / config / srclist-update
1 #!/bin/sh
2 # $Id: srclist-update,v 1.19 2007-03-30 23:44:27 karl Exp $
3 #
4 # Check for files in directory $1 being up to date, according to the
5 # list on stdin.  Don't actually make any changes, just show the diffs.
6 #
7 # Copyright (C) 2002, 2003, 2005, 2007, 2008, 2009, 2010 Free Software
8 # Foundation, Inc.
9 #
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 # Originally written by Karl Berry.
24
25
26 if test -n "$1"; then
27   cd "$1" || exit 1
28 fi
29
30 verbose=false
31 #chicken="echo (would)"
32
33 : ${TMPDIR=/tmp}
34 dsttmp=$TMPDIR/srclist.dst
35
36 # Source `dirname $0`/srclistvars.sh first, if it exists.
37 mydir=`dirname $0`
38 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
39
40
41\f
42 # sed command to fix the license to be GPL.
43 fixlicense='
44   /^[[:space:]]*#[[:space:]]*Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
45 #   This program is free software: you can redistribute it and/or modify\
46 #   it under the terms of the GNU General Public License as published by\
47 #   the Free Software Foundation; either version 3 of the License, or\
48 #   (at your option) any later version.\
49 #\
50 #   This program is distributed in the hope that it will be useful,\
51 #   but WITHOUT ANY WARRANTY; without even the implied warranty of\
52 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\
53 #   GNU General Public License for more details.\
54 #\
55 #   You should have received a copy of the GNU General Public License\
56 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
57
58   /Th[ei][ s].* is free software/,/\*\//c\
59    This program is free software: you can redistribute it and/or modify\
60    it under the terms of the GNU General Public License as published by\
61    the Free Software Foundation; either version 3 of the License, or\
62    (at your option) any later version.\
63 \
64    This program is distributed in the hope that it will be useful,\
65    but WITHOUT ANY WARRANTY; without even the implied warranty of\
66    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\
67    GNU General Public License for more details.\
68 \
69    You should have received a copy of the GNU General Public License\
70    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
71 '
72
73 # sed command to remove lines containing $Id lines.
74 # Quote the $ so that CVS does not expand it in this script.
75 remove_id_lines='/[$]Id:.*[$]/d'
76
77 # $1 is input file, $2 is output.
78 # Remove $Id lines, since they'll differ between source locations.
79 # If $options contains "gpl", change the license to be the standard
80 # GPL.  We use this for libc files, et al.
81 #
82 fixfile() \
83 {
84   sed_command="$remove_id_lines"
85
86   case " $options " in
87   *' gpl '*)
88     sed_command="$sed_command; $fixlicense";;
89   esac
90
91   sed "$sed_command" $1 >$2
92 }
93
94
95\f
96 cat | while read src dst options; do
97   #echo "src=$src, dst=$dst, options=$options" >&2
98   case $src:$dst in
99     *: ) continue;;    # skip lines without second element
100     '#'* ) continue;;  # skip comment-only lines
101   esac
102
103   # Expand variables and make sure we have an input file.
104   eval src=$src
105   if test ! -r $src; then
106     echo "$0: cannot read $src" >&2
107     continue
108   fi
109
110   # Ignore subdirs in src dir.  E.g., if input spec is
111   #   src/subdir/foo.c dst
112   # then write destination file dst/foo.c.
113   eval dst=$dst
114   test -d $dst && dst=$dst/`basename $src`
115
116   # Fix files in both src and dst, for the sake
117   # of a clean comparison.
118   srctmp=$TMPDIR/`basename $src`
119   fixfile $src $srctmp
120   test -r $dst && fixfile $dst $dsttmp
121
122   # if src was executable, make dst executable, to placate git.
123   test -x $src && chmod a+x $dst
124
125   if test ! -e $dst; then
126     echo "## $srctmp $dst  # new"
127     $chicken cp -p $srctmp $dst
128   elif cmp -s $srctmp $dsttmp; then
129     $verbose && echo "## $srctmp $dst  # unchanged"
130   else
131     echo "## $srctmp $dst  # changes"
132     diff -C 2 $dst $srctmp
133   fi
134 done
135
136 rm -f $dsttmp