1
0
mirror of https://git.openwrt.org/openwrt/openwrt.git synced 2024-06-16 12:14:01 +02:00
openwrt/package
Alexander Egorenkov 1854aeec4d build: fix opkg install step for large package selection
When the list of packages to be installed in a built image exceeds a certain
number, then 'opkg install' executed for target '$(curdir)/install' in
package/Makefile fails with: /usr/bin/env: Argument list too long.

On Linux, the length of a command-line parameter is limited by
MAX_ARG_STRLEN to max 128 kB.

* https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/binfmts.h#L15
* https://www.in-ulm.de/~mascheck/various/argmax/

To solve the problem, store the package list being passed to 'opkg install'
in a temporary file and use the shell command substitution to pass the
content of the file to 'opkg install'. This guarantees that the length of
the command-line parameters passed to the bash shell is short.

The following bash script demonstrates the problem:
----------------------------------------------------------------------------
count=${1:-1000}

FILES=""
a_file="/home/egorenar/Repositories/openwrt-rel/bin/targets/alpine/generic/packages/base-files_1414-r16464+19-e887049fbb_arm_cortex-a15_neon-vfpv4.ipk"

for i in $(seq 1 $count); do
	FILES="$FILES $a_file"
done

env bash -c "echo $FILES >/dev/null"
echo "$FILES" | wc -c
----------------------------------------------------------------------------

Test run:
----------------------------------------------------------------------------
$ ./test.sh 916
130989
$ ./test.sh 917
./test.sh: line 14: /bin/env: Argument list too long
131132
----------------------------------------------------------------------------

Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net>
[reword commit subject]
Signed-off-by: Paul Spooren <mail@aparcar.org>
2021-05-12 11:13:53 +02:00
..
base-files base-files: upgrade: take down loop and LVM before upgrade 2021-05-05 13:18:43 +01:00
boot ramips: mt7621: Add support for ZyXEL NR7101 2021-05-09 09:15:44 +02:00
devel valgrind: Fix compile problem with MIPS soft float 2021-04-11 23:01:28 +02:00
firmware ipq40xx: add support for MikroTik SXTsq 5 ac 2021-04-29 10:55:07 +02:00
kernel kernel: add kmod-leds-uleds 2021-05-12 10:47:23 +02:00
libs libsemanage: fix pkgconfig paths 2021-04-15 11:54:14 +01:00
network uqmi: fix network registration loop 2021-05-08 12:29:24 +02:00
system rpcd: set correct PKG_SOURCE_DATE 2021-05-10 10:57:09 +01:00
utils busybox: backport fix for CVE-2021-28831 2021-05-02 19:06:02 +02:00
Makefile build: fix opkg install step for large package selection 2021-05-12 11:13:53 +02:00