[OpenWrt-Devel] [PATCH 0/2] build: Avoid 'Argument list too long' error

Eneas U de Queiroz cotequeiroz at gmail.com
Wed Feb 19 16:52:10 EST 2020


After building all of the luci packages with all of the translations,
if I either run:
'make package/luci/clean' or 'make package/luci/compile', I get:
make[2]: execvp: /usr/bin/env: Argument list too long
make[2]: *** [../../luci.mk:285: luci-clean] Error 127

This is caused by the call to scripts/ipkg-remove with a list of over
2,300 packages matching a luci* wildcard:
$ ll bin/packages/arm_cortex-a9_vfpv3/luci/luci*.ipk | wc -l
2307

To circumvent this we can use xargs.  However, using echo from the
Makefile results in make calling the shell with the same 2,307 file
names.  The solution is to have make write the list to a file and then
pipe it to xargs.

To avoid creating a file every time, xargs is only used when the number
of files is >=512.

As an optimization, to avoid calling wildcard twice, I've defined a
RemoveOpkgPackageFiles function, and added the check for an empty list
there, so that the call to opkg_package_files would only be done when
the new function was called.

I've put them in separate commits to ease an eventual reversal or 
rejection.

I think that changing the wildcard pattern would be the ideal solution,
but I could not come up with a pattern that works.  My first idea was to
change opkg_package_files,$(1)* to opkg_package_files,$(1)[^a-z-]*, but
it would fail when the package name ends in a number, such as
libnghttp2, ABI is 14, the filename starts with libnhtttp2-14, and
without being able to filter the -, the result is the same:

$ ll bin/packages/arm_cortex-a9_vfpv3/luci/luci-*.ipk | wc -l
2306

Another way out may be have an exception just for luci, which I may do
later, because calling ipkg-remove luci* results in 4,614 runs of
'tar -Ozxf'.

This was compile-tested for mvebu, and checked by adding $(info ...)
tracers to the new functions and to opkg_package_files in
include/feeds.mk.


Eneas U de Queiroz (2):
  build: package-ipkg: avoid calling wildcard twice
  build: call ipkg-remove using xargs if #args>=512

 include/package-ipkg.mk | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list