summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-09-18 20:20:03 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2006-09-18 20:20:03 +0000
commit058f319e6d762d4689e339c3d2124f4a3ce4bce4 (patch)
treeced56256f0bc498caa3bae591fb1cdab947c210c
parent87353aebd86689802e8dafd195891e88c28ba37c (diff)
downloadcoreutils-058f319e6d762d4689e339c3d2124f4a3ce4bce4.tar.xz
* bootstrap (symlink_to_gnulib): New function.
(cp_mark_as_generated): Use it, to prefer symlinks-to-gnulib to copies-of-gnulib. (cp_mark_as_generated, slurp, gnulib_files): Avoid making a copy if it's the same as the old version. (gnulib_files): Add support for this variable (used by Bison).
-rw-r--r--ChangeLog7
-rwxr-xr-xbootstrap106
2 files changed, 85 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index eef235e2f..f2aea9cf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2006-09-18 Paul Eggert <eggert@cs.ucla.edu>
+ * bootstrap (symlink_to_gnulib): New function.
+ (cp_mark_as_generated): Use it, to prefer symlinks-to-gnulib
+ to copies-of-gnulib.
+ (cp_mark_as_generated, slurp, gnulib_files):
+ Avoid making a copy if it's the same as the old version.
+ (gnulib_files): Add support for this variable (used by Bison).
+
* tests/ls/stat-vs-dirent: Fix quoting problem in diagnostic
indicating flaw in kernel. Reword to say that the flaw isn't
serious for coreutils, since the flaw does affect ls -i.
diff --git a/bootstrap b/bootstrap
index b4eec8985..8828a7e5b 100755
--- a/bootstrap
+++ b/bootstrap
@@ -35,7 +35,7 @@ export LC_ALL
# List of gnulib modules needed.
gnulib_modules=
-# Any extra gnulib files needed.
+# Any gnulib files needed that are not in modules.
gnulib_files=
# Translation Project URL, for the registry of all projects
@@ -61,7 +61,7 @@ extract_package_name='
'
package=`sed -n "$extract_package_name" configure.ac` || exit
-# Extra files from gnulib, which are not part of any module yet.
+# Extra files from gnulib, which override files from other sources.
gnulib_extra_files='
build-aux/install-sh
build-aux/missing
@@ -212,27 +212,73 @@ case $SKIP_PO in
fi;;
esac
+symlink_to_gnulib()
+{
+ src=$GNULIB_SRCDIR/$1
+ dst=${2-$1}
+ dot_dots=
+
+ case $src in
+ /*) ;;
+ *)
+ case /$dst/ in
+ *//* | */../* | */./* | /*/*/*/*/*/)
+ echo >&2 "$0: invalid symlink calculation: $src -> $dst"
+ exit 1;;
+ /*/*/*/*/) dot_dots=../../../;;
+ /*/*/*/) dot_dots=../../;;
+ /*/*/) dot_dots=../;;
+ esac;;
+ esac
+
+ test -f "$src" && {
+ test -h "$dst" &&
+ src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
+ dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
+ test "$src_i" = "$dst_i" || {
+ echo "$0: ln -fs $dot_dots$src $dst" &&
+ ln -fs "$dot_dots$src" "$dst"
+ }
+ }
+}
+
cp_mark_as_generated()
{
cp_src=$1
cp_dst=$2
- case $cp_dst in
- *.[ch]) c1='/* '; c2=' */';;
- *.texi) c1='@c '; c2= ;;
- *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
- *) c1= ; c2= ;;
- esac
- if test -z "$c1"; then
- cp "$cp_src" "$cp_dst"
- return
- fi
+ if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
+ symlink_to_gnulib "$cp_dst"
+ else
+ case $cp_dst in
+ *.[ch]) c1='/* '; c2=' */';;
+ *.texi) c1='@c '; c2= ;;
+ *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
+ *) c1= ; c2= ;;
+ esac
- (
- echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2"
- echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2"
- cat "$cp_src"
- ) >> "$cp_dst"
+ if test -z "$c1"; then
+ cmp -s "$cp_src" "$cp_dst" || {
+ echo "$0: cp -f $cp_src $cp_dst" &&
+ cp -f "$cp_src" "$cp_dst"
+ }
+ else
+ # Copy the file first to get proper permissions if it
+ # doesn't already exist. Then overwrite the copy.
+ cp "$cp_src" "$cp_dst-t" &&
+ (
+ echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
+ echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
+ cat "$cp_src"
+ ) > $cp_dst-t &&
+ if cmp -s "$cp_dst-t" "$cp_dst"; then
+ rm -f "$cp_dst-t"
+ else
+ echo "$0: cp $cp_src $cp_dst # with edits" &&
+ mv -f "$cp_dst-t" "$cp_dst"
+ fi
+ fi
+ fi
}
slurp() {
@@ -245,11 +291,14 @@ slurp() {
test "$dir/$file" = "$excluded_file" && continue 2
done
if test $file = Makefile.am; then
- copied=$copied${sep}gnulib.mk; sep=$nl
- echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
- rm -f $dir/gnulib.mk
- sed '/^[^#].*\/intl/s/^/#/' $1/$dir/$file >$dir/gnulib.mk
- elif test -r ${2-no/such/dir}/$dir/$file ||
+ copied=$copied${sep}gnulib.mk; sep=$nl
+ remove_intl='/^[^#].*\/intl/s/^/#/'
+ sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/gnulib.mk || {
+ echo "$0: Copying $1/$dir/$file to $dir/gnulib.mk ..." &&
+ rm -f $dir/gnulib.mk &&
+ sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk
+ }
+ elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
grep -q '^/[^/]*/[0-9]'; then
echo "$0: $dir/$file overrides $1/$dir/$file"
@@ -267,7 +316,6 @@ slurp() {
AC_DEFUN([gl_LOCK_EARLY], [])
' $1/$dir/$file >$dir/$file
else
- rm -f $dir/$file
cp_mark_as_generated $1/$dir/$file $dir/$file
fi
fi || exit
@@ -305,6 +353,10 @@ echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
slurp $bt || exit
+for file in $gnulib_files; do
+ symlink_to_gnulib $file || exit
+done
+
# Import from gettext.
@@ -332,13 +384,11 @@ done
# Get some extra files from gnulib, overriding existing files.
for file in $gnulib_extra_files; do
- src=$GNULIB_SRCDIR/$file
case $file in
- */INSTALL) dest=.;;
- *) dest=$file;;
+ */INSTALL) dst=INSTALL;;
+ *) dst=$file;;
esac
- echo "$0: cp -fp $src $dest" &&
- cp -fp $src $dest || exit
+ symlink_to_gnulib $file $dst || exit
done