progname=$0
package=gnulib
-cvsdatestamp='$Date: 2006-02-13 15:40:25 $'
+cvsdatestamp='$Date: 2006-04-24 11:30:00 $'
last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
Operation modes:
--list print the available module names
--import import the given modules into the current package;
- if no modules are specified, update the
- current package.
+ if no modules are specified, update the current
+ package from the current gnulib
+ --update update the current package, restore files omitted
+ from CVS
--create-testdir create a scratch package with the given modules
--create-megatestdir create a mega scratch package with the given modules
one by one and all together
fi
fi
- # Copy files or make symbolic links. Remove obsolete files.
func_tmpdir
trap 'rm -rf "$tmp"' 0 1 2 3 15
+ # func_dest_tmpfilename file
+ # determines the name of a temporary file (file is relative to destdir).
+ # Sets variable:
+ # - tmpfile absolute filename of the temporary file
+ func_dest_tmpfilename ()
+ {
+ if $doit; then
+ # Put the new contents of $file in a file in the same directory (needed
+ # to guarantee that an 'mv' to "$destdir/$file" works).
+ tmpfile="$destdir/$1.tmp"
+ else
+ # Put the new contents of $file in a file in a temporary directory
+ # (because the directory of "$file" might not exist).
+ tmpfile="$tmp"/`basename "$1"`.tmp
+ fi
+ }
+
+ # Copy files or make symbolic links. Remove obsolete files.
delimiter=' '
for f in $old_files; do
case "$f" in
# Uses parameters f, g, already_present.
func_add_or_update ()
{
- cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
+ func_dest_tmpfilename "$g"
+ cp "$gnulib_dir/$f" "$tmpfile" || func_fatal_error "failed"
if test -n "$lgpl"; then
# Update license.
case "$f" in
lib/*)
sed -e 's/GNU General/GNU Lesser General/g' \
-e 's/version 2\([ ,]\)/version 2.1\1/g' \
- < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
+ < "$gnulib_dir/$f" > "$tmpfile" || func_fatal_error "failed"
;;
esac
fi
if test -f "$destdir/$g"; then
# The file already exists.
- if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
+ if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
: # The file has not changed.
else
# Replace the file.
echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
fi
mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
- if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
else
- mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
+ mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
fi
else
if test -n "$already_present"; then
# frequently that developers don't put autogenerated files into CVS.
if $doit; then
echo "Copying file $g"
- if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
else
- mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
+ mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
fi
else
echo "Copy file $g"
fi
fi
- rm -f "$destdir/$g.tmp"
+ rm -f "$tmpfile"
}
# Then the files that are in new-files, but not in old-files:
sed_take_last_column='s,^.*'"$delimiter"',,'
esac
func_add_or_update
done
- rm -rf "$tmp"
- # Undo the effect of the previous 'trap' command. Some shellology:
- # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
- # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
- # exit); for the others we need to call 'exit' explicitly. The value of $? is
- # 128 + signal number and is set before the trap-registered command is run.
- trap '' 0
- trap 'exit $?' 1 2 3 15
# Command-line invocation printed in a comment in generated gnulib-cache.m4.
actioncmd="gnulib-tool --import"
actioncmd="$actioncmd `echo $specified_modules`"
# Create lib/Makefile.am.
- func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.tmp
+ func_dest_tmpfilename $sourcebase/Makefile.am
+ func_emit_lib_Makefile_am > "$tmpfile"
if test -f "$destdir"/$sourcebase/Makefile.am; then
- if cmp "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am.tmp > /dev/null; then
- rm -f "$destdir"/$sourcebase/Makefile.am.tmp
+ if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
else
if $doit; then
echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
- mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
+ mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
else
echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
- rm -f "$destdir"/$sourcebase/Makefile.am.tmp
+ rm -f "$tmpfile"
fi
fi
else
if $doit; then
echo "Creating $sourcebase/Makefile.am"
- mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
+ mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
else
echo "Create $sourcebase/Makefile.am"
- rm -f "$destdir"/$sourcebase/Makefile.am.tmp
+ rm -f "$tmpfile"
fi
fi
# Create m4/gnulib-cache.m4.
+ func_dest_tmpfilename $m4base/gnulib-cache.m4
(
echo "# Copyright (C) 2004 Free Software Foundation, Inc."
echo "# This file is free software, distributed under the terms of the GNU"
test -z "$lgpl" || echo "gl_LGPL"
test -z "$libtool" || echo "gl_LIBTOOL"
echo "gl_MACRO_PREFIX([$macro_prefix])"
- ) > "$destdir"/$m4base/gnulib-cache.m4.tmp
+ ) > "$tmpfile"
if test -f "$destdir"/$m4base/gnulib-cache.m4; then
- if cmp "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4.tmp > /dev/null; then
- rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
+ if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
else
if $doit; then
echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
- mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
else
echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
if false; then
- cat "$destdir"/$m4base/gnulib-cache.m4.tmp
+ cat "$tmpfile"
echo
echo "# gnulib-cache.m4 ends here"
fi
- rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
+ rm -f "$tmpfile"
fi
fi
else
if $doit; then
echo "Creating $m4base/gnulib-cache.m4"
- mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
else
echo "Create $m4base/gnulib-cache.m4"
- cat "$destdir"/$m4base/gnulib-cache.m4.tmp
- rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
+ cat "$tmpfile"
+ rm -f "$tmpfile"
fi
fi
# Create m4/gnulib-comp.m4.
+ func_dest_tmpfilename $m4base/gnulib-comp.m4
(
echo "# Copyright (C) 2004 Free Software Foundation, Inc."
echo "# This file is free software, distributed under the terms of the GNU"
echo "AC_DEFUN([${macro_prefix}_EARLY],"
echo "["
echo " AC_REQUIRE([AC_PROG_RANLIB])"
- if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
+ if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
echo " AC_REQUIRE([AC_GNU_SOURCE])"
fi
- if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
+ if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
fi
- if grep gl_LOCK "$destdir"/$m4base/*.m4 > /dev/null; then
+ if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
echo " AC_REQUIRE([gl_LOCK])"
fi
echo "])"
echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
echo "$files" | sed -e 's,^, ,'
echo "])"
- ) > "$destdir"/$m4base/gnulib-comp.m4.tmp
+ ) > "$tmpfile"
if test -f "$destdir"/$m4base/gnulib-comp.m4; then
- if cmp "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4.tmp > /dev/null; then
- rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
+ if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
else
if $doit; then
echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
- mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
else
echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
if false; then
- cat "$destdir"/$m4base/gnulib-comp.m4.tmp
+ cat "$tmpfile"
echo
echo "# gnulib-comp.m4 ends here"
fi
- rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
+ rm -f "$tmpfile"
fi
fi
else
if $doit; then
echo "Creating $m4base/gnulib-comp.m4"
- mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
else
echo "Create $m4base/gnulib-comp.m4"
- cat "$destdir"/$m4base/gnulib-comp.m4.tmp
- rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
+ cat "$tmpfile"
+ rm -f "$tmpfile"
fi
fi
if test -n "$inctests"; then
# Create tests/Makefile.am.
- func_emit_tests_Makefile_am > "$destdir"/$testsbase/Makefile.am.tmp
+ func_dest_tmpfilename $testsbase/Makefile.am
+ func_emit_tests_Makefile_am > "$tmpfile"
if test -f "$destdir"/$testsbase/Makefile.am; then
- if cmp "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am.tmp > /dev/null; then
- rm -f "$destdir"/$testsbase/Makefile.am.tmp
+ if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
else
if $doit; then
echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
- mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
+ mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
else
echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
- rm -f "$destdir"/$testsbase/Makefile.am.tmp
+ rm -f "$tmpfile"
fi
fi
else
if $doit; then
echo "Creating $testsbase/Makefile.am"
- mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
+ mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
else
echo "Create $testsbase/Makefile.am"
- rm -f "$destdir"/$testsbase/Makefile.am.tmp
+ rm -f "$tmpfile"
fi
fi
fi
+ rm -rf "$tmp"
+ # Undo the effect of the previous 'trap' command. Some shellology:
+ # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
+ # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
+ # exit); for the others we need to call 'exit' explicitly. The value of $? is
+ # 128 + signal number and is set before the trap-registered command is run.
+ trap '' 0
+ trap 'exit $?' 1 2 3 15
+
echo "Finished."
echo
echo "You may need to add #include directives for the following .h files."
echo "AC_PROG_MAKE_SET"
echo "AC_PROG_RANLIB"
echo
- if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
+ if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "AC_GNU_SOURCE"
echo
fi
- if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
+ if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "gl_USE_SYSTEM_EXTENSIONS"
echo
fi
- if grep gl_LOCK "$testdir"/m4/*.m4 > /dev/null; then
+ if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "gl_LOCK"
echo
fi
echo "AC_PROG_MAKE_SET"
echo "AC_PROG_RANLIB"
echo
- if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
+ if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "AC_GNU_SOURCE"
echo
fi
- if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
+ if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "gl_USE_SYSTEM_EXTENSIONS"
echo
fi
- if grep gl_LOCK "$testdir"/m4/*.m4 > /dev/null; then
+ if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
echo "gl_LOCK"
echo
fi