[openwrt/openwrt] build: call ipkg-remove using xargs if #args>=512
LEDE Commits
lede-commits at lists.infradead.org
Fri Mar 19 10:49:58 GMT 2021
jow pushed a commit to openwrt/openwrt.git, branch openwrt-19.07:
https://git.openwrt.org/1fcd833c9afe2e990ec656ae15c6ec0386bf9fa8
commit 1fcd833c9afe2e990ec656ae15c6ec0386bf9fa8
Author: Eneas U de Queiroz <cotequeiroz at gmail.com>
AuthorDate: Thu Feb 20 18:29:03 2020 -0300
build: call ipkg-remove using xargs if #args>=512
The wildcard call to clean up luci package (luci*) can pick up over
2,300 files when the full tree is built. Running make package/luci/clean
or a second run of make package/luci/compile would fail with an
'Argument list too long' error.
To avoid that, a maybe_use_xargs function was created that runs the
command straight as usual if the number of arguments is < 512, or saves
the list in a temporary file and feeds it to xargs otherwise.
Signed-off-by: Eneas U de Queiroz <cotequeiroz at gmail.com>
(cherry picked from commit 78d1f3ac61b1740f2a45c40bcde0e83246308a18)
---
include/package-ipkg.mk | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index 00ebb9197f..cbce90a0f1 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -18,10 +18,20 @@ IPKG_REMOVE:= \
IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/opkg
+# 1: command and initial arguments
+# 2: arguments list
+# 3: tmp filename
+define maybe_use_xargs
+ $(if $(word 512,$(2)), \
+ $(file >$(3),$(2)) $(XARGS) $(1) < "$(3)"; rm "$(3)", \
+ $(1) $(2))
+endef
+
# 1: package name
# 2: candidate ipk files
define remove_ipkg_files
- $(if $(strip $(2)),$(IPKG_REMOVE) $(1) $(2))
+ $(if $(strip $(2)), \
+ $(call maybe_use_xargs,$(IPKG_REMOVE) $(1),$(2),$(TMP_DIR)/$(1).in))
endef
# 1: package name
More information about the lede-commits
mailing list