aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Egorenkov <egorenar-dev@posteo.net>2021-04-10 01:32:44 +0200
committerPaul Spooren <mail@aparcar.org>2021-12-31 17:55:29 +0100
commit3b14ddf8d204ee59533ec76ed6018db01f77d6e7 (patch)
tree5d058e4c1c7c1bd08e5020c8e06d4c8acaff0594
parent4dddb7ca3669e93d4da2b1ca43b8bc22bd007e48 (diff)
downloadupstream-3b14ddf8d204ee59533ec76ed6018db01f77d6e7.tar.gz
upstream-3b14ddf8d204ee59533ec76ed6018db01f77d6e7.tar.bz2
upstream-3b14ddf8d204ee59533ec76ed6018db01f77d6e7.zip
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> (cherry picked from commit 1854aeec4d37079690309dec3171d0864339f73a)
-rw-r--r--package/Makefile6
1 files changed, 4 insertions, 2 deletions
diff --git a/package/Makefile b/package/Makefile
index ec503dc527..209be34674 100644
--- a/package/Makefile
+++ b/package/Makefile
@@ -66,8 +66,10 @@ $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DE
- find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
mkdir -p $(TARGET_DIR)/tmp
- $(call opkg,$(TARGET_DIR)) install \
- $(call opkg_package_files,$(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg))))
+ $(file >$(TMP_DIR)/opkg_install_list,\
+ $(call opkg_package_files,\
+ $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg)))))
+ $(call opkg,$(TARGET_DIR)) install $$(cat $(TMP_DIR)/opkg_install_list)
@for file in $(PACKAGE_INSTALL_FILES); do \
[ -s $$file.flags ] || continue; \
for flag in `cat $$file.flags`; do \