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 "strip-trailing-space" (to strip trailing white space from lines)
18 # and "release" (to use the release version instead of the
19 # development version).
20 # Unrecognized options are ignored.
21 # $VARIABLE expansions are done (with sh eval).
23 # This script is used in gnulib and texinfo; the input files are named
26 # Copyright (C) 2002-2003, 2005, 2007-2021 Free Software Foundation, Inc.
28 # This program is free software: you can redistribute it and/or modify
29 # it under the terms of the GNU General Public License as published by
30 # the Free Software Foundation; either version 3 of the License, or
31 # (at your option) any later version.
33 # This program is distributed in the hope that it will be useful,
34 # but WITHOUT ANY WARRANTY; without even the implied warranty of
35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 # GNU General Public License for more details.
38 # You should have received a copy of the GNU General Public License
39 # along with this program. If not, see <https://www.gnu.org/licenses/>.
41 # Originally written by Karl Berry.
49 #chicken="echo (would)"
52 dsttmp
=$TMPDIR/srclist.dst
54 # Source `dirname $0`/srclistvars.sh first, if it exists.
56 test -r $mydir/srclistvars.sh
&& .
$mydir/srclistvars.sh
60 # sed command to fix the license to be GPL.
62 /^[[:space:]]*#[[:space:]]*Th[ei][ s].* is free software/,/^[[:space:]]*#.*USA\./c\
63 # This program is free software: you can redistribute it and/or modify\
64 # it under the terms of the GNU General Public License as published by\
65 # the Free Software Foundation; either version 3 of the License, or\
66 # (at your option) any later version.\
68 # This program is distributed in the hope that it will be useful,\
69 # but WITHOUT ANY WARRANTY; without even the implied warranty of\
70 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
71 # GNU General Public License for more details.\
73 # You should have received a copy of the GNU General Public License\
74 # along with this program. If not, see <https://www.gnu.org/licenses/>.
76 /Th[ei][ s].* is free software/,/\*\//c\
77 This program is free software: you can redistribute it and/or modify\
78 it under the terms of the GNU General Public License as published by\
79 the Free Software Foundation; either version 3 of the License, or\
80 (at your option) any later version.\
82 This program is distributed in the hope that it will be useful,\
83 but WITHOUT ANY WARRANTY; without even the implied warranty of\
84 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
85 GNU General Public License for more details.\
87 You should have received a copy of the GNU General Public License\
88 along with this program. If not, see <https://www.gnu.org/licenses/>. */
91 # sed command to remove lines containing $Id lines.
92 # Quote the $ so that CVS does not expand it in this script.
93 remove_id_lines
='/[$]Id:.*[$]/d'
95 # $1 is input file, $2 is output.
96 # Remove $Id lines, since they'll differ between source
97 # locations. If $options contains "gpl", change the license to be the
98 # standard GPL. We use this for libc files, et al.
102 sed_command
="$remove_id_lines"
105 *' strip-trailing-space '*)
106 sed_command
="$sed_command; s/[[:space:]]*\$//";;
111 sed_command
="$sed_command; $fixlicense";;
114 sed_command
="$sed_command; s/@include doclicense.texi/@include fdl.texi/";;
117 sed "$sed_command" $1 >$2-t && mv $2-t $2
122 cat |
while read top src dst options
; do
123 #echo "top=$top, src=$src, dst=$dst, options=$options" >&2
124 case $top:$src:$dst in
125 *: ) continue;; # skip lines without last element
126 '#'* ) continue;; # skip comment-only lines
137 if $release && test ! -d $top/.git
; then
138 echo "$0: 'release' option only works with git checkout"
142 # Expand variables and make sure we have an input file.
145 if test ! -r $src; then
146 echo "$0: cannot read $src" >&2
150 # Ignore subdirs in src dir. E.g., if input spec is
151 # src/subdir/foo.c dst
152 # then write destination file dst/foo.c.
154 test -d $dst && dst
=$dst/`basename $src`
157 rev=$
(git
--git-dir=$top/.git describe
--abbrev=0)
158 reltmp
=$TMPDIR/`basename $src1`:$rev
159 git
--git-dir=$top/.git show
$rev:$src1 > $reltmp
160 fixfile
$reltmp $reltmp
163 # Fix files in both src and dst, for the sake
164 # of a clean comparison.
165 srctmp
=$TMPDIR/`basename $src`
167 test -r $dst && fixfile
$dst $dsttmp
169 # if src was executable, make dst executable, to placate git.
170 test -x $src && chmod a
+x
$dst
172 if test ! -e $dst; then
173 echo "## $srctmp $dst # new"
174 $chicken cp -p $srctmp $dst
175 elif $release && cmp -s $reltmp $dsttmp; then
176 $verbose && echo "## $reltmp $dst # unchanged"
177 elif cmp -s $srctmp $dsttmp; then
178 $verbose && echo "## $srctmp $dst # unchanged"
180 echo "## $srctmp $dst # changes"
181 diff -C 2 $dst $srctmp