[openwrt/openwrt] build: call ipkg-remove using xargs if #args>=512
LEDE Commits
lede-commits at lists.infradead.org
Thu Jul 24 23:42:04 PDT 2025
nick pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/ac9a97e49b8cd46cd19cbfdeb147b3815f5af0ba
commit ac9a97e49b8cd46cd19cbfdeb147b3815f5af0ba
Author: Eric Fahlgren <ericfahlgren at gmail.com>
AuthorDate: Thu Jul 24 10:09:04 2025 -0700
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.
This is an update to current file names and resubmission of
https://lists.openwrt.org/pipermail/openwrt-devel/2020-February/027525.html
Fixes: https://github.com/openwrt/openwrt/issues/19510
Fixes: https://github.com/openwrt/luci/issues/7869
Authored-by: Eneas U de Queiroz <cotequeiroz at gmail.com>
Signed-off-by: Kuan-Yi Li <kyli at abysm.org>
Signed-off-by: Eric Fahlgren <ericfahlgren at gmail.com>
Link: https://github.com/openwrt/openwrt/pull/19516
Signed-off-by: Nick Hainke <vincent at systemli.org>
---
include/package-pack.mk | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/package-pack.mk b/include/package-pack.mk
index f6d90e50ee..14500473c9 100644
--- a/include/package-pack.mk
+++ b/include/package-pack.mk
@@ -18,10 +18,20 @@ define gen_package_wildcard
$(1)$$(if $$(filter -%,$$(ABIV_$(1))),,[^a-z$(if $(CONFIG_USE_APK),,-)])*
endef
+# 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)),$(SCRIPT_DIR)/ipkg-remove $(1) $(2))
+ $(if $(strip $(2)), \
+ $(call maybe_use_xargs,$(SCRIPT_DIR)/ipkg-remove $(1),$(2),$(TMP_DIR)/$(1).in))
endef
# 1: package name
More information about the lede-commits
mailing list