From 822f5840c0f498e33829a0a00f383d9be3a7e913 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Wed, 30 Sep 2015 16:01:14 -0700 Subject: [PATCH] Only use a fixed timestamp when packaging. [1] changed to use a fixed timestamp for all the generated images (either the one under $ANDROID_PRODUCT_OUT/ or the one added into the target_files zip). It makes 'adb sync' after 'fastboot flashall' to resync all the files. This CL changes to use a fixed timestamp only when packaging into the target_files zip. [1]: commit 052ae3542be93d30108e742c5c21d5c45d9b7cf8 Bug: 24377993 Bug: 24536411 Change-Id: I209318966109fd4902468dfe96caf777464f9fe1 --- tools/releasetools/add_img_to_target_files.py | 19 +++++++++++++++++++ tools/releasetools/build_image.py | 10 ++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py index bc2667d16..6bdb9d1c6 100755 --- a/tools/releasetools/add_img_to_target_files.py +++ b/tools/releasetools/add_img_to_target_files.py @@ -28,6 +28,7 @@ if sys.hexversion < 0x02070000: print >> sys.stderr, "Python 2.7 or newer is required." sys.exit(1) +import datetime import errno import os import shutil @@ -120,6 +121,12 @@ def CreateImage(input_dir, info_dict, what, block_list=None): if fstab: image_props["fs_type"] = fstab["/" + what].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) + if what == "system": fs_config_prefix = "" else: @@ -166,6 +173,12 @@ def AddUserdata(output_zip, prefix="IMAGES/"): 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) + # The name of the directory it is making an image out of matters to # mkyaffs2image. So we create a temp dir, and within it we create an # empty dir named "data", or a symlink to the DATA dir, @@ -210,6 +223,12 @@ def AddCache(output_zip, prefix="IMAGES/"): 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) + # The name of the directory it is making an image out of matters to # mkyaffs2image. So we create a temp dir, and within it we create an # empty dir named "cache", and build the image from that. diff --git a/tools/releasetools/build_image.py b/tools/releasetools/build_image.py index e1488dc9e..e5e2a243d 100755 --- a/tools/releasetools/build_image.py +++ b/tools/releasetools/build_image.py @@ -20,7 +20,6 @@ Build image output_image_file from input_directory and properties_file. Usage: build_image input_directory properties_file output_image_file """ -import datetime import os import os.path import re @@ -387,11 +386,10 @@ def ImagePropFromGlobalDict(glob_dict, mount_point): """ d = {} - # Use a fixed timestamp (01/01/2009) for all the files in an image. - # Bug: 24377993 - epoch = datetime.datetime.fromtimestamp(0) - timestamp = (datetime.datetime(2009, 1, 1) - epoch).total_seconds() - d["timestamp"] = int(timestamp) + if "build.prop" in glob_dict: + bp = glob_dict["build.prop"] + if "ro.build.date.utc" in bp: + d["timestamp"] = bp["ro.build.date.utc"] def copy_prop(src_p, dest_p): if src_p in glob_dict: