From a65eb8c7899751f91fd34824f755fa4708cde30b Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Fri, 26 Oct 2012 09:21:28 -0700 Subject: [PATCH] Split to multiple bash commands. This can fix the error "/bin/bash: Argument list too long", if we get a really long apk list. Bug tracker Link: http://code.google.com/p/android/issues/detail?id=38937 (cherry picked from commit d9a88d585f162c5b99c5c6f995c0400fc616bd26) Change-Id: I80cd07cf50cc2b04e4b6aa9d5ecb1faf80d4cb5c --- core/Makefile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/core/Makefile b/core/Makefile index 78b9f1e441..32480f2292 100644 --- a/core/Makefile +++ b/core/Makefile @@ -234,6 +234,12 @@ package-stats: $(PACKAGE_STATS_FILE) # ----------------------------------------------------------------- # Cert-to-package mapping. Used by the post-build signing tools. +# Use a macro to add newline to each echo command +define _apkcerts_echo_with_newline +$(hide) echo $(1) + +endef + name := $(TARGET_PRODUCT) ifeq ($(TARGET_BUILD_TYPE),debug) name := $(name)_debug @@ -248,13 +254,15 @@ $(APKCERTS_FILE): @echo APK certs list: $@ @mkdir -p $(dir $@) @rm -f $@ - $(hide) $(foreach p,$(PACKAGES),\ - $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ - echo 'name="$(p).apk" certificate="EXTERNAL" \ - private_key=""' >> $@;,\ - echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ - private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;)) - # In case $(PACKAGES) is empty. + $(foreach p,$(PACKAGES),\ + $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ + $(call _apkcerts_echo_with_newline,\ + 'name="$(p).apk" certificate="EXTERNAL" \ + private_key=""' >> $@),\ + $(call _apkcerts_echo_with_newline,\ + 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ + private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@))) + # In case value of PACKAGES is empty. $(hide) touch $@ .PHONY: apkcerts-list