Merge "Remove copying of TARGET_OUT_RAMDISK to recovery image"
diff --git a/core/binary.mk b/core/binary.mk
index 8d2bb65..427f689 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -91,7 +91,9 @@
 
     ifeq ($(strip $(my_xom)),true)
       ifeq (arm64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
-        my_ldflags += -Wl,-execute-only
+        ifeq ($(my_use_clang_lld),true)
+          my_ldflags += -Wl,-execute-only
+        endif
       endif
     endif
   endif
diff --git a/core/config.mk b/core/config.mk
index 77f5e6b..6b67e1a 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -1006,6 +1006,7 @@
 #     - BOARD_{GROUP}_PARTITION_PARTITION_LIST: the list of partitions that belongs to this group.
 #       If empty, no partitions belong to this group, and the sum of sizes is effectively 0.
 $(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)), \
+    $(eval BOARD_$(group)_SIZE := $(strip $(BOARD_$(group)_SIZE))) \
     $(if $(BOARD_$(group)_SIZE),,$(error BOARD_$(group)_SIZE must not be empty)) \
     $(eval .KATI_READONLY := BOARD_$(group)_SIZE) \
     $(eval BOARD_$(group)_PARTITION_LIST ?=) \
@@ -1032,7 +1033,7 @@
         $(BOARD_$(group)_PARTITION_LIST))
 .KATI_READONLY := BOARD_SUPER_PARTITION_PARTITION_LIST
 
-ifdef BOARD_SUPER_PARTITION_SIZE
+ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
 ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
 
 # The metadata device must be specified manually for retrofitting.
@@ -1075,6 +1076,7 @@
 .KATI_READONLY := BOARD_SUPER_PARTITION_METADATA_DEVICE
 
 $(foreach device,$(call to-upper,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)), \
+    $(eval BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE := $(strip $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))) \
     $(if $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE),, \
         $(error $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE must not be empty))) \
     $(eval .KATI_READONLY := BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
index 698034c..1c9ef64 100644
--- a/core/dex_preopt_libart.mk
+++ b/core/dex_preopt_libart.mk
@@ -173,6 +173,9 @@
 # In the case where LOCAL_ENFORCE_USES_LIBRARIES is true, PRIVATE_DEX2OAT_CLASS_LOADER_CONTEXT
 # contains the normalized path list of the libraries. This makes it easier to conditionally prepend
 # org.apache.http.legacy.impl based on the SDK level if required.
+#
+# Pass --avoid-storing-invocation to make the output deterministics between
+# different products that may have different paths on the command line.
 define dex2oat-one-file
 $(hide) rm -f $(2)
 $(hide) mkdir -p $(dir $(2))
@@ -188,6 +191,7 @@
 source build/make/core/construct_context.sh "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_HOST)" "$(PRIVATE_CONDITIONAL_USES_LIBRARIES_TARGET)" && \
 ,) \
 ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
+	--avoid-storing-invocation \
 	--runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
 	$${class_loader_context_arg} \
 	$${stored_class_loader_context_arg} \
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
index 14955f0..70a934c 100644
--- a/core/dex_preopt_libart_boot.mk
+++ b/core/dex_preopt_libart_boot.mk
@@ -86,6 +86,8 @@
 $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME): PRIVATE_BOOT_IMAGE_FLAGS := $(my_boot_image_flags)
 $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
 # Use dex2oat debug version for better error reporting
+# Pass --avoid-storing-invocation to make the output deterministics between
+# different products that may have different paths on the command line.
 $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(PRELOADED_CLASSES) $(DIRTY_IMAGE_OBJECTS) $(DEX2OAT_DEPENDENCY) $(my_out_boot_image_profile_location)
 	@echo "target dex2oat: $@"
 	@mkdir -p $(dir $@)
@@ -94,6 +96,7 @@
 	@rm -f $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))/*.art
 	@rm -f $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))/*.oat
 	$(hide) $(DEX2OAT_BOOT_IMAGE_LOG_TAGS) $(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
+		--avoid-storing-invocation \
 		--runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
 		$(PRIVATE_BOOT_IMAGE_FLAGS) \
 		$(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
diff --git a/core/main.mk b/core/main.mk
index add8fd9..9fd1c35 100644
--- a/core/main.mk
+++ b/core/main.mk
@@ -410,7 +410,9 @@
 # Typical build; include any Android.mk files we can find.
 #
 
-
+# Before we go and include all of the module makefiles, strip values for easier
+# processing.
+$(call strip-product-vars)
 # Before we go and include all of the module makefiles, mark the PRODUCT_*
 # and ADDITIONAL*PROPERTIES values readonly so that they won't be modified.
 $(call readonly-product-vars)
diff --git a/core/product.mk b/core/product.mk
index fbdd237..8497b28 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -404,7 +404,7 @@
 	WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY
 
 # Logical partitions related variables.
-_product_stash_var_list += \
+_dynamic_partitions_var_list += \
 	BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE \
 	BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE \
 	BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE \
@@ -413,6 +413,9 @@
 	BOARD_SUPER_PARTITION_SIZE \
 	BOARD_SUPER_PARTITION_GROUPS \
 
+_product_stash_var_list += $(_dynamic_partitions_var_list)
+_product_strip_var_list := $(_dynamic_partitions_var_list)
+
 #
 # Mark the variables in _product_stash_var_list as readonly
 #
@@ -423,6 +426,13 @@
  )
 endef
 
+#
+# Strip the variables in _product_strip_var_list
+#
+define strip-product-vars
+$(foreach v,$(_product_strip_var_list),$(eval $(v) := $(strip $($(v)))))
+endef
+
 define add-to-product-copy-files-if-exists
 $(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
 endef
diff --git a/target/product/base_system.mk b/target/product/base_system.mk
index 07fbc3d..2c53a6e 100644
--- a/target/product/base_system.mk
+++ b/target/product/base_system.mk
@@ -52,6 +52,7 @@
     charger \
     cmd \
     com.android.location.provider \
+    com.android.resolv \
     com.android.tzdata \
     ContactsProvider \
     content \
diff --git a/tools/releasetools/ota_from_target_files.py b/tools/releasetools/ota_from_target_files.py
index 7e9677b..7ec8ad8 100755
--- a/tools/releasetools/ota_from_target_files.py
+++ b/tools/releasetools/ota_from_target_files.py
@@ -1745,7 +1745,7 @@
   assert super_block_devices, "No super_block_devices are specified."
 
   replace = {'OTA/super_{}.img'.format(dev): 'IMAGES/{}.img'.format(dev)
-      for dev in super_block_devices}
+             for dev in super_block_devices}
 
   target_file = common.MakeTempFile(prefix="targetfiles-", suffix=".zip")
   shutil.copyfile(input_file, target_file)
@@ -1760,8 +1760,9 @@
   # is a regular update on devices without dynamic partitions support.
   to_delete += [DYNAMIC_PARTITION_INFO]
 
-  # Remove the existing partition images.
+  # Remove the existing partition images as well as the map files.
   to_delete += replace.values()
+  to_delete += ['IMAGES/{}.map'.format(dev) for dev in super_block_devices]
 
   common.ZipDelete(target_file, to_delete)