2 # $Id: srclist-update,v 1.12 2003-08-13 07:04:57 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 # Copyright (C) 2002, 2003 Free Software Foundation, Inc.
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)
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.
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
26 # Written by Karl Berry.
34 #chicken="echo (would)"
37 dsttmp=$TMPDIR/srclist.dst
40 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
44 # $1 is input, output to stdout with gpl.
50 /^\([[:space:]]*#[[:space:]]*\)Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
51 # This program is free software; you can redistribute it and/or modify\
52 # it under the terms of the GNU General Public License as published by\
53 # the Free Software Foundation; either version 2, or (at your option)\
56 # This program is distributed in the hope that it will be useful,\
57 # but WITHOUT ANY WARRANTY; without even the implied warranty of\
58 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
59 # GNU General Public License for more details.\
61 # You should have received a copy of the GNU General Public License along\
62 # with this program; if not, write to the Free Software Foundation,\
63 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
65 /Th[ei][ s].* is free software/,/USA\. *\*\//c\
66 This program is free software; you can redistribute it and/or modify\
67 it under the terms of the GNU General Public License as published by\
68 the Free Software Foundation; either version 2, or (at your option)\
71 This program is distributed in the hope that it will be useful,\
72 but WITHOUT ANY WARRANTY; without even the implied warranty of\
73 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
74 GNU General Public License for more details.\
76 You should have received a copy of the GNU General Public License along\
77 with this program; if not, write to the Free Software Foundation,\
78 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
84 # sed command to remove lines containing $Id lines.
85 # Quote the $Id so that CVS does not expand it in this script.
86 remove_id_lines='/[$]Id:.*[$]/d'
88 # sed command to remove trailing blanks.
89 # Do not use [[:space:]] in this pattern, as that would kill formfeeds.
90 remove_trailing_blanks='s/[ ][ ]*$//'
92 # $1 is input file, $2 is output.
93 # Remove $Id lines, since they'll differ between source locations.
94 # If $options contains "gpl", change the license to be the standard
95 # GPL. We use this for libc files, et al.
96 # Also, normalize white space simple-mindedly.
107 | sed "$remove_id_lines; $remove_trailing_blanks" >$2
112 cat | while read src dst options; do
113 #echo "src=$src, dst=$dst, options=$options" >&2
115 *: ) continue;; # skip lines without second element
116 '#'* ) continue;; # skip comment-only lines
119 # Expand variables and make sure we have an input file.
121 if test ! -r $src; then
122 echo "$0: cannot read $src" >&2
126 # Ignore subdirs in src dir. E.g., if input spec is
127 # src/subdir/foo.c dst
128 # then write destination file dst/foo.c.
130 test -d $dst && dst=$dst/`basename $src`
132 # Fix files in both src and dst, for the sake
133 # of a clean comparison.
134 srctmp=$TMPDIR/`basename $src`
136 test -r $dst && fixfile $dst $dsttmp
138 if test ! -e $dst; then
139 echo "## $srctmp $dst # new"
140 $chicken cp -p $srctmp $dst
141 elif cmp -s $srctmp $dsttmp; then
142 $verbose && echo "## $srctmp $dst # unchanged"
144 echo "## $srctmp $dst # changes"
145 diff -C 2 $dst $srctmp