From c27d795b6351cbe0a3abba5bfa9cfb466e80ec9d Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Sat, 11 Jul 2020 22:33:30 -0700 Subject: [PATCH] Use unzip -DD We put reproducible timestamps in zip files so that the artifacts are consistent, but that leads to old timestamps in the output directory if they are unzipped as part of the build. Use unzip -DD when unzipping to update the timestamps. Bug: 161015009 Test: touch -d 2020-01-01 ref; find $OUT/system -not -newer ref Change-Id: I6f08ba8695d90a8225cfc04e679755e6296deed0 --- core/Makefile | 2 +- core/dex_preopt_odex_install.mk | 2 +- core/jacoco.mk | 2 +- core/java_prebuilt_internal.mk | 5 +---- core/soong_android_app_set.mk | 2 +- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/Makefile b/core/Makefile index 2f5b6211c..5aad7991d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -265,7 +265,7 @@ $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6) rm -rf $$(PRIVATE_STAGING_DIR) mkdir -p $$(PRIVATE_MODULE_DIR) $(if $(6),\ - unzip -qo -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \ + unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \ mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \ cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \ find $$(PRIVATE_MODULE_DIR) -type f -name *.ko | xargs basename -a > $$(PRIVATE_LOAD_FILE); \ diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk index f738c3e8b..3d5f68aa0 100644 --- a/core/dex_preopt_odex_install.mk +++ b/core/dex_preopt_odex_install.mk @@ -304,7 +304,7 @@ ifdef LOCAL_DEX_PREOPT 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]} ) || \ + ( unzip -qoDD -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) diff --git a/core/jacoco.mk b/core/jacoco.mk index 148bb045e..e8fb89bf6 100644 --- a/core/jacoco.mk +++ b/core/jacoco.mk @@ -47,7 +47,7 @@ $(my_unzipped_timestamp_path): PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR := $(LOCAL_FU $(my_unzipped_timestamp_path): $(LOCAL_FULL_CLASSES_PRE_JACOCO_JAR) rm -rf $(PRIVATE_UNZIPPED_PATH) $@ mkdir -p $(PRIVATE_UNZIPPED_PATH) - unzip -q $(PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR) \ + unzip -qDD $(PRIVATE_FULL_CLASSES_PRE_JACOCO_JAR) \ -d $(PRIVATE_UNZIPPED_PATH) \ $(PRIVATE_INCLUDE_ARGS) (cd $(PRIVATE_UNZIPPED_PATH) && rm -rf $(PRIVATE_EXCLUDE_ARGS)) diff --git a/core/java_prebuilt_internal.mk b/core/java_prebuilt_internal.mk index 95ae2f8d4..6ee1ae1d7 100644 --- a/core/java_prebuilt_internal.mk +++ b/core/java_prebuilt_internal.mk @@ -126,11 +126,8 @@ $(my_src_jar) : .KATI_IMPLICIT_OUTPUTS := $(my_src_proguard_options) $(my_src_jar) : .KATI_IMPLICIT_OUTPUTS += $(my_src_android_manifest) $(my_src_jar) : $(my_src_aar) $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@) $(dir $@)/res - $(hide) unzip -qo -d $(dir $@) $< - # Make sure the extracted classes.jar has a new timestamp. - $(hide) touch $@ + $(hide) unzip -qoDD -d $(dir $@) $< # Make sure the proguard and AndroidManifest.xml files exist - # and have a new timestamp. $(hide) touch $(dir $@)/proguard.txt $(hide) touch $(dir $@)/AndroidManifest.xml diff --git a/core/soong_android_app_set.mk b/core/soong_android_app_set.mk index c88489427..c93bb3fac 100644 --- a/core/soong_android_app_set.mk +++ b/core/soong_android_app_set.mk @@ -26,7 +26,7 @@ endef $(eval $(call extract-master-from-apk-set,$(LOCAL_PREBUILT_MODULE_FILE),$(LOCAL_APK_SET_MASTER_FILE))) # unzip returns 11 it there was nothing to extract, which is expected, # $(LOCAL_APK_SET_MASTER_FILE) has is already there. -LOCAL_POST_INSTALL_CMD := unzip -qo -j -d $(dir $(LOCAL_INSTALLED_MODULE)) \ +LOCAL_POST_INSTALL_CMD := unzip -qoDD -j -d $(dir $(LOCAL_INSTALLED_MODULE)) \ $(LOCAL_PREBUILT_MODULE_FILE) -x $(LOCAL_APK_SET_MASTER_FILE) || [[ $$? -eq 11 ]] $(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))