2 # $Id: srclist-update,v 1.17 2005-05-15 06:51:32 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, 2005 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 Foundation,
23 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 # Originally written by Karl Berry.
33 #chicken="echo (would)"
36 dsttmp=$TMPDIR/srclist.dst
39 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
43 # sed command to fix the license to be GPL.
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)\
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.\
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.
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)\
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.\
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.
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'
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.
87 sed_command="$remove_id_lines"
91 sed_command="$sed_command; $fixlicense";;
94 sed "$sed_command" $1 >$2
99 cat | while read src dst options; do
100 #echo "src=$src, dst=$dst, options=$options" >&2
102 *: ) continue;; # skip lines without second element
103 '#'* ) continue;; # skip comment-only lines
106 # Expand variables and make sure we have an input file.
108 if test ! -r $src; then
109 echo "$0: cannot read $src" >&2
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.
117 test -d $dst && dst=$dst/`basename $src`
119 # Fix files in both src and dst, for the sake
120 # of a clean comparison.
121 srctmp=$TMPDIR/`basename $src`
123 test -r $dst && fixfile $dst $dsttmp
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"
131 echo "## $srctmp $dst # changes"
132 diff -C 2 $dst $srctmp