releasetools: Update the handling of recovery fstab.
First, remove the use of info_dict['fstab'] in add_img_to_target_files.
- info_dict['fstab'] corresponds to recovery fstab
(`/etc/recovery.fstab`), which may differ from the one used for
normal boot.
- When calling build_image.ImagePropFromGlobalDict, we already have the
desired info from global dict (`META/info_dict.txt`).
Second, common.LoadInfoDict now loads recovery fstab only for non-A/B
devices. Because the info is only meaningful for installing non-A/B OTAs
(under recovery mode).
Fixes: 132458722
Test: TreeHugger
Test: Build non-A/B incremental OTAs.
Change-Id: Id23e7b17264c123319fe00b1663d52bfd9b4a5e2
diff --git a/tools/releasetools/add_img_to_target_files.py b/tools/releasetools/add_img_to_target_files.py
index 1a1f6fd..4ba8643 100755
--- a/tools/releasetools/add_img_to_target_files.py
+++ b/tools/releasetools/add_img_to_target_files.py
@@ -317,11 +317,6 @@
logger.info("creating %s.img...", what)
image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
- fstab = info_dict["fstab"]
- mount_point = "/" + what
- if fstab and mount_point in fstab:
- image_props["fs_type"] = fstab[mount_point].fs_type
-
image_props["timestamp"] = FIXED_FILE_TIMESTAMP
if what == "system":
@@ -406,9 +401,6 @@
else:
user_dir = common.MakeTempDir()
- fstab = OPTIONS.info_dict["fstab"]
- if fstab:
- image_props["fs_type"] = fstab["/data"].fs_type
build_image.BuildImage(user_dir, image_props, img.name)
common.CheckSize(img.name, "userdata.img", OPTIONS.info_dict)
@@ -495,10 +487,6 @@
image_props["timestamp"] = FIXED_FILE_TIMESTAMP
user_dir = common.MakeTempDir()
-
- fstab = OPTIONS.info_dict["fstab"]
- if fstab:
- image_props["fs_type"] = fstab["/cache"].fs_type
build_image.BuildImage(user_dir, image_props, img.name)
common.CheckSize(img.name, "cache.img", OPTIONS.info_dict)
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 04c721d..37c03ab 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -393,37 +393,8 @@
makeint("boot_size")
makeint("fstab_version")
- # We changed recovery.fstab path in Q, from ../RAMDISK/etc/recovery.fstab to
- # ../RAMDISK/system/etc/recovery.fstab. LoadInfoDict() has to handle both
- # cases, since it may load the info_dict from an old build (e.g. when
- # generating incremental OTAs from that build).
- system_root_image = d.get("system_root_image") == "true"
- if d.get("no_recovery") != "true":
- recovery_fstab_path = "RECOVERY/RAMDISK/system/etc/recovery.fstab"
- if isinstance(input_file, zipfile.ZipFile):
- if recovery_fstab_path not in input_file.namelist():
- recovery_fstab_path = "RECOVERY/RAMDISK/etc/recovery.fstab"
- else:
- path = os.path.join(input_file, *recovery_fstab_path.split("/"))
- if not os.path.exists(path):
- recovery_fstab_path = "RECOVERY/RAMDISK/etc/recovery.fstab"
- d["fstab"] = LoadRecoveryFSTab(
- read_helper, d["fstab_version"], recovery_fstab_path, system_root_image)
-
- elif d.get("recovery_as_boot") == "true":
- recovery_fstab_path = "BOOT/RAMDISK/system/etc/recovery.fstab"
- if isinstance(input_file, zipfile.ZipFile):
- if recovery_fstab_path not in input_file.namelist():
- recovery_fstab_path = "BOOT/RAMDISK/etc/recovery.fstab"
- else:
- path = os.path.join(input_file, *recovery_fstab_path.split("/"))
- if not os.path.exists(path):
- 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
+ # Load recovery fstab if applicable.
+ d["fstab"] = _FindAndLoadRecoveryFstab(d, input_file, read_helper)
# Tries to load the build props for all partitions with care_map, including
# system and vendor.
@@ -549,6 +520,47 @@
return d
+def _FindAndLoadRecoveryFstab(info_dict, input_file, read_helper):
+ """Finds the path to recovery fstab and loads its contents."""
+ # recovery fstab is only meaningful when installing an update via recovery
+ # (i.e. non-A/B OTA). Skip loading fstab if device used A/B OTA.
+ if info_dict.get('ab_update') == 'true':
+ return None
+
+ # We changed recovery.fstab path in Q, from ../RAMDISK/etc/recovery.fstab to
+ # ../RAMDISK/system/etc/recovery.fstab. This function has to handle both
+ # cases, since it may load the info_dict from an old build (e.g. when
+ # generating incremental OTAs from that build).
+ system_root_image = info_dict.get('system_root_image') == 'true'
+ if info_dict.get('no_recovery') != 'true':
+ recovery_fstab_path = 'RECOVERY/RAMDISK/system/etc/recovery.fstab'
+ if isinstance(input_file, zipfile.ZipFile):
+ if recovery_fstab_path not in input_file.namelist():
+ recovery_fstab_path = 'RECOVERY/RAMDISK/etc/recovery.fstab'
+ else:
+ path = os.path.join(input_file, *recovery_fstab_path.split('/'))
+ if not os.path.exists(path):
+ recovery_fstab_path = 'RECOVERY/RAMDISK/etc/recovery.fstab'
+ return LoadRecoveryFSTab(
+ read_helper, info_dict['fstab_version'], recovery_fstab_path,
+ system_root_image)
+
+ if info_dict.get('recovery_as_boot') == 'true':
+ recovery_fstab_path = 'BOOT/RAMDISK/system/etc/recovery.fstab'
+ if isinstance(input_file, zipfile.ZipFile):
+ if recovery_fstab_path not in input_file.namelist():
+ recovery_fstab_path = 'BOOT/RAMDISK/etc/recovery.fstab'
+ else:
+ path = os.path.join(input_file, *recovery_fstab_path.split('/'))
+ if not os.path.exists(path):
+ recovery_fstab_path = 'BOOT/RAMDISK/etc/recovery.fstab'
+ return LoadRecoveryFSTab(
+ read_helper, info_dict['fstab_version'], recovery_fstab_path,
+ system_root_image)
+
+ return None
+
+
def DumpInfoDict(d):
for k, v in sorted(d.items()):
logger.info("%-25s = (%s) %s", k, type(v).__name__, v)
@@ -629,7 +641,7 @@
cmd.extend(["--salt", avb_salt])
-def GetAvbPartitionArg(partition, image, info_dict = None):
+def GetAvbPartitionArg(partition, image, info_dict=None):
"""Returns the VBMeta arguments for partition.
It sets up the VBMeta argument by including the partition descriptor from the