Add a check that the staging directories don't...
...contain extra files after an installclean. Bug: 205632228 Test: m installclean && m Change-Id: Ib021465d1089a21bc4f43306b1441348baf71f9c
This commit is contained in:
@@ -3439,12 +3439,22 @@ BUILT_SYSTEMIMAGE :=$= $(systemimage_intermediates)/system.img
|
|||||||
$(systemimage_intermediates)/staging_dir.stamp: $(FULL_SYSTEMIMAGE_DEPS)
|
$(systemimage_intermediates)/staging_dir.stamp: $(FULL_SYSTEMIMAGE_DEPS)
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
define write-file-lines
|
COMPARE_FILE_LIST_TO_STAGING_DIR :=$= $(HOST_OUT_EXECUTABLES)/compare_file_list_to_staging_dir
|
||||||
|
# Args:
|
||||||
|
# $(1): The output file
|
||||||
|
# $(2): The staging directory
|
||||||
|
# $(3): The full list of files that should go into the partition.
|
||||||
|
define create-partition-file-list
|
||||||
|
$(1)-validate: $(1) $(strip $(3)) $(COMPARE_FILE_LIST_TO_STAGING_DIR) $(OUT_DIR)/partitions_were_clean_at_start_of_build.txt
|
||||||
|
rm -f $$@
|
||||||
|
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,$(COMPARE_FILE_LIST_TO_STAGING_DIR) $(OUT_DIR)/partitions_were_clean_at_start_of_build.txt $1 $(2))
|
||||||
|
touch $$@
|
||||||
|
$(1): .KATI_VALIDATIONS := $(1)-validate
|
||||||
$(1):
|
$(1):
|
||||||
@echo Writing $$@
|
@echo Writing $$@
|
||||||
rm -f $$@
|
rm -f $$@
|
||||||
echo -n > $$@
|
touch $$@
|
||||||
$$(foreach f,$(2),echo "$$(f)" >> $$@$$(newline))
|
$$(foreach f,$(subst $(2)/,,$(filter $(2)/%,$(3))),echo "$$(f)" >> $$@$$(newline))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# $(1): output file
|
# $(1): output file
|
||||||
@@ -3462,7 +3472,7 @@ define build-systemimage-target
|
|||||||
exit 1 )
|
exit 1 )
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(systemimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT)/,,$(filter $(TARGET_OUT)/%,$(FULL_SYSTEMIMAGE_DEPS)))))
|
$(eval $(call create-partition-file-list,$(systemimage_intermediates)/file_list.txt,$(TARGET_OUT),$(FULL_SYSTEMIMAGE_DEPS)))
|
||||||
|
|
||||||
ifeq ($(BOARD_AVB_ENABLE),true)
|
ifeq ($(BOARD_AVB_ENABLE),true)
|
||||||
$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
|
$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
|
||||||
@@ -3576,7 +3586,7 @@ INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
|
|||||||
$(INTERNAL_USERIMAGES_DEPS) \
|
$(INTERNAL_USERIMAGES_DEPS) \
|
||||||
$(INTERNAL_USERDATAIMAGE_FILES)
|
$(INTERNAL_USERDATAIMAGE_FILES)
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(userdataimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_DATA)/,,$(filter $(TARGET_OUT_DATA)/%,$(INSTALLED_USERDATAIMAGE_TARGET_DEPS)))))
|
$(eval $(call create-partition-file-list,$(userdataimage_intermediates)/file_list.txt,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS)))
|
||||||
|
|
||||||
$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS) $(userdataimage_intermediates)/file_list.txt
|
$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS) $(userdataimage_intermediates)/file_list.txt
|
||||||
$(build-userdataimage-target)
|
$(build-userdataimage-target)
|
||||||
@@ -3629,7 +3639,7 @@ define build-cacheimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(cacheimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_CACHE)/,,$(filter $(TARGET_OUT_CACHE)/%,$(INTERNAL_CACHEIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(cacheimage_intermediates)/file_list.txt,$(TARGET_OUT_CACHE),$(INTERNAL_CACHEIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
|
INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
|
||||||
@@ -3713,7 +3723,7 @@ define build-systemotherimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(systemotherimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_SYSTEM_OTHER)/,,$(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(INTERNAL_SYSTEMOTHERIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(systemotherimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_OTHER),$(INTERNAL_SYSTEMOTHERIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
|
INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
|
||||||
@@ -3816,7 +3826,7 @@ define build-vendorimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(vendorimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_VENDOR)/,,$(filter $(TARGET_OUT_VENDOR)/%,$(INTERNAL_VENDORIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(vendorimage_intermediates)/file_list.txt,$(TARGET_OUT_VENDOR),$(INTERNAL_VENDORIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
|
INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
|
||||||
@@ -3886,7 +3896,7 @@ define build-productimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(productimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_PRODUCT)/,,$(filter $(TARGET_OUT_PRODUCT)/%,$(INTERNAL_PRODUCTIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(productimage_intermediates)/file_list.txt,$(TARGET_OUT_PRODUCT),$(INTERNAL_PRODUCTIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
|
INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
|
||||||
@@ -3953,7 +3963,7 @@ define build-system_extimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(system_extimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_SYSTEM_EXT)/,,$(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(INTERNAL_SYSTEM_EXTIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(system_extimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_EXT),$(INTERNAL_SYSTEM_EXTIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
|
INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
|
||||||
@@ -4039,7 +4049,7 @@ define build-odmimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(odmimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_ODM)/,,$(filter $(TARGET_OUT_ODM)/%,$(INTERNAL_ODMIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(odmimage_intermediates)/file_list.txt,$(TARGET_OUT_ODM),$(INTERNAL_ODMIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
|
INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
|
||||||
@@ -4105,7 +4115,7 @@ define build-vendor_dlkmimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(vendor_dlkmimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_VENDOR_DLKM)/,,$(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(INTERNAL_VENDOR_DLKMIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(vendor_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_VENDOR_DLKM),$(INTERNAL_VENDOR_DLKMIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
|
INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
|
||||||
@@ -4171,7 +4181,7 @@ define build-odm_dlkmimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(odm_dlkmimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_ODM_DLKM)/,,$(filter $(TARGET_OUT_ODM_DLKM)/%,$(INTERNAL_ODM_DLKMIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(odm_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_ODM_DLKM),$(INTERNAL_ODM_DLKMIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
|
INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
|
||||||
@@ -4239,7 +4249,7 @@ define build-system_dlkmimage-target
|
|||||||
$(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
|
$(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
$(eval $(call write-file-lines,$(system_dlkmimage_intermediates)/file_list.txt,$(subst $(TARGET_OUT_SYSTEM_DLKM)/,,$(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(INTERNAL_SYSTEM_DLKMIMAGE_FILES)))))
|
$(eval $(call create-partition-file-list,$(system_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_DLKM),$(INTERNAL_SYSTEM_DLKMIMAGE_FILES)))
|
||||||
|
|
||||||
# We just build this directly to the install location.
|
# We just build this directly to the install location.
|
||||||
INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
|
INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
|
||||||
|
@@ -18,56 +18,59 @@ package {
|
|||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "generate-self-extracting-archive",
|
name: "generate-self-extracting-archive",
|
||||||
srcs: ["generate-self-extracting-archive.py"],
|
srcs: ["generate-self-extracting-archive.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "post_process_props",
|
name: "post_process_props",
|
||||||
srcs: ["post_process_props.py"],
|
srcs: ["post_process_props.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_test_host {
|
python_test_host {
|
||||||
name: "post_process_props_unittest",
|
name: "post_process_props_unittest",
|
||||||
main: "test_post_process_props.py",
|
main: "test_post_process_props.py",
|
||||||
srcs: [
|
srcs: [
|
||||||
"post_process_props.py",
|
"post_process_props.py",
|
||||||
"test_post_process_props.py",
|
"test_post_process_props.py",
|
||||||
],
|
],
|
||||||
test_config: "post_process_props_unittest.xml",
|
test_config: "post_process_props_unittest.xml",
|
||||||
test_suites: ["general-tests"],
|
test_suites: ["general-tests"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "extract_kernel",
|
name: "extract_kernel",
|
||||||
srcs: ["extract_kernel.py"],
|
srcs: ["extract_kernel.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
genrule_defaults {
|
genrule_defaults {
|
||||||
name: "extract_kernel_release_defaults",
|
name: "extract_kernel_release_defaults",
|
||||||
tools: ["extract_kernel", "lz4"],
|
tools: [
|
||||||
out: ["kernel_release.txt"],
|
"extract_kernel",
|
||||||
cmd: "$(location) --tools lz4:$(location lz4) --input $(in) --output-release > $(out)"
|
"lz4",
|
||||||
|
],
|
||||||
|
out: ["kernel_release.txt"],
|
||||||
|
cmd: "$(location) --tools lz4:$(location lz4) --input $(in) --output-release > $(out)",
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_binary_host {
|
cc_binary_host {
|
||||||
name: "build-runfiles",
|
name: "build-runfiles",
|
||||||
srcs: ["build-runfiles.cc"],
|
srcs: ["build-runfiles.cc"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "check_radio_versions",
|
name: "check_radio_versions",
|
||||||
srcs: ["check_radio_versions.py"],
|
srcs: ["check_radio_versions.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "check_elf_file",
|
name: "check_elf_file",
|
||||||
srcs: ["check_elf_file.py"],
|
srcs: ["check_elf_file.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
name: "generate_gts_shared_report",
|
name: "generate_gts_shared_report",
|
||||||
srcs: ["generate_gts_shared_report.py"],
|
srcs: ["generate_gts_shared_report.py"],
|
||||||
}
|
}
|
||||||
|
|
||||||
python_binary_host {
|
python_binary_host {
|
||||||
@@ -77,10 +80,20 @@ python_binary_host {
|
|||||||
"list_files.py",
|
"list_files.py",
|
||||||
],
|
],
|
||||||
version: {
|
version: {
|
||||||
py3: {
|
py3: {
|
||||||
embedded_launcher: true,
|
embedded_launcher: true,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
python_binary_host {
|
||||||
|
name: "compare_file_list_to_staging_dir",
|
||||||
|
srcs: ["compare_file_list_to_staging_dir.py"],
|
||||||
|
version: {
|
||||||
|
py3: {
|
||||||
|
embedded_launcher: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
python_test_host {
|
python_test_host {
|
||||||
|
45
tools/compare_file_list_to_staging_dir.py
Executable file
45
tools/compare_file_list_to_staging_dir.py
Executable file
@@ -0,0 +1,45 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('partitions_were_clean_at_start_of_build')
|
||||||
|
parser.add_argument('file_list')
|
||||||
|
parser.add_argument('staging_dir')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
with open(args.partitions_were_clean_at_start_of_build, 'r') as f:
|
||||||
|
contents = f.read().strip()
|
||||||
|
if contents not in ['true', 'false']:
|
||||||
|
sys.exit('failed to read ' + args.partitions_were_clean_at_start_of_build)
|
||||||
|
if contents == 'false':
|
||||||
|
# Since the partitions weren't clean at the start of the build, the test would
|
||||||
|
# arbitrarily fail if we tried to run it. This is only for builds that directly follow
|
||||||
|
# an `m installclean`. (Like most ci builds do)
|
||||||
|
return
|
||||||
|
|
||||||
|
with open(args.file_list, 'r') as f:
|
||||||
|
files_in_file_list = set(f.read().strip().splitlines())
|
||||||
|
|
||||||
|
files_in_staging_dir = set()
|
||||||
|
for root, _, files in os.walk(args.staging_dir):
|
||||||
|
for f in files:
|
||||||
|
fullpath = os.path.join(root, f)
|
||||||
|
files_in_staging_dir.add(os.path.relpath(fullpath, args.staging_dir))
|
||||||
|
|
||||||
|
# backslashes aren't allowed in expression parts of f-strings
|
||||||
|
sep = '\n '
|
||||||
|
if files_in_staging_dir != files_in_file_list:
|
||||||
|
sys.exit(f'''Files in staging directory did not match files in file list after an installclean.
|
||||||
|
Note that in order to reproduce this error, you must run `m installclean` directly before `m`.
|
||||||
|
Files in the staging dir but not in the file list:
|
||||||
|
{sep.join(sorted(files_in_staging_dir - files_in_file_list))}
|
||||||
|
Files in the file list but not in the staging dir:
|
||||||
|
{sep.join(sorted(files_in_file_list - files_in_staging_dir))}
|
||||||
|
''')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Reference in New Issue
Block a user