automake-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[automake-commit] 02/02: python: use xargs -n when uninstalling files


From: Mike Frysinger
Subject: [automake-commit] 02/02: python: use xargs -n when uninstalling files
Date: Wed, 23 Feb 2022 22:08:41 -0500

vapier pushed a commit to branch master
in repository automake.

View the commit online:
https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=38da1d906a33dccb9372132a241f906e3dc2eba5

commit 38da1d906a33dccb9372132a241f906e3dc2eba5
Author: Mike Frysinger <vapier@gentoo.org>
AuthorDate: Thu Feb 17 04:35:03 2022 -0500

    python: use xargs -n when uninstalling files
    
    Fixes automake bug https://bugs.gnu.org/53340.
    
    If the system has xargs, then utilize it to uninstall files to stay
    within long command line limits.  If the system doesn't have xargs,
    fall back to running the remove command one at a time.  Since every
    reasonable system should have `xargs -n`, and POSIX requires it, the
    fallback probably rarely gets used, so don't bother optimizing.
    
    * lib/am/inst-vars.am: Use am__xargs_n to call rm -f on the files.
    * lib/am/python.am: Drop am__base_list and for loop and let the
    am__uninstall_files_from_dir break up the long command lines.
    * m4/init.m4: Call _AM_PROG_XARGS_N.
    * m4/xargsn.m4: New test for `xargs -n`.
---
 lib/am/inst-vars.am |  2 +-
 lib/am/python.am    |  8 ++------
 m4/init.m4          |  1 +
 m4/xargsn.m4        | 20 ++++++++++++++++++++
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/lib/am/inst-vars.am b/lib/am/inst-vars.am
index fd35a7de1..9eb5dc6ee 100644
--- a/lib/am/inst-vars.am
+++ b/lib/am/inst-vars.am
@@ -65,7 +65,7 @@ am__uninstall_files_from_dir = { \
 ## is indeed desired and welcome (better to fail loudly thasn silently).
   { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
   || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
-       $(am__cd) "$$dir" && $(am__rm_f) $$files; }; \
+       $(am__cd) "$$dir" && echo $$files | $(am__xargs_n) 40 $(am__rm_f); }; \
   }
 
 endif %?FIRST%
diff --git a/lib/am/python.am b/lib/am/python.am
index e5e9dfe3b..17b7415dc 100644
--- a/lib/am/python.am
+++ b/lib/am/python.am
@@ -117,12 +117,8 @@ uninstall-%DIR%PYTHON:
 ## This is somewhat tricky, because for newer pythons we have to take PEP-3147
 ## into account.  Avoid exceeding the command-line length limit.
        dir='$(DESTDIR)$(%NDIR%dir)'; \
-       echo "$$py_files" | $(am__pep3147_tweak) | $(am__base_list) | \
-         ( sst=0; \
-           while read files; do \
-             $(am__uninstall_files_from_dir) || sst=$$?; \
-           done; \
-           exit $$sst ) || st=$$?; \
+       files=`echo "$$py_files" | $(am__pep3147_tweak)`; \
+       $(am__uninstall_files_from_dir) || st=$$?; \
        exit $$st
 endif %?INSTALL%
 
diff --git a/m4/init.m4 b/m4/init.m4
index e576b935d..f3abf66c6 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -143,6 +143,7 @@ AC_CONFIG_COMMANDS_PRE(dnl
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 
 AC_REQUIRE([_AM_PROG_RM_F])
+AC_REQUIRE([_AM_PROG_XARGS_N])
 
 dnl The trailing newline in this macro's definition is deliberate, for
 dnl backward compatibility and to allow trailing 'dnl'-style comments
diff --git a/m4/xargsn.m4 b/m4/xargsn.m4
new file mode 100644
index 000000000..8ddf2d8f4
--- /dev/null
+++ b/m4/xargsn.m4
@@ -0,0 +1,20 @@
+##                                                          -*- Autoconf -*-
+# Copyright (C) 2022 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_XARGS_N
+# ----------------
+# Check whether 'xargs -n' works.  It should work everywhere, so the fallback
+# is not optimized at all as we never expect to use it.
+AC_DEFUN([_AM_PROG_XARGS_N],
+[AC_CACHE_CHECK([xargs -n works], am_cv_xargs_n_works, [dnl
+AS_IF([test "`echo 1 2 3 | xargs -n2 echo`" = "1 2
+3"], [am_cv_xargs_n_works=yes], [am_cv_xargs_n_works=no])])
+AS_IF([test "$am_cv_xargs_n_works" = yes], [am__xargs_n='xargs -n'], [dnl
+  am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read 
am__xargs_n_arg; do "$@" "$am__xargs_n_arg"; done; }'
+])dnl
+AC_SUBST(am__xargs_n)
+])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]