2 # $Id: srclist-update,v 1.15 2004-06-22 18:28:25 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 # sed command to fix the license to be GPL.
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)\
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.\
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.
61 /Th[ei][ s].* is free software/,/\*\//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)\
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.\
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. */
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'
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.
88 sed_command="$remove_id_lines"
92 sed_command="$sed_command; $fixlicense";;
95 sed "$sed_command" $1 >$2
100 cat | while read src dst options; do
101 #echo "src=$src, dst=$dst, options=$options" >&2
103 *: ) continue;; # skip lines without second element
104 '#'* ) continue;; # skip comment-only lines
107 # Expand variables and make sure we have an input file.
109 if test ! -r $src; then
110 echo "$0: cannot read $src" >&2
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.
118 test -d $dst && dst=$dst/`basename $src`
120 # Fix files in both src and dst, for the sake
121 # of a clean comparison.
122 srctmp=$TMPDIR/`basename $src`
124 test -r $dst && fixfile $dst $dsttmp
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"
132 echo "## $srctmp $dst # changes"
133 diff -C 2 $dst $srctmp