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