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 MaybeUseXargs 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 pipes it to xargs otherwise. Signed-off-by: Eneas U de Queiroz <[email protected]> diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk index 5f7f2583a2..f2c31d1d3c 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 MaybeUseXargs + $(if $(word 512,$(2)), \ + $(file >$(3),$(2)) cat "$(3)" | $(XARGS) $(1); rm "$(3)", \ + $(1) $(2)) +endef + # 1: sourcename # 2: package files define RemoveOpkgPackageFiles - $(if $(strip $(2)),$(IPKG_REMOVE) $(1) $(2)) + $(if $(strip $(2)), \ + $(call MaybeUseXargs,$(IPKG_REMOVE) $(1),$(2),$(TMP_DIR)/$(1).in)) endef # 1: package name _______________________________________________ openwrt-devel mailing list [email protected] https://lists.openwrt.org/mailman/listinfo/openwrt-devel
