Merge "Fix 2009-01-01 timestamps in releasetools to always be UTC"
am: e118d5bc4a
Change-Id: I12c8cc0664306ba116076b3f6d43e1c01fb9120f
This commit is contained in:
@@ -72,10 +72,12 @@ OPTIONS.replace_verity_public_key = False
|
||||
OPTIONS.replace_verity_private_key = False
|
||||
OPTIONS.is_signing = False
|
||||
|
||||
|
||||
# Partitions that should have their care_map added to META/care_map.txt.
|
||||
PARTITIONS_WITH_CARE_MAP = ('system', 'vendor', 'product', 'product-services')
|
||||
|
||||
# Use a fixed timestamp (01/01/2009 00:00:00 UTC) for files when packaging
|
||||
# images. (b/24377993, b/80600931)
|
||||
FIXED_FILE_TIMESTAMP = (datetime.datetime(2009, 1, 1, 0, 0, 0, 0, None)
|
||||
- datetime.datetime.utcfromtimestamp(0)).total_seconds()
|
||||
|
||||
class OutputFile(object):
|
||||
def __init__(self, output_zip, input_dir, prefix, name):
|
||||
@@ -94,7 +96,6 @@ class OutputFile(object):
|
||||
if self._output_zip:
|
||||
common.ZipWrite(self._output_zip, self.name, self._zip_name)
|
||||
|
||||
|
||||
def GetCareMap(which, imgname):
|
||||
"""Returns the care_map string for the given partition.
|
||||
|
||||
@@ -259,11 +260,7 @@ def CreateImage(input_dir, info_dict, what, output_file, block_list=None):
|
||||
if fstab and mount_point in fstab:
|
||||
image_props["fs_type"] = fstab[mount_point].fs_type
|
||||
|
||||
# Use a fixed timestamp (01/01/2009) when packaging the image.
|
||||
# Bug: 24377993
|
||||
epoch = datetime.datetime.fromtimestamp(0)
|
||||
timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds()
|
||||
image_props["timestamp"] = int(timestamp)
|
||||
image_props["timestamp"] = FIXED_FILE_TIMESTAMP
|
||||
|
||||
if what == "system":
|
||||
fs_config_prefix = ""
|
||||
@@ -337,11 +334,7 @@ def AddUserdata(output_zip):
|
||||
|
||||
print("creating userdata.img...")
|
||||
|
||||
# Use a fixed timestamp (01/01/2009) when packaging the image.
|
||||
# Bug: 24377993
|
||||
epoch = datetime.datetime.fromtimestamp(0)
|
||||
timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds()
|
||||
image_props["timestamp"] = int(timestamp)
|
||||
image_props["timestamp"] = FIXED_FILE_TIMESTAMP
|
||||
|
||||
if OPTIONS.info_dict.get("userdata_img_with_data") == "true":
|
||||
user_dir = os.path.join(OPTIONS.input_tmp, "DATA")
|
||||
@@ -483,11 +476,7 @@ def AddCache(output_zip):
|
||||
|
||||
print("creating cache.img...")
|
||||
|
||||
# Use a fixed timestamp (01/01/2009) when packaging the image.
|
||||
# Bug: 24377993
|
||||
epoch = datetime.datetime.fromtimestamp(0)
|
||||
timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds()
|
||||
image_props["timestamp"] = int(timestamp)
|
||||
image_props["timestamp"] = FIXED_FILE_TIMESTAMP
|
||||
|
||||
user_dir = common.MakeTempDir()
|
||||
|
||||
|
@@ -1271,8 +1271,12 @@ def ZipWrite(zip_file, filename, arcname=None, perms=0o644,
|
||||
os.chmod(filename, perms)
|
||||
|
||||
# Use a fixed timestamp so the output is repeatable.
|
||||
epoch = datetime.datetime.fromtimestamp(0)
|
||||
timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds()
|
||||
# Note: Use of fromtimestamp rather than utcfromtimestamp here is
|
||||
# intentional. zip stores datetimes in local time without a time zone
|
||||
# attached, so we need "epoch" but in the local time zone to get 2009/01/01
|
||||
# in the zip archive.
|
||||
local_epoch = datetime.datetime.fromtimestamp(0)
|
||||
timestamp = (datetime.datetime(2009, 1, 1) - local_epoch).total_seconds()
|
||||
os.utime(filename, (timestamp, timestamp))
|
||||
|
||||
zip_file.write(filename, arcname=arcname, compress_type=compress_type)
|
||||
|
Reference in New Issue
Block a user