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