am 6937a447: Merge "load SYSTEM/build.prop into the info_dict" into jb-mr1-dev

* commit '6937a447429022ea4776418fc47dcd81f57709b2':
  load SYSTEM/build.prop into the info_dict
This commit is contained in:
Doug Zongker 2012-08-17 13:17:46 -07:00 committed by Android Git Automerger
commit 18cb0198ef
2 changed files with 40 additions and 22 deletions

View file

@ -143,6 +143,22 @@ def LoadInfoDict(zip):
makeint("boot_size")
d["fstab"] = LoadRecoveryFSTab(zip)
d["build.prop"] = LoadBuildProp(zip)
return d
def LoadBuildProp(zip):
try:
data = zip.read("SYSTEM/build.prop")
except KeyError:
print "Warning: could not find SYSTEM/build.prop in %s" % zip
data = ""
d = {}
for line in data.split("\n"):
line = line.strip()
if not line or line.startswith("#"): continue
name, value = line.split("=", 1)
d[name] = value
return d
def LoadRecoveryFSTab(zip):

View file

@ -303,8 +303,8 @@ def SignOutput(temp_zip_name, output_zip_name):
whole_file=True)
def AppendAssertions(script, input_zip):
device = GetBuildProp("ro.product.device", input_zip)
def AppendAssertions(script, info_dict):
device = GetBuildProp("ro.product.device", info_dict)
script.AssertDevice(device)
@ -358,9 +358,12 @@ def WriteFullOTAPackage(input_zip, output_zip):
# change very often.
script = edify_generator.EdifyGenerator(3, OPTIONS.info_dict)
metadata = {"post-build": GetBuildProp("ro.build.fingerprint", input_zip),
"pre-device": GetBuildProp("ro.product.device", input_zip),
"post-timestamp": GetBuildProp("ro.build.date.utc", input_zip),
metadata = {"post-build": GetBuildProp("ro.build.fingerprint",
OPTIONS.info_dict),
"pre-device": GetBuildProp("ro.product.device",
OPTIONS.info_dict),
"post-timestamp": GetBuildProp("ro.build.date.utc",
OPTIONS.info_dict),
}
device_specific = common.DeviceSpecificParams(
@ -373,10 +376,10 @@ def WriteFullOTAPackage(input_zip, output_zip):
info_dict=OPTIONS.info_dict)
if not OPTIONS.omit_prereq:
ts = GetBuildProp("ro.build.date.utc", input_zip)
ts = GetBuildProp("ro.build.date.utc", OPTIONS.info_dict)
script.AssertOlderBuild(ts)
AppendAssertions(script, input_zip)
AppendAssertions(script, OPTIONS.info_dict)
device_specific.FullOTA_Assertions()
device_specific.FullOTA_InstallBegin()
@ -446,16 +449,12 @@ def LoadSystemFiles(z):
return out
def GetBuildProp(property, z):
"""Return the fingerprint of the build of a given target-files
ZipFile object."""
bp = z.read("SYSTEM/build.prop")
if not property:
return bp
m = re.search(re.escape(property) + r"=(.*)\n", bp)
if not m:
def GetBuildProp(prop, info_dict):
"""Return the fingerprint of the build of a given target-files info_dict."""
try:
return info_dict.get("build.prop", {})[prop]
except KeyError:
raise common.ExternalError("couldn't find %s in build.prop" % (property,))
return m.group(1).strip()
def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
@ -465,10 +464,13 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
if source_version == 0:
print ("WARNING: generating edify script for a source that "
"can't install it.")
script = edify_generator.EdifyGenerator(source_version, OPTIONS.target_info_dict)
script = edify_generator.EdifyGenerator(source_version,
OPTIONS.target_info_dict)
metadata = {"pre-device": GetBuildProp("ro.product.device", source_zip),
"post-timestamp": GetBuildProp("ro.build.date.utc", target_zip),
metadata = {"pre-device": GetBuildProp("ro.product.device",
OPTIONS.source_info_dict),
"post-timestamp": GetBuildProp("ro.build.date.utc",
OPTIONS.target_info_dict),
}
device_specific = common.DeviceSpecificParams(
@ -522,8 +524,8 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
patch_list.append((tf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
largest_source_size = max(largest_source_size, sf.size)
source_fp = GetBuildProp("ro.build.fingerprint", source_zip)
target_fp = GetBuildProp("ro.build.fingerprint", target_zip)
source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
target_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.target_info_dict)
metadata["pre-build"] = source_fp
metadata["post-build"] = target_fp
@ -550,7 +552,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
# 0.1 for unpacking verbatim files, symlinking, and doing the
# device-specific commands.
AppendAssertions(script, target_zip)
AppendAssertions(script, OPTIONS.target_info_dict)
device_specific.IncrementalOTA_Assertions()
script.Print("Verifying current system...")