Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1de6f32 authored by Tao Bao's avatar Tao Bao
Browse files

releasetools: Drop the support for fstab_version 1.

fstab_version is defined by RECOVERY_FSTAB_VERSION in
bootable/recovery. We have moved to fstab_version 2 since commit
f35d1cef7c19db975a1295e8c23c7fb8bd2489f9 (landed into JB MR2).

Drop the support for fstab_version 1, since we won't run the latest OTA
script over a JB target_files zip.

Test: No impact on building full/incremental OTAs.
Change-Id: Ia87c4e7da6c5e71ce0908fca2e4f1ad1c06ba869
parent 59978ab6
Loading
Loading
Loading
Loading
+39 −76
Original line number Diff line number Diff line
@@ -153,9 +153,7 @@ def LoadInfoDict(input_file, input_dir=None):
    raise ValueError("can't find META/misc_info.txt in input target-files")

  assert "recovery_api_version" in d

  if "fstab_version" not in d:
    d["fstab_version"] = "1"
  assert "fstab_version" in d

  # A few properties are stored as links to the files in the out/ directory.
  # It works fine with the build system. However, they are no longer available
@@ -251,6 +249,7 @@ def LoadInfoDict(input_file, input_dir=None):
  d["build.prop"] = LoadBuildProp(read_helper)
  return d


def LoadBuildProp(read_helper):
  try:
    data = read_helper("SYSTEM/build.prop")
@@ -259,6 +258,7 @@ def LoadBuildProp(read_helper):
    data = ""
  return LoadDictionaryFromLines(data.split("\n"))


def LoadDictionaryFromLines(lines):
  d = {}
  for line in lines:
@@ -270,15 +270,15 @@ def LoadDictionaryFromLines(lines):
      d[name] = value
  return d


def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
                      system_root_image=False):
  class Partition(object):
    def __init__(self, mount_point, fs_type, device, length, device2, context):
    def __init__(self, mount_point, fs_type, device, length, context):
      self.mount_point = mount_point
      self.fs_type = fs_type
      self.device = device
      self.length = length
      self.device2 = device2
      self.context = context

  try:
@@ -287,65 +287,32 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
    print("Warning: could not find {}".format(recovery_fstab_path))
    data = ""

  if fstab_version == 1:
    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,))
      options = None
      if len(pieces) >= 4:
        if pieces[3].startswith("/"):
          device2 = pieces[3]
          if len(pieces) >= 5:
            options = pieces[4]
        else:
          device2 = None
          options = pieces[3]
      else:
        device2 = None

      mount_point = pieces[0]
      length = 0
      if options:
        options = options.split(",")
        for i in options:
          if i.startswith("length="):
            length = int(i[7:])
          else:
            print("%s: unknown option \"%s\"" % (mount_point, i))

      d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[1],
                                 device=pieces[2], length=length,
                                 device2=device2)
  assert fstab_version == 2

  elif fstab_version == 2:
  d = {}
  for line in data.split("\n"):
    line = line.strip()
    if not line or line.startswith("#"):
      continue

    # <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
    pieces = line.split()
    if len(pieces) != 5:
      raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))

      # Ignore entries that are managed by vold
    # Ignore entries that are managed by vold.
    options = pieces[4]
    if "voldmanaged=" in options:
      continue

      # It's a good line, parse it
    # It's a good line, parse it.
    length = 0
    options = options.split(",")
    for i in options:
      if i.startswith("length="):
        length = int(i[7:])
      else:
          # Ignore all unknown options in the unified fstab
        # Ignore all unknown options in the unified fstab.
        continue

    mount_flags = pieces[3]
@@ -357,11 +324,7 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,

    mount_point = pieces[1]
    d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[2],
                                 device=pieces[0], length=length,
                                 device2=None, context=context)

  else:
    raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
                               device=pieces[0], length=length, context=context)

  # / is used for the system mount point when the root directory is included in
  # system. Other areas assume system is always at "/system" so point /system