Hide unzip warning when zip file is empty

unzip prints a warning and exits with code 1 when a zip file is empty.
Pipe the output of unzip through grep -v to hide the warning,
using PIPESTATUS to preserve the exit code of unzip, and then
filter out exit codes that are not 0 or 1.

Test: m
Change-Id: If2cf725fc3315d5996d5a7190288df46d84a59e2
This commit is contained in:
Colin Cross 2018-12-19 13:13:13 -08:00
parent 17e9a79fb0
commit cff1cee3f1

View file

@ -253,7 +253,13 @@ ifdef LOCAL_DEX_PREOPT
LOCAL_POST_INSTALL_CMD += &&
endif
LOCAL_POST_INSTALL_CMD += for i in $$(zipinfo -1 $(my_dexpreopt_zip)); do mkdir -p $(PRODUCT_OUT)/$$(dirname $$i); done && unzip -qo -d $(PRODUCT_OUT) $(my_dexpreopt_zip)
LOCAL_POST_INSTALL_CMD += \
for i in $$(zipinfo -1 $(my_dexpreopt_zip)); \
do mkdir -p $(PRODUCT_OUT)/$$(dirname $$i); \
done && \
( unzip -qo -d $(PRODUCT_OUT) $(my_dexpreopt_zip) 2>&1 | grep -v "zipfile is empty"; exit $${PIPESTATUS[0]} ) || \
( code=$$?; if [ $$code -ne 0 -a $$code -ne 1 ]; then exit $$code; fi )
$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
$(LOCAL_INSTALLED_MODULE): $(my_dexpreopt_zip)