forked from openkylin/platform_build
Merge "resolve merge conflicts of 333df6c
to nyc-mr1-dev-plus-aosp" into nyc-mr1-dev-plus-aosp
This commit is contained in:
commit
dda7ffbd77
|
@ -39,6 +39,7 @@ import zipfile
|
||||||
|
|
||||||
import build_image
|
import build_image
|
||||||
import common
|
import common
|
||||||
|
import sparse_img
|
||||||
|
|
||||||
OPTIONS = common.OPTIONS
|
OPTIONS = common.OPTIONS
|
||||||
|
|
||||||
|
@ -48,6 +49,19 @@ OPTIONS.replace_verity_public_key = False
|
||||||
OPTIONS.replace_verity_private_key = False
|
OPTIONS.replace_verity_private_key = False
|
||||||
OPTIONS.verity_signer_path = None
|
OPTIONS.verity_signer_path = None
|
||||||
|
|
||||||
|
def GetCareMap(which, imgname):
|
||||||
|
"""Generate care_map of system (or vendor) partition"""
|
||||||
|
|
||||||
|
assert which in ("system", "vendor")
|
||||||
|
_, blk_device = common.GetTypeAndDevice("/" + which, OPTIONS.info_dict)
|
||||||
|
|
||||||
|
simg = sparse_img.SparseImage(imgname)
|
||||||
|
care_map_list = []
|
||||||
|
care_map_list.append(blk_device)
|
||||||
|
care_map_list.append(simg.care_map.to_string_raw())
|
||||||
|
return care_map_list
|
||||||
|
|
||||||
|
|
||||||
def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
|
def AddSystem(output_zip, prefix="IMAGES/", recovery_img=None, boot_img=None):
|
||||||
"""Turn the contents of SYSTEM into a system image and store it in
|
"""Turn the contents of SYSTEM into a system image and store it in
|
||||||
output_zip. Returns the name of the system image file."""
|
output_zip. Returns the name of the system image file."""
|
||||||
|
@ -120,13 +134,14 @@ def AddVendor(output_zip, prefix="IMAGES/"):
|
||||||
prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img")
|
prebuilt_path = os.path.join(OPTIONS.input_tmp, prefix, "vendor.img")
|
||||||
if os.path.exists(prebuilt_path):
|
if os.path.exists(prebuilt_path):
|
||||||
print "vendor.img already exists in %s, no need to rebuild..." % (prefix,)
|
print "vendor.img already exists in %s, no need to rebuild..." % (prefix,)
|
||||||
return
|
return prebuilt_path
|
||||||
|
|
||||||
block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map")
|
block_list = common.MakeTempFile(prefix="vendor-blocklist-", suffix=".map")
|
||||||
imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict,
|
imgname = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict,
|
||||||
block_list=block_list)
|
block_list=block_list)
|
||||||
common.ZipWrite(output_zip, imgname, prefix + "vendor.img")
|
common.ZipWrite(output_zip, imgname, prefix + "vendor.img")
|
||||||
common.ZipWrite(output_zip, block_list, prefix + "vendor.map")
|
common.ZipWrite(output_zip, block_list, prefix + "vendor.map")
|
||||||
|
return imgname
|
||||||
|
|
||||||
|
|
||||||
def BuildVendor(input_dir, info_dict, block_list=None):
|
def BuildVendor(input_dir, info_dict, block_list=None):
|
||||||
|
@ -156,8 +171,9 @@ def CreateImage(input_dir, info_dict, what, block_list=None):
|
||||||
|
|
||||||
image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
|
image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
|
||||||
fstab = info_dict["fstab"]
|
fstab = info_dict["fstab"]
|
||||||
if fstab:
|
mount_point = "/" + what
|
||||||
image_props["fs_type"] = fstab["/" + what].fs_type
|
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.
|
# Use a fixed timestamp (01/01/2009) when packaging the image.
|
||||||
# Bug: 24377993
|
# Bug: 24377993
|
||||||
|
@ -402,9 +418,10 @@ def AddImagesToTargetFiles(filename):
|
||||||
system_img_path=system_img_path)
|
system_img_path=system_img_path)
|
||||||
if boot_image:
|
if boot_image:
|
||||||
boot_image.AddToZip(output_zip)
|
boot_image.AddToZip(output_zip)
|
||||||
|
vendor_img_path = None
|
||||||
if has_vendor:
|
if has_vendor:
|
||||||
banner("vendor")
|
banner("vendor")
|
||||||
AddVendor(output_zip)
|
vendor_img_path = AddVendor(output_zip)
|
||||||
if has_system_other:
|
if has_system_other:
|
||||||
banner("system_other")
|
banner("system_other")
|
||||||
AddSystemOther(output_zip)
|
AddSystemOther(output_zip)
|
||||||
|
@ -424,7 +441,19 @@ def AddImagesToTargetFiles(filename):
|
||||||
if os.path.exists(ab_partitions):
|
if os.path.exists(ab_partitions):
|
||||||
with open(ab_partitions, 'r') as f:
|
with open(ab_partitions, 'r') as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
|
# For devices using A/B update, generate care_map for system and vendor
|
||||||
|
# partitions (if present), then write this file to target_files package.
|
||||||
|
care_map_list = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
if line.strip() == "system" and OPTIONS.info_dict.get(
|
||||||
|
"system_verity_block_device", None) is not None:
|
||||||
|
assert os.path.exists(system_img_path)
|
||||||
|
care_map_list += GetCareMap("system", system_img_path)
|
||||||
|
if line.strip() == "vendor" and OPTIONS.info_dict.get(
|
||||||
|
"vendor_verity_block_device", None) is not None:
|
||||||
|
assert os.path.exists(vendor_img_path)
|
||||||
|
care_map_list += GetCareMap("vendor", vendor_img_path)
|
||||||
|
|
||||||
img_name = line.strip() + ".img"
|
img_name = line.strip() + ".img"
|
||||||
prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name)
|
prebuilt_path = os.path.join(OPTIONS.input_tmp, "IMAGES", img_name)
|
||||||
if os.path.exists(prebuilt_path):
|
if os.path.exists(prebuilt_path):
|
||||||
|
@ -448,6 +477,10 @@ def AddImagesToTargetFiles(filename):
|
||||||
img_path = 'IMAGES/' + img_name
|
img_path = 'IMAGES/' + img_name
|
||||||
assert img_path in output_zip.namelist(), "cannot find " + img_name
|
assert img_path in output_zip.namelist(), "cannot find " + img_name
|
||||||
|
|
||||||
|
if care_map_list:
|
||||||
|
file_path = "META/care_map.txt"
|
||||||
|
common.ZipWriteStr(output_zip, file_path, '\n'.join(care_map_list))
|
||||||
|
|
||||||
common.ZipClose(output_zip)
|
common.ZipClose(output_zip)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
|
@ -251,11 +251,18 @@ def LoadInfoDict(input_file, input_dir=None):
|
||||||
makeint("boot_size")
|
makeint("boot_size")
|
||||||
makeint("fstab_version")
|
makeint("fstab_version")
|
||||||
|
|
||||||
if d.get("no_recovery", False) == "true":
|
system_root_image = d.get("system_root_image", None) == "true"
|
||||||
d["fstab"] = None
|
if d.get("no_recovery", None) != "true":
|
||||||
else:
|
recovery_fstab_path = "RECOVERY/RAMDISK/etc/recovery.fstab"
|
||||||
d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
|
d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
|
||||||
d.get("system_root_image", False))
|
recovery_fstab_path, system_root_image)
|
||||||
|
elif d.get("recovery_as_boot", None) == "true":
|
||||||
|
recovery_fstab_path = "BOOT/RAMDISK/etc/recovery.fstab"
|
||||||
|
d["fstab"] = LoadRecoveryFSTab(read_helper, d["fstab_version"],
|
||||||
|
recovery_fstab_path, system_root_image)
|
||||||
|
else:
|
||||||
|
d["fstab"] = None
|
||||||
|
|
||||||
d["build.prop"] = LoadBuildProp(read_helper)
|
d["build.prop"] = LoadBuildProp(read_helper)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
@ -278,7 +285,8 @@ def LoadDictionaryFromLines(lines):
|
||||||
d[name] = value
|
d[name] = value
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def LoadRecoveryFSTab(read_helper, fstab_version, system_root_image=False):
|
def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
|
||||||
|
system_root_image=False):
|
||||||
class Partition(object):
|
class Partition(object):
|
||||||
def __init__(self, mount_point, fs_type, device, length, device2, context):
|
def __init__(self, mount_point, fs_type, device, length, device2, context):
|
||||||
self.mount_point = mount_point
|
self.mount_point = mount_point
|
||||||
|
@ -289,9 +297,9 @@ def LoadRecoveryFSTab(read_helper, fstab_version, system_root_image=False):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = read_helper("RECOVERY/RAMDISK/etc/recovery.fstab")
|
data = read_helper(recovery_fstab_path)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "Warning: could not find RECOVERY/RAMDISK/etc/recovery.fstab"
|
print "Warning: could not find {}".format(recovery_fstab_path)
|
||||||
data = ""
|
data = ""
|
||||||
|
|
||||||
if fstab_version == 1:
|
if fstab_version == 1:
|
||||||
|
|
|
@ -1317,6 +1317,19 @@ def WriteABOTAPackageWithBrilloScript(target_file, output_file,
|
||||||
compress_type=zipfile.ZIP_STORED)
|
compress_type=zipfile.ZIP_STORED)
|
||||||
WriteMetadata(metadata, output_zip)
|
WriteMetadata(metadata, output_zip)
|
||||||
|
|
||||||
|
# If dm-verity is supported for the device, copy contents of care_map
|
||||||
|
# into A/B OTA package.
|
||||||
|
if OPTIONS.info_dict.get("verity") == "true":
|
||||||
|
target_zip = zipfile.ZipFile(target_file, "r")
|
||||||
|
care_map_path = "META/care_map.txt"
|
||||||
|
namelist = target_zip.namelist()
|
||||||
|
if care_map_path in namelist:
|
||||||
|
care_map_data = target_zip.read(care_map_path)
|
||||||
|
common.ZipWriteStr(output_zip, "care_map.txt", care_map_data)
|
||||||
|
else:
|
||||||
|
print "Warning: cannot find care map file in target_file package"
|
||||||
|
common.ZipClose(target_zip)
|
||||||
|
|
||||||
# Sign the whole package to comply with the Android OTA package format.
|
# Sign the whole package to comply with the Android OTA package format.
|
||||||
common.ZipClose(output_zip)
|
common.ZipClose(output_zip)
|
||||||
SignOutput(temp_zip_file.name, output_file)
|
SignOutput(temp_zip_file.name, output_file)
|
||||||
|
|
Loading…
Reference in New Issue