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