Re: [PATCH 1/4] libtoolize: simplify file-copying and -linking call-graph.

2011-11-15 Thread Eric Blake
On 11/14/2011 04:04 AM, Gary V. Vaughan wrote:
 This series of changesets are either necessary for, or at least
 make the application of the directory move patches coming in the
 next set as straight forward as possible.
 
 It turns out that we haven't needed to fork a tar process for
 every file-copy for about 4 years now.  With that knowledge it's
 easy to reduce the complexity of the surrounding functions
 somewhat.
 
 I'll apply in 72 hours, along with addressing any feedback I
 get in the mean time.
 
 @@ -112,8 +110,7 @@ M4SH_GETOPTS(
   CP=func_echo_all $CP
   test -n $LN_S  LN_S=func_echo_all $LN_S
   MKDIR=func_echo_all $MKDIR
 - RM=func_echo_all $RM
 - TAR=func_echo_all $TAR],
 + RM=func_echo_all $RM],

My only concern is whether existing projects may have been
(inadvertently) relying on $TAR to be set on their behalf by using libtool.

The reason I ask is that I know of at least one case where a project was
using libtool, but manually setting $RM itself to a value different than
libtool's default, which in turn caused libtool to emit a warning:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=8a93dafc5

That is, dropping $TAR is a user-visible change, so we either need to
document it in NEWS that it is intentional, or we need to keep providing
$TAR (even though we no longer use it) to keep our namespace pollution
constant, all so that users upgrading to newer libtool don't complain
about an undocumented change.

-- 
Eric Blake   ebl...@redhat.com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 1/4] libtoolize: simplify file-copying and -linking call-graph.

2011-11-15 Thread Gary V. Vaughan
Hi Eric,

Thanks again for taking the time to review these patches.

On 16 Nov 2011, at 00:00, Eric Blake wrote:
 On 11/14/2011 04:04 AM, Gary V. Vaughan wrote:
 This series of changesets are either necessary for, or at least
 make the application of the directory move patches coming in the
 next set as straight forward as possible.
 
 It turns out that we haven't needed to fork a tar process for
 every file-copy for about 4 years now.  With that knowledge it's
 easy to reduce the complexity of the surrounding functions
 somewhat.
 
 I'll apply in 72 hours, along with addressing any feedback I
 get in the mean time.
 
 @@ -112,8 +110,7 @@ M4SH_GETOPTS(
  CP=func_echo_all $CP
  test -n $LN_S  LN_S=func_echo_all $LN_S
  MKDIR=func_echo_all $MKDIR
 -RM=func_echo_all $RM
 -TAR=func_echo_all $TAR],
 +RM=func_echo_all $RM],
 
 My only concern is whether existing projects may have been
 (inadvertently) relying on $TAR to be set on their behalf by using libtool.

Libtool's setting of TAR was never exported to the environment, so I'm
pretty sure that its use inside of libtoolize has always been invisible,
(except of course that until recently it wastefully forked a process that
could be influenced by the environment TAR value for every file it
installed).

 The reason I ask is that I know of at least one case where a project was
 using libtool, but manually setting $RM itself to a value different than
 libtool's default, which in turn caused libtool to emit a warning:
 http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=8a93dafc5

That's slightly different in that it means another tool could influence
the behaviour of libtool by setting an environment variable it depends on.

 That is, dropping $TAR is a user-visible change, so we either need to
 document it in NEWS that it is intentional, or we need to keep providing
 $TAR (even though we no longer use it) to keep our namespace pollution
 constant, all so that users upgrading to newer libtool don't complain
 about an undocumented change.

We definitely don't need to keep TAR, because there's never been any way
for another program to access libtoolize's setting.

I can't imagine a scenario where setting TAR in libtoolize's environment
would have worked before removing our reliance on it but broken afterwards.

Am I missing something here?

Cheers,
-- 
Gary V. Vaughan (gary AT gnu DOT org)



[PATCH 1/4] libtoolize: simplify file-copying and -linking call-graph.

2011-11-14 Thread Gary V. Vaughan
This series of changesets are either necessary for, or at least
make the application of the directory move patches coming in the
next set as straight forward as possible.

It turns out that we haven't needed to fork a tar process for
every file-copy for about 4 years now.  With that knowledge it's
easy to reduce the complexity of the surrounding functions
somewhat.

I'll apply in 72 hours, along with addressing any feedback I
get in the mean time.

* libtoolize.m4sh (TAR): Remove.
(func_copy_some_files, func_copy_cb): Remove.
(func_copy): Refactor from all of the above, and simplify. No
need to use $TAR to preserve timestamps when copying, since
we've been running touch right afterwards anyway. Adjust all
callers to use the new argument footprint.
(func_serial_update, func_keyword_update): Delete any pre-
existing destination file when used with `--force' before
calling func_copy, now that the hardcoded special cases are not
in there any more.
(func_install_pkgmacro_subproject)
(func_install_pkgaux_subproject): Use our own file loop -
func_copy subsumes all the checks previously in
func_copy_some_files, but operates on only one file at a time.
(func_install_pkgltdl_files): Similarly, handle aclocal.m4 and
configure special cases here, before calling func_copy.
* tests/libtoolize.at: Make sure we match corrected copying
`configure.ac' output.

Signed-off-by: Gary V. Vaughan g...@gnu.org
---
 libtoolize.m4sh |  186 ++
 tests/libtoolize.at |4 +-
 2 files changed, 69 insertions(+), 121 deletions(-)

diff --git a/libtoolize.m4sh b/libtoolize.m4sh
index c920248..8fc2042 100644
--- a/libtoolize.m4sh
+++ b/libtoolize.m4sh
@@ -67,8 +67,6 @@ AS_INIT[]m4_divert_push([HEADER-COPYRIGHT])
 # GNU @PACKAGE@ home page: @PACKAGE_URL@.
 # General help using GNU software: http://www.gnu.org/gethelp/.
 
-: ${TAR=tar}
-
 PROGRAM=libtoolize
 
 m4_divert_pop
@@ -112,8 +110,7 @@ M4SH_GETOPTS(
CP=func_echo_all $CP
test -n $LN_S  LN_S=func_echo_all $LN_S
MKDIR=func_echo_all $MKDIR
-   RM=func_echo_all $RM
-   TAR=func_echo_all $TAR],
+   RM=func_echo_all $RM],
   [q], [--quiet|--automake],   [], [],
   [v], [--verbose],[], [],
   [],  [--no-warning|--no-warn],   [], [],
@@ -211,134 +208,73 @@ func_whisper_error_hdr ()
 
 func_whisper_once $my_msg_var
 func_error $*
-}
-
-
-# func_copy srcfile destfile [msg_var]
-# A wrapper for func_copy_cb that accepts arguments in the same order
-# as the cp(1) shell command.
-func_copy ()
-{
-$debug_cmd
-
-test -f $1 || \
-  { func_error \`$1' not copied:  not a regular file; return 1; }
-
-func_dirname_and_basename $1
-my_f1=$func_basename_result
-
-if test -d $2; then
-
-  func_copy_cb $my_f1 \
-   `$ECHO $1 | $SED $dirname` $2 $3
-
-else
 
-  # Supporting this would mean changing the timestamp:
-  func_dirname_and_basename $2
-  my_tname=$func_basename_result
-  test X$my_f1 = X$my_tname \
-|| func_fatal_error func_copy() cannot change filename on copy
-
-  func_copy_cb $my_f1 \
-`$ECHO $1 | $SED $dirname` \
-`$ECHO $2 | $SED $dirname` \
-   $3
-
-fi
-
-return $copy_return_status # set in func_copy_cb
+exit_status=$EXIT_FAILURE
 }
 
 
-# func_copy_cb filename srcdir destdir [msg_var]
+# func_copy filename srcdir destdir [msg_var]
 # If option `--copy' was specified, or soft-linking SRCFILE to DESTFILE
 # fails, then try to copy SRCFILE to DESTFILE (making sure to update the
 # timestamp so that a series of files with dependencies can be copied
 # in the right order that their timestamps won't trigger rebuilds).
-func_copy_cb ()
+# MSG_VAR names a variable for use with func_whisper_hdr.
+func_copy ()
 {
 $debug_cmd
 
-my_file=$1
-my_srcdir=$2
-my_destdir=$3
-my_msg_var=$4
-copy_return_status=1
+my_filename=$1
+my_srcdir=$2
+my_destdir=$3
+my_msg_var=$4
+
+my_srcfile=$my_srcdir/$my_filename
+my_destfile=$my_destdir/$my_filename
 
 # Libtool is probably misinstalled if this happens:
-test -f $my_srcdir/$my_file ||
-func_fatal_error \`$my_file' not found in \`$my_srcdir'
+test -f $my_srcfile || {
+  func_whisper_error_hdr $my_msg_var \`$my_srcfile' not found
+  return 1
+}
 
-case $opt_verbose in
-  false) my_copy_msg=file \`$my_destdir/$my_file' ;;
-  *) my_copy_msg=file from \`$my_srcdir/$my_file' ;;
-esac
-func_mkdir_p `$ECHO $my_destdir/$my_file | $SED $dirname`
+# Require --force to remove existing $my_destfile.
+$opt_force  $RM $my_destfile
+test -f $my_destfile  {
+  func_whisper_error_hdr $my_msg_var \
+\`$my_destfile' exists: use \`--force' to overwrite
+  return 1
+}
+
+# Be careful to support `func_copy dir/target srcbase destbase'.
+