support for per-partition fs_type (do not merge)
Include the recovery.fstab file in the recovery image. Remove the global fs_type and partition_type values from the target-files key/value dict, and parse the recovery.fstab file instead to find types for each partition. Change-Id: I35ee2dd0989441dc2a704b63c1b32e598049acb5
This commit is contained in:
@@ -601,11 +601,16 @@ recovery_resources_common := $(call include-path-for, recovery)/res
|
|||||||
recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
|
recovery_resources_private := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery/res))
|
||||||
recovery_resource_deps := $(shell find $(recovery_resources_common) \
|
recovery_resource_deps := $(shell find $(recovery_resources_common) \
|
||||||
$(recovery_resources_private) -type f)
|
$(recovery_resources_private) -type f)
|
||||||
|
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
|
||||||
|
|
||||||
ifeq ($(recovery_resources_private),)
|
ifeq ($(recovery_resources_private),)
|
||||||
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
|
$(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(recovery_fstab),)
|
||||||
|
$(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE))
|
||||||
|
endif
|
||||||
|
|
||||||
INTERNAL_RECOVERYIMAGE_ARGS := \
|
INTERNAL_RECOVERYIMAGE_ARGS := \
|
||||||
$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
|
$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \
|
||||||
--kernel $(recovery_kernel) \
|
--kernel $(recovery_kernel) \
|
||||||
@@ -663,6 +668,8 @@ $(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \
|
|||||||
cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
|
cp -rf $(recovery_resources_common) $(TARGET_RECOVERY_ROOT_OUT)/
|
||||||
$(foreach item,$(recovery_resources_private), \
|
$(foreach item,$(recovery_resources_private), \
|
||||||
cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
|
cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/)
|
||||||
|
$(foreach item,$(recovery_fstab), \
|
||||||
|
cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab)
|
||||||
cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
|
cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys
|
||||||
cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
|
cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \
|
||||||
> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
|
> $(TARGET_RECOVERY_ROOT_OUT)/default.prop
|
||||||
@@ -1010,15 +1017,6 @@ ifdef BOARD_SYSTEMIMAGE_PARTITION_SIZE
|
|||||||
endif
|
endif
|
||||||
ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
|
ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
|
||||||
$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
|
$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt
|
||||||
endif
|
|
||||||
ifneq (,$(INTERNAL_USERIMAGES_EXT_VARIANT))
|
|
||||||
$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(zip_root)/META/misc_info.txt
|
|
||||||
$(hide) echo "partition_type=EMMC" >> $(zip_root)/META/misc_info.txt
|
|
||||||
@# TODO: where is the right place to get this path from? BoardConfig.mk?
|
|
||||||
$(hide) echo "partition_path=/dev/block/platform/sdhci-tegra.3/by-name/" >> $(zip_root)/META/misc_info.txt
|
|
||||||
else
|
|
||||||
$(hide) echo "fs_type=yaffs2" >> $(zip_root)/META/misc_info.txt
|
|
||||||
$(hide) echo "partition_type=MTD" >> $(zip_root)/META/misc_info.txt
|
|
||||||
endif
|
endif
|
||||||
$(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
|
$(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt
|
||||||
ifdef mkyaffs2_extra_flags
|
ifdef mkyaffs2_extra_flags
|
||||||
|
@@ -72,9 +72,6 @@ def LoadInfoDict(zip):
|
|||||||
# ok if misc_info.txt doesn't exist
|
# ok if misc_info.txt doesn't exist
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if "fs_type" not in d: d["fs_type"] = "yaffs2"
|
|
||||||
if "partition_type" not in d: d["partition_type"] = "MTD"
|
|
||||||
|
|
||||||
# backwards compatibility: These values used to be in their own
|
# backwards compatibility: These values used to be in their own
|
||||||
# files. Look for them, in case we're processing an old
|
# files. Look for them, in case we're processing an old
|
||||||
# target_files zip.
|
# target_files zip.
|
||||||
@@ -123,8 +120,45 @@ def LoadInfoDict(zip):
|
|||||||
makeint("recovery_size")
|
makeint("recovery_size")
|
||||||
makeint("boot_size")
|
makeint("boot_size")
|
||||||
|
|
||||||
|
d["fstab"] = LoadRecoveryFSTab(zip)
|
||||||
|
if not d["fstab"]:
|
||||||
|
if "fs_type" not in d: d["fs_type"] = "yaffs2"
|
||||||
|
if "partition_type" not in d: d["partition_type"] = "MTD"
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def LoadRecoveryFSTab(zip):
|
||||||
|
class Partition(object):
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = zip.read("RECOVERY/RAMDISK/etc/recovery.fstab")
|
||||||
|
except KeyError:
|
||||||
|
# older target-files that doesn't have a recovery.fstab; fall back
|
||||||
|
# to the fs_type and partition_type keys.
|
||||||
|
return
|
||||||
|
|
||||||
|
d = {}
|
||||||
|
for line in data.split("\n"):
|
||||||
|
line = line.strip()
|
||||||
|
if not line or line.startswith("#"): continue
|
||||||
|
pieces = line.split()
|
||||||
|
if not (3 <= len(pieces) <= 4):
|
||||||
|
raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
|
||||||
|
|
||||||
|
p = Partition()
|
||||||
|
p.mount_point = pieces[0]
|
||||||
|
p.fs_type = pieces[1]
|
||||||
|
p.device = pieces[2]
|
||||||
|
if len(pieces) == 4:
|
||||||
|
p.device2 = pieces[3]
|
||||||
|
else:
|
||||||
|
p.device2 = None
|
||||||
|
|
||||||
|
d[p.mount_point] = p
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
def DumpInfoDict(d):
|
def DumpInfoDict(d):
|
||||||
for k, v in sorted(d.items()):
|
for k, v in sorted(d.items()):
|
||||||
print "%-25s = (%s) %s" % (k, type(v).__name__, v)
|
print "%-25s = (%s) %s" % (k, type(v).__name__, v)
|
||||||
@@ -308,12 +342,18 @@ def CheckSize(data, target, info_dict):
|
|||||||
any, for the given target. Raise exception if the data is too big.
|
any, for the given target. Raise exception if the data is too big.
|
||||||
Print a warning if the data is nearing the maximum size."""
|
Print a warning if the data is nearing the maximum size."""
|
||||||
|
|
||||||
fs_type = info_dict.get("fs_type", None)
|
|
||||||
if not fs_type: return
|
|
||||||
|
|
||||||
if target.endswith(".img"): target = target[:-4]
|
if target.endswith(".img"): target = target[:-4]
|
||||||
|
mount_point = "/" + target
|
||||||
|
|
||||||
|
if info_dict["fstab"]:
|
||||||
|
if mount_point == "/userdata": mount_point = "/data"
|
||||||
|
p = info_dict["fstab"][mount_point]
|
||||||
|
fs_type = p.fs_type
|
||||||
|
limit = info_dict.get(p.device + "_size", None)
|
||||||
|
else:
|
||||||
|
fs_type = info_dict.get("fs_type", None)
|
||||||
limit = info_dict.get(target + "_size", None)
|
limit = info_dict.get(target + "_size", None)
|
||||||
if limit is None: return
|
if not fs_type or not limit: return
|
||||||
|
|
||||||
if fs_type == "yaffs2":
|
if fs_type == "yaffs2":
|
||||||
# image size should be increased by 1/64th to account for the
|
# image size should be increased by 1/64th to account for the
|
||||||
|
@@ -21,6 +21,9 @@ class EdifyGenerator(object):
|
|||||||
"""Class to generate scripts in the 'edify' recovery script language
|
"""Class to generate scripts in the 'edify' recovery script language
|
||||||
used from donut onwards."""
|
used from donut onwards."""
|
||||||
|
|
||||||
|
# map recovery.fstab's fs_types to mount/format "partition types"
|
||||||
|
PARTITION_TYPES = { "yaffs2": "MTD", "mtd": "MTD", "ext4": "EMMC" }
|
||||||
|
|
||||||
def __init__(self, version, info):
|
def __init__(self, version, info):
|
||||||
self.script = []
|
self.script = []
|
||||||
self.mounts = set()
|
self.mounts = set()
|
||||||
@@ -131,10 +134,17 @@ class EdifyGenerator(object):
|
|||||||
available on /cache."""
|
available on /cache."""
|
||||||
self.script.append("assert(apply_patch_space(%d));" % (amount,))
|
self.script.append("assert(apply_patch_space(%d));" % (amount,))
|
||||||
|
|
||||||
def Mount(self, what, mount_point):
|
def Mount(self, mount_point):
|
||||||
"""Mount the given 'what' at the given path. 'what' should be a
|
"""Mount the partition with the given mount_point."""
|
||||||
partition name for an MTD partition, or a block device for
|
fstab = self.info.get("fstab", None)
|
||||||
anything else."""
|
if fstab:
|
||||||
|
p = fstab[mount_point]
|
||||||
|
self.script.append('mount("%s", "%s", "%s", "%s");' %
|
||||||
|
(p.fs_type, self.PARTITION_TYPES[p.fs_type],
|
||||||
|
p.device, p.mount_point))
|
||||||
|
self.mounts.add(p.mount_point)
|
||||||
|
else:
|
||||||
|
what = mount_point.lstrip("/")
|
||||||
what = self.info.get("partition_path", "") + what
|
what = self.info.get("partition_path", "") + what
|
||||||
self.script.append('mount("%s", "%s", "%s", "%s");' %
|
self.script.append('mount("%s", "%s", "%s", "%s");' %
|
||||||
(self.info["fs_type"], self.info["partition_type"],
|
(self.info["fs_type"], self.info["partition_type"],
|
||||||
@@ -158,7 +168,16 @@ class EdifyGenerator(object):
|
|||||||
self.script.append('ui_print("%s");' % (message,))
|
self.script.append('ui_print("%s");' % (message,))
|
||||||
|
|
||||||
def FormatPartition(self, partition):
|
def FormatPartition(self, partition):
|
||||||
"""Format the given partition."""
|
"""Format the given partition, specified by its mount point (eg,
|
||||||
|
"/system")."""
|
||||||
|
|
||||||
|
fstab = self.info.get("fstab", None)
|
||||||
|
if fstab:
|
||||||
|
p = fstab[partition]
|
||||||
|
self.script.append('format("%s", "%s", "%s");' %
|
||||||
|
(p.fs_type, self.PARTITION_TYPES[p.fs_type], p.device))
|
||||||
|
else:
|
||||||
|
# older target-files without per-partition types
|
||||||
partition = self.info.get("partition_path", "") + partition
|
partition = self.info.get("partition_path", "") + partition
|
||||||
self.script.append('format("%s", "%s", "%s");' %
|
self.script.append('format("%s", "%s", "%s");' %
|
||||||
(self.info["fs_type"], self.info["partition_type"],
|
(self.info["fs_type"], self.info["partition_type"],
|
||||||
@@ -196,9 +215,27 @@ class EdifyGenerator(object):
|
|||||||
self.script.append(
|
self.script.append(
|
||||||
'write_firmware_image("PACKAGE:%s", "%s");' % (fn, kind))
|
'write_firmware_image("PACKAGE:%s", "%s");' % (fn, kind))
|
||||||
|
|
||||||
def WriteRawImage(self, partition, fn):
|
def WriteRawImage(self, mount_point, fn):
|
||||||
"""Write the given package file into the given partition."""
|
"""Write the given package file into the partition for the given
|
||||||
|
mount point."""
|
||||||
|
|
||||||
|
fstab = self.info["fstab"]
|
||||||
|
if fstab:
|
||||||
|
p = fstab[mount_point]
|
||||||
|
partition_type = self.PARTITION_TYPES[p.fs_type]
|
||||||
|
args = {'device': p.device, 'fn': fn}
|
||||||
|
if partition_type == "MTD":
|
||||||
|
self.script.append(
|
||||||
|
('assert(package_extract_file("%(fn)s", "/tmp/%(device)s.img"),\n'
|
||||||
|
' write_raw_image("/tmp/%(device)s.img", "%(device)s"),\n'
|
||||||
|
' delete("/tmp/%(device)s.img"));') % args)
|
||||||
|
elif partition_type == "EMMC":
|
||||||
|
self.script.append(
|
||||||
|
'package_extract_file("%(fn)s", "%(device)s");' % args)
|
||||||
|
else:
|
||||||
|
raise ValueError("don't know how to write \"%s\" partitions" % (p.fs_type,))
|
||||||
|
else:
|
||||||
|
# backward compatibility with older target-files that lack recovery.fstab
|
||||||
if self.info["partition_type"] == "MTD":
|
if self.info["partition_type"] == "MTD":
|
||||||
self.script.append(
|
self.script.append(
|
||||||
('assert(package_extract_file("%(fn)s", "/tmp/%(partition)s.img"),\n'
|
('assert(package_extract_file("%(fn)s", "/tmp/%(partition)s.img"),\n'
|
||||||
|
@@ -61,9 +61,10 @@ def AddUserdata(output_zip):
|
|||||||
img = tempfile.NamedTemporaryFile()
|
img = tempfile.NamedTemporaryFile()
|
||||||
|
|
||||||
build_command = []
|
build_command = []
|
||||||
if OPTIONS.info_dict.get("fs_type", "").startswith("ext"):
|
if OPTIONS.info_dict["fstab"]["/data"].fs_type.startswith("ext"):
|
||||||
build_command = ["mkuserimg.sh",
|
build_command = ["mkuserimg.sh",
|
||||||
user_dir, img.name, OPTIONS.info_dict["fs_type"], "userdata"]
|
user_dir, img.name,
|
||||||
|
OPTIONS.info_dict["fstab"]["/data"].fs_type, "userdata"]
|
||||||
if "userdata_size" in OPTIONS.info_dict:
|
if "userdata_size" in OPTIONS.info_dict:
|
||||||
build_command.append(str(OPTIONS.info_dict["userdata_size"]))
|
build_command.append(str(OPTIONS.info_dict["userdata_size"]))
|
||||||
else:
|
else:
|
||||||
@@ -108,10 +109,10 @@ def AddSystem(output_zip):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
build_command = []
|
build_command = []
|
||||||
if OPTIONS.info_dict.get("fs_type", "").startswith("ext"):
|
if OPTIONS.info_dict["fstab"]["/system"].fs_type.startswith("ext"):
|
||||||
build_command = ["mkuserimg.sh",
|
build_command = ["mkuserimg.sh",
|
||||||
os.path.join(OPTIONS.input_tmp, "system"), img.name,
|
os.path.join(OPTIONS.input_tmp, "system"), img.name,
|
||||||
OPTIONS.info_dict["fs_type"], "system"]
|
OPTIONS.info_dict["fstab"]["/system"].fs_type, "system"]
|
||||||
if "system_img" in OPTIONS.info_dict:
|
if "system_img" in OPTIONS.info_dict:
|
||||||
build_command.append(str(OPTIONS.info_dict["system_size"]))
|
build_command.append(str(OPTIONS.info_dict["system_size"]))
|
||||||
else:
|
else:
|
||||||
|
@@ -363,10 +363,10 @@ def WriteFullOTAPackage(input_zip, output_zip):
|
|||||||
script.ShowProgress(0.5, 0)
|
script.ShowProgress(0.5, 0)
|
||||||
|
|
||||||
if OPTIONS.wipe_user_data:
|
if OPTIONS.wipe_user_data:
|
||||||
script.FormatPartition("userdata")
|
script.FormatPartition("/data")
|
||||||
|
|
||||||
script.FormatPartition("system")
|
script.FormatPartition("/system")
|
||||||
script.Mount("system", "/system")
|
script.Mount("/system")
|
||||||
script.UnpackPackageDir("recovery", "/system")
|
script.UnpackPackageDir("recovery", "/system")
|
||||||
script.UnpackPackageDir("system", "/system")
|
script.UnpackPackageDir("system", "/system")
|
||||||
|
|
||||||
@@ -387,7 +387,7 @@ def WriteFullOTAPackage(input_zip, output_zip):
|
|||||||
script.ShowProgress(0.2, 0)
|
script.ShowProgress(0.2, 0)
|
||||||
|
|
||||||
script.ShowProgress(0.2, 10)
|
script.ShowProgress(0.2, 10)
|
||||||
script.WriteRawImage("boot", "boot.img")
|
script.WriteRawImage("/boot", "boot.img")
|
||||||
|
|
||||||
script.ShowProgress(0.1, 0)
|
script.ShowProgress(0.1, 0)
|
||||||
device_specific.FullOTA_InstallEnd()
|
device_specific.FullOTA_InstallEnd()
|
||||||
@@ -500,7 +500,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||||||
metadata["pre-build"] = source_fp
|
metadata["pre-build"] = source_fp
|
||||||
metadata["post-build"] = target_fp
|
metadata["post-build"] = target_fp
|
||||||
|
|
||||||
script.Mount("system", "/system")
|
script.Mount("/system")
|
||||||
script.AssertSomeFingerprint(source_fp, target_fp)
|
script.AssertSomeFingerprint(source_fp, target_fp)
|
||||||
|
|
||||||
source_boot = common.File("/tmp/boot.img",
|
source_boot = common.File("/tmp/boot.img",
|
||||||
@@ -564,7 +564,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
|
|||||||
|
|
||||||
if OPTIONS.wipe_user_data:
|
if OPTIONS.wipe_user_data:
|
||||||
script.Print("Erasing user data...")
|
script.Print("Erasing user data...")
|
||||||
script.FormatPartition("userdata")
|
script.FormatPartition("/data")
|
||||||
|
|
||||||
script.Print("Removing unneeded files...")
|
script.Print("Removing unneeded files...")
|
||||||
script.DeleteFiles(["/"+i[0] for i in verbatim_targets] +
|
script.DeleteFiles(["/"+i[0] for i in verbatim_targets] +
|
||||||
|
Reference in New Issue
Block a user