double space after USA in the license
[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 2, or (at your option)
12 # 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, write to the Free Software Foundation,
21 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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 2, or (at your option)\
48 #   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 along\
56 #   with this program; if not, write to the Free Software Foundation,\
57 #   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
58
59   /Th[ei][ s].* is free software/,/\*\//c\
60    This program is free software; you can redistribute it and/or modify\
61    it under the terms of the GNU General Public License as published by\
62    the Free Software Foundation; either version 2, or (at your option)\
63    any later version.\
64 \
65    This program is distributed in the hope that it will be useful,\
66    but WITHOUT ANY WARRANTY; without even the implied warranty of\
67    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\
68    GNU General Public License for more details.\
69 \
70    You should have received a copy of the GNU General Public License along\
71    with this program; if not, write to the Free Software Foundation,\
72    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
73 '
74
75 # sed command to remove lines containing $Id lines.
76 # Quote the $ so that CVS does not expand it in this script.
77 remove_id_lines='/[$]Id:.*[$]/d'
78
79 # $1 is input file, $2 is output.
80 # Remove $Id lines, since they'll differ between source locations.
81 # If $options contains "gpl", change the license to be the standard
82 # GPL.  We use this for libc files, et al.
83 #
84 fixfile() \
85 {
86   sed_command="$remove_id_lines"
87
88   case " $options " in
89   *' gpl '*)
90     sed_command="$sed_command; $fixlicense";;
91   esac
92
93   sed "$sed_command" $1 >$2
94 }
95
96
97\f
98 cat | while read src dst options; do
99   #echo "src=$src, dst=$dst, options=$options" >&2
100   case $src:$dst in
101     *: ) continue;;    # skip lines without second element
102     '#'* ) continue;;  # skip comment-only lines
103   esac
104
105   # Expand variables and make sure we have an input file.
106   eval src=$src
107   if test ! -r $src; then
108     echo "$0: cannot read $src" >&2
109     continue
110   fi
111
112   # Ignore subdirs in src dir.  E.g., if input spec is
113   #   src/subdir/foo.c dst
114   # then write destination file dst/foo.c.
115   eval dst=$dst
116   test -d $dst && dst=$dst/`basename $src`
117
118   # Fix files in both src and dst, for the sake
119   # of a clean comparison.
120   srctmp=$TMPDIR/`basename $src`
121   fixfile $src $srctmp
122   test -r $dst && fixfile $dst $dsttmp
123
124   if test ! -e $dst; then
125     echo "## $srctmp $dst  # new"
126     $chicken cp -p $srctmp $dst
127   elif cmp -s $srctmp $dsttmp; then
128     $verbose && echo "## $srctmp $dst  # unchanged"
129   else
130     echo "## $srctmp $dst  # changes"
131     diff -C 2 $dst $srctmp
132   fi
133 done
134
135 rm -f $dsttmp