2 # $Id: srclist-update,v 1.11 2003-08-13 06:48:58 eggert Exp $
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.
7 # Source `dirname $0`/srclistvars.sh first, if it exists.
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)
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.
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
21 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 # Written by Karl Berry.
32 #chicken="echo (would)"
35 dsttmp=$TMPDIR/srclist.dst
38 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
42 # $1 is input, output to stdout with gpl.
48 /^\([[:space:]]*#[[:space:]]*\)Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
49 # This program is free software; you can redistribute it and/or modify\
50 # it under the terms of the GNU General Public License as published by\
51 # the Free Software Foundation; either version 2, or (at your option)\
54 # This program is distributed in the hope that it will be useful,\
55 # but WITHOUT ANY WARRANTY; without even the implied warranty of\
56 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
57 # GNU General Public License for more details.\
59 # You should have received a copy of the GNU General Public License along\
60 # with this program; if not, write to the Free Software Foundation,\
61 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
63 /Th[ei][ s].* is free software/,/USA\. *\*\//c\
64 This program is free software; you can redistribute it and/or modify\
65 it under the terms of the GNU General Public License as published by\
66 the Free Software Foundation; either version 2, or (at your option)\
69 This program is distributed in the hope that it will be useful,\
70 but WITHOUT ANY WARRANTY; without even the implied warranty of\
71 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
72 GNU General Public License for more details.\
74 You should have received a copy of the GNU General Public License along\
75 with this program; if not, write to the Free Software Foundation,\
76 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
82 # sed command to remove lines containing $Id lines.
83 # Quote the $Id so that CVS does not expand it in this script.
84 remove_id_lines='/[$]Id:.*[$]/d'
86 # sed command to remove trailing blanks.
87 # Do not use [[:space:]] in this pattern, as that would kill formfeeds.
88 remove_trailing_blanks='s/[ ][ ]*$//'
90 # $1 is input file, $2 is output.
91 # Remove $Id lines, since they'll differ between source locations.
92 # If $options contains "gpl", change the license to be the standard
93 # GPL. We use this for libc files, et al.
94 # Also, normalize white space simple-mindedly.
105 | sed "$remove_id_lines; $remove_trailing_blanks" >$2
110 cat | while read src dst options; do
111 #echo "src=$src, dst=$dst, options=$options" >&2
113 *: ) continue;; # skip lines without second element
114 '#'* ) continue;; # skip comment-only lines
117 # Expand variables and make sure we have an input file.
119 if test ! -r $src; then
120 echo "$0: cannot read $src" >&2
124 # Ignore subdirs in src dir. E.g., if input spec is
125 # src/subdir/foo.c dst
126 # then write destination file dst/foo.c.
128 test -d $dst && dst=$dst/`basename $src`
130 # Fix files in both src and dst, for the sake
131 # of a clean comparison.
132 srctmp=$TMPDIR/`basename $src`
134 test -r $dst && fixfile $dst $dsttmp
136 if test ! -e $dst; then
137 echo "## $srctmp $dst # new"
138 $chicken cp -p $srctmp $dst
139 elif cmp -s $srctmp $dsttmp; then
140 $verbose && echo "## $srctmp $dst # unchanged"
142 echo "## $srctmp $dst # changes"
143 diff -C 2 $dst $srctmp