2 # $Id: srclist-update,v 1.19 2007-03-30 23:44:27 karl 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 # Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc.
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 3 of the License, or
12 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
22 # Originally written by Karl Berry.
30 #chicken="echo (would)"
33 dsttmp=$TMPDIR/srclist.dst
35 # Source `dirname $0`/srclistvars.sh first, if it exists.
37 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
41 # sed command to fix the license to be GPL.
43 /^[[:space:]]*#[[:space:]]*Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
44 # This program is free software: you can redistribute it and/or modify\
45 # it under the terms of the GNU General Public License as published by\
46 # the Free Software Foundation; either version 3 of the License, or\
47 # (at your option) any later version.\
49 # This program is distributed in the hope that it will be useful,\
50 # but WITHOUT ANY WARRANTY; without even the implied warranty of\
51 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
52 # GNU General Public License for more details.\
54 # You should have received a copy of the GNU General Public License\
55 # along with this program. If not, see <http://www.gnu.org/licenses/>.
57 /Th[ei][ s].* is free software/,/\*\//c\
58 This program is free software: you can redistribute it and/or modify\
59 it under the terms of the GNU General Public License as published by\
60 the Free Software Foundation; either version 3 of the License, or\
61 (at your option) any later version.\
63 This program is distributed in the hope that it will be useful,\
64 but WITHOUT ANY WARRANTY; without even the implied warranty of\
65 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
66 GNU General Public License for more details.\
68 You should have received a copy of the GNU General Public License\
69 along with this program. If not, see <http://www.gnu.org/licenses/>. */
72 # sed command to remove lines containing $Id lines.
73 # Quote the $ so that CVS does not expand it in this script.
74 remove_id_lines='/[$]Id:.*[$]/d'
76 # $1 is input file, $2 is output.
77 # Remove $Id lines, since they'll differ between source locations.
78 # If $options contains "gpl", change the license to be the standard
79 # GPL. We use this for libc files, et al.
83 sed_command="$remove_id_lines"
87 sed_command="$sed_command; $fixlicense";;
90 sed "$sed_command" $1 >$2
95 cat | while read src dst options; do
96 #echo "src=$src, dst=$dst, options=$options" >&2
98 *: ) continue;; # skip lines without second element
99 '#'* ) continue;; # skip comment-only lines
102 # Expand variables and make sure we have an input file.
104 if test ! -r $src; then
105 echo "$0: cannot read $src" >&2
109 # Ignore subdirs in src dir. E.g., if input spec is
110 # src/subdir/foo.c dst
111 # then write destination file dst/foo.c.
113 test -d $dst && dst=$dst/`basename $src`
115 # Fix files in both src and dst, for the sake
116 # of a clean comparison.
117 srctmp=$TMPDIR/`basename $src`
119 test -r $dst && fixfile $dst $dsttmp
121 # if src was executable, make dst executable, to placate git.
122 test -x $src && chmod a+x $dst
124 if test ! -e $dst; then
125 echo "## $srctmp $dst # new"
126 $chicken cp -p $srctmp $dst
127 elif cmp -s $srctmp $dsttmp; then
128 $verbose && echo "## $srctmp $dst # unchanged"
130 echo "## $srctmp $dst # changes"
131 diff -C 2 $dst $srctmp