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, 2009, 2010 Free Software
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 # Originally written by Karl Berry.
31 #chicken="echo (would)"
34 dsttmp=$TMPDIR/srclist.dst
36 # Source `dirname $0`/srclistvars.sh first, if it exists.
38 test -r $mydir/srclistvars.sh && . $mydir/srclistvars.sh
42 # sed command to fix the license to be GPL.
44 /^[[:space:]]*#[[:space:]]*Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
45 # This program is free software: you can redistribute it and/or modify\
46 # it under the terms of the GNU General Public License as published by\
47 # the Free Software Foundation; either version 3 of the License, or\
48 # (at your option) any later version.\
50 # This program is distributed in the hope that it will be useful,\
51 # but WITHOUT ANY WARRANTY; without even the implied warranty of\
52 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
53 # GNU General Public License for more details.\
55 # You should have received a copy of the GNU General Public License\
56 # along with this program. If not, see <http://www.gnu.org/licenses/>.
58 /Th[ei][ s].* is free software/,/\*\//c\
59 This program is free software: you can redistribute it and/or modify\
60 it under the terms of the GNU General Public License as published by\
61 the Free Software Foundation; either version 3 of the License, or\
62 (at your option) any later version.\
64 This program is distributed in the hope that it will be useful,\
65 but WITHOUT ANY WARRANTY; without even the implied warranty of\
66 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
67 GNU General Public License for more details.\
69 You should have received a copy of the GNU General Public License\
70 along with this program. If not, see <http://www.gnu.org/licenses/>. */
73 # sed command to remove lines containing $Id lines.
74 # Quote the $ so that CVS does not expand it in this script.
75 remove_id_lines='/[$]Id:.*[$]/d'
77 # $1 is input file, $2 is output.
78 # Remove $Id lines, since they'll differ between source locations.
79 # If $options contains "gpl", change the license to be the standard
80 # GPL. We use this for libc files, et al.
84 sed_command="$remove_id_lines"
88 sed_command="$sed_command; $fixlicense";;
91 sed "$sed_command" $1 >$2
96 cat | while read src dst options; do
97 #echo "src=$src, dst=$dst, options=$options" >&2
99 *: ) continue;; # skip lines without second element
100 '#'* ) continue;; # skip comment-only lines
103 # Expand variables and make sure we have an input file.
105 if test ! -r $src; then
106 echo "$0: cannot read $src" >&2
110 # Ignore subdirs in src dir. E.g., if input spec is
111 # src/subdir/foo.c dst
112 # then write destination file dst/foo.c.
114 test -d $dst && dst=$dst/`basename $src`
116 # Fix files in both src and dst, for the sake
117 # of a clean comparison.
118 srctmp=$TMPDIR/`basename $src`
120 test -r $dst && fixfile $dst $dsttmp
122 # if src was executable, make dst executable, to placate git.
123 test -x $src && chmod a+x $dst
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