From cf821fc963fa74e4875d5d305e24492d9c945044 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 24 Jun 2019 12:39:10 -0700 Subject: [PATCH] Fix an issue in setting up PATH. `PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH` will produce a space separated string due to `foreach`, if $(INTERNAL_USERIMAGES_BINARY_PATHS) has more than one string. We didn't hit the issue in the past because $(INTERNAL_USERIMAGES_BINARY_PATHS) had contained only one path in practice. Test: TreeHugger Change-Id: I74ef4356668af63d871a81f6bfd4c9324aa1d956 --- core/Makefile | 25 +++++++++++++------------ core/tasks/oem_image.mk | 2 +- core/tasks/tools/build_custom_image.mk | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/Makefile b/core/Makefile index 0d83b8101c..690c9c176a 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1328,7 +1328,8 @@ ifneq ($(filter $(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) $(BOARD_PRODUCT_SERVICESI INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG) endif -INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS))) +# Get a colon-separated list of search paths. +INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS)))) ifeq (true,$(PRODUCT_SUPPORTS_VERITY)) INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_METADATA) $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER) @@ -2251,7 +2252,7 @@ define build-systemimage-target @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt $(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \ skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \ || ( mkdir -p $${DIST_DIR}; cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \ @@ -2499,7 +2500,7 @@ define build-userdataimage-target @mkdir -p $(TARGET_OUT_DATA) @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt $(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE)) @@ -2605,7 +2606,7 @@ define build-cacheimage-target @mkdir -p $(TARGET_OUT_CACHE) @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt $(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE)) @@ -2676,7 +2677,7 @@ define build-systemotherimage-target @mkdir -p $(TARGET_OUT_SYSTEM_OTHER) @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt $(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) @@ -2814,7 +2815,7 @@ define build-vendorimage-target $(call create-vendor-odm-symlink) @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt $(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE)) @@ -2869,7 +2870,7 @@ define build-productimage-target @mkdir -p $(TARGET_OUT_PRODUCT) @mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt $(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ ./build/tools/releasetools/build_image.py \ $(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt $(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE)) @@ -2967,7 +2968,7 @@ define build-product_servicesimage-target @mkdir -p $(TARGET_OUT_PRODUCT_SERVICES) @mkdir -p $(product_servicesimage_intermediates) && rm -rf $(product_servicesimage_intermediates)/product_services_image_info.txt $(call generate-image-prop-dictionary, $(product_servicesimage_intermediates)/product_services_image_info.txt,product_services, skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ ./build/tools/releasetools/build_image.py \ $(TARGET_OUT_PRODUCT_SERVICES) $(product_servicesimage_intermediates)/product_services_image_info.txt $(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE)) @@ -3018,7 +3019,7 @@ define build-odmimage-target @mkdir -p $(TARGET_OUT_ODM) @mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt $(call generate-userimage-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ ./build/tools/releasetools/build_image.py \ $(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt $(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT) $(hide) $(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE)) @@ -4105,7 +4106,7 @@ endif $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt) ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) ifdef BUILDING_SYSTEM_IMAGE - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \ build/make/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) endif # BUILDING_SYSTEM_IMAGE endif @@ -4229,7 +4230,7 @@ ifneq ($(BOARD_SUPER_PARTITION_GROUPS),) echo "$(group)_partition_list=$(_group_partition_list)" >> $(zip_root)/META/dynamic_partitions_info.txt;)) endif # BOARD_SUPER_PARTITION_GROUPS @# TODO(b/134525174): Remove `-r` after addressing the issue with recovery patch generation. - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \ build/make/tools/releasetools/add_img_to_target_files -a -r -v -p $(HOST_OUT) $(zip_root) @# Zip everything up, preserving symlinks and placing META/ files first to @# help early validation of the .zip file while uploading it. @@ -4260,7 +4261,7 @@ ifeq ($(build_ota_package),true) # $(1): output file # $(2): additional args define build-ota-package-target -PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ +PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \ build/make/tools/releasetools/ota_from_target_files -v \ --block \ --extracted_input_target_files $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) \ diff --git a/core/tasks/oem_image.mk b/core/tasks/oem_image.mk index e9c506a279..489feeb6e9 100644 --- a/core/tasks/oem_image.mk +++ b/core/tasks/oem_image.mk @@ -34,7 +34,7 @@ $(INSTALLED_OEMIMAGE_TARGET) : $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_OEMIMAGE_F @mkdir -p $(TARGET_OUT_OEM) @mkdir -p $(oemimage_intermediates) && rm -rf $(oemimage_intermediates)/oem_image_info.txt $(call generate-image-prop-dictionary, $(oemimage_intermediates)/oem_image_info.txt,oem,skip_fsck=true) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(TARGET_OUT_OEM) $(oemimage_intermediates)/oem_image_info.txt $@ $(TARGET_OUT) $(hide) $(call assert-max-image-size,$@,$(BOARD_OEMIMAGE_PARTITION_SIZE)) diff --git a/core/tasks/tools/build_custom_image.mk b/core/tasks/tools/build_custom_image.mk index a58019e66d..b0d1a0cac1 100644 --- a/core/tasks/tools/build_custom_image.mk +++ b/core/tasks/tools/build_custom_image.mk @@ -151,7 +151,7 @@ $(my_built_custom_image): $(INTERNAL_USERIMAGES_DEPS) $(my_built_modules) $(my_i # Generate the image. $(if $(filter oem,$(PRIVATE_MOUNT_POINT)), \ $(hide) echo "oem.buildnumber=$(BUILD_NUMBER_FROM_FILE)" >> $(PRIVATE_STAGING_DIR)/oem.prop) - $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + $(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \ build/make/tools/releasetools/build_image.py \ $(PRIVATE_STAGING_DIR) $(PRIVATE_INTERMEDIATES)/image_info.txt $@ $(TARGET_OUT)