2 # Check for files in directory $1 being up to date, according to the
3 # list on stdin. Don't actually make any changes, just show the diffs.
5 # Empty (or only whitespace) input lines are ignored.
6 # Lines beginning with # are ignored.
7 # Lines with just one word are ignored.
8 # Otherwise, the line has two or more whitespace-separated words:
9 # the first word is the source directory, which can be a top-level
10 # directory of source archive,
11 # the second word is the source file name relative to the source
13 # the third word is the destination, other optional words are
15 # The possible options are "gpl" (to replace the license with the GPL)
16 # and "doclicense" (to replace @include doclicense.texi with fdl.texi)
17 # and "release" (to use the release version instead of the
18 # development version).
19 # Unrecognized options are ignored.
20 # $VARIABLE expansions are done (with sh eval).
22 # This script is used in gnulib and texinfo; the input files are named
25 # Copyright (C) 2002-2003, 2005, 2007-2019 Free Software Foundation, Inc.
27 # This program is free software: you can redistribute it and/or modify
28 # it under the terms of the GNU General Public License as published by
29 # the Free Software Foundation; either version 3 of the License, or
30 # (at your option) any later version.
32 # This program is distributed in the hope that it will be useful,
33 # but WITHOUT ANY WARRANTY; without even the implied warranty of
34 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 # GNU General Public License for more details.
37 # You should have received a copy of the GNU General Public License
38 # along with this program. If not, see <https://www.gnu.org/licenses/>.
40 # Originally written by Karl Berry.
48 #chicken="echo (would)"
51 dsttmp
=$TMPDIR/srclist.dst
53 # Source `dirname $0`/srclistvars.sh first, if it exists.
55 test -r $mydir/srclistvars.sh
&& .
$mydir/srclistvars.sh
59 # sed command to fix the license to be GPL.
61 /^[[:space:]]*#[[:space:]]*Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./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 3 of the License, or\
65 # (at your option) any later version.\
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\
73 # along with this program. If not, see <https://www.gnu.org/licenses/>.
75 /Th[ei][ s].* is free software/,/\*\//c\
76 This program is free software: you can redistribute it and/or modify\
77 it under the terms of the GNU General Public License as published by\
78 the Free Software Foundation; either version 3 of the License, or\
79 (at your option) any later version.\
81 This program is distributed in the hope that it will be useful,\
82 but WITHOUT ANY WARRANTY; without even the implied warranty of\
83 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
84 GNU General Public License for more details.\
86 You should have received a copy of the GNU General Public License\
87 along with this program. If not, see <https://www.gnu.org/licenses/>. */
90 # sed command to remove lines containing $Id lines.
91 # Quote the $ so that CVS does not expand it in this script.
92 remove_id_lines
='/[$]Id:.*[$]/d'
94 # $1 is the root directory of input file, $2 is input file, $3 is
95 # output. Remove $Id lines, since they'll differ between source
96 # locations. If $options contains "gpl", change the license to be the
97 # standard GPL. We use this for libc files, et al.
101 sed_command
="$remove_id_lines"
105 sed_command
="$sed_command; $fixlicense";;
108 sed_command
="$sed_command; s/@include doclicense.texi/@include fdl.texi/";;
111 sed "$sed_command" $1 >$2-t && mv $2-t $2
116 cat |
while read top src dst options
; do
117 #echo "top=$top, src=$src, dst=$dst, options=$options" >&2
118 case $top:$src:$dst in
119 *: ) continue;; # skip lines without last element
120 '#'* ) continue;; # skip comment-only lines
131 if $release && test ! -d $top/.git
; then
132 echo "$0: 'release' option only works with git checkout"
136 # Expand variables and make sure we have an input file.
139 if test ! -r $src; then
140 echo "$0: cannot read $src" >&2
144 # Ignore subdirs in src dir. E.g., if input spec is
145 # src/subdir/foo.c dst
146 # then write destination file dst/foo.c.
148 test -d $dst && dst
=$dst/`basename $src`
151 rev=$
(git
--git-dir=$top/.git describe
--abbrev=0)
152 reltmp
=$TMPDIR/`basename $src1`:$rev
153 git
--git-dir=$top/.git show
$rev:$src1 > $reltmp
154 fixfile
$reltmp $reltmp
157 # Fix files in both src and dst, for the sake
158 # of a clean comparison.
159 srctmp
=$TMPDIR/`basename $src`
161 test -r $dst && fixfile
$dst $dsttmp
163 # if src was executable, make dst executable, to placate git.
164 test -x $src && chmod a
+x
$dst
166 if test ! -e $dst; then
167 echo "## $srctmp $dst # new"
168 $chicken cp -p $srctmp $dst
169 elif $release && cmp -s $reltmp $dsttmp; then
170 $verbose && echo "## $reltmp $dst # unchanged"
171 elif cmp -s $srctmp $dsttmp; then
172 $verbose && echo "## $srctmp $dst # unchanged"
174 echo "## $srctmp $dst # changes"
175 diff -C 2 $dst $srctmp