Parse fingerprint and timestamp unconditionally
build_image.py adds `fingerprint` and `timestamp` to the config object
by doing some string processing, but does so only when mount_point is
missing in the input property file. This makes this unavailable to
Soong's android_filesystem modules, which always provide a mount_point
in the property file.
This CL creates a `TryParseFingerprintAndTimestamp` function to make
this logic common to empty and non-empty `mount_point` property files.
Bug: 376539388
Test: lunch aosp_panther-trunk_staging-userdebug
Test: m
out/soong/.intermediates/packages/modules/Virtualization/guest/pvmfw/pvmfw_img/android_arm64_armv8-2a_cortex-a55/pvmfw.img
(a bootimage module) followed by rm repeatedly
Test: sha remains consistent
Change-Id: I602815338d8938cc81ba44d2e9aa1a9ff8afccde
diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py
index 464ad9b..b6c96c4 100755
--- a/tools/releasetools/build_image.py
+++ b/tools/releasetools/build_image.py
@@ -677,6 +677,21 @@
glob_dict["fingerprint"] = fingerprint
return
+def TryParseFingerprintAndTimestamp(glob_dict):
+ """Helper function that parses fingerprint and timestamp from the global dictionary.
+
+ Args:
+ glob_dict: the global dictionary from the build system.
+ """
+ TryParseFingerprint(glob_dict)
+
+ # Set fixed timestamp for building the OTA package.
+ if "use_fixed_timestamp" in glob_dict:
+ glob_dict["timestamp"] = FIXED_FILE_TIMESTAMP
+ if "build.prop" in glob_dict:
+ timestamp = glob_dict["build.prop"].GetProp("ro.build.date.utc")
+ if timestamp:
+ glob_dict["timestamp"] = timestamp
def ImagePropFromGlobalDict(glob_dict, mount_point):
"""Build an image property dictionary from the global dictionary.
@@ -686,15 +701,7 @@
mount_point: such as "system", "data" etc.
"""
d = {}
- TryParseFingerprint(glob_dict)
-
- # Set fixed timestamp for building the OTA package.
- if "use_fixed_timestamp" in glob_dict:
- d["timestamp"] = FIXED_FILE_TIMESTAMP
- if "build.prop" in glob_dict:
- timestamp = glob_dict["build.prop"].GetProp("ro.build.date.utc")
- if timestamp:
- d["timestamp"] = timestamp
+ TryParseFingerprintAndTimestamp(glob_dict)
def copy_prop(src_p, dest_p):
"""Copy a property from the global dictionary.
@@ -730,6 +737,7 @@
"avb_avbtool",
"use_dynamic_partition_size",
"fingerprint",
+ "timestamp",
)
for p in common_props:
copy_prop(p, p)
@@ -992,6 +1000,7 @@
# The caller knows the mount point and provides a dictionary needed by
# BuildImage().
image_properties = glob_dict
+ TryParseFingerprintAndTimestamp(image_properties)
else:
image_filename = os.path.basename(args.out_file)
mount_point = ""