Merge "releasetools: Drop the support for fstab_version 1."

This commit is contained in:
Treehugger Robot 2017-03-02 19:19:08 +00:00 committed by Gerrit Code Review
commit afc0ea14d8

View file

@ -153,9 +153,7 @@ def LoadInfoDict(input_file, input_dir=None):
raise ValueError("can't find META/misc_info.txt in input target-files") raise ValueError("can't find META/misc_info.txt in input target-files")
assert "recovery_api_version" in d assert "recovery_api_version" in d
assert "fstab_version" in d
if "fstab_version" not in d:
d["fstab_version"] = "1"
# A few properties are stored as links to the files in the out/ directory. # 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 # 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) d["build.prop"] = LoadBuildProp(read_helper)
return d return d
def LoadBuildProp(read_helper): def LoadBuildProp(read_helper):
try: try:
data = read_helper("SYSTEM/build.prop") data = read_helper("SYSTEM/build.prop")
@ -259,6 +258,7 @@ def LoadBuildProp(read_helper):
data = "" data = ""
return LoadDictionaryFromLines(data.split("\n")) return LoadDictionaryFromLines(data.split("\n"))
def LoadDictionaryFromLines(lines): def LoadDictionaryFromLines(lines):
d = {} d = {}
for line in lines: for line in lines:
@ -270,15 +270,15 @@ def LoadDictionaryFromLines(lines):
d[name] = value d[name] = value
return d return d
def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path, def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
system_root_image=False): 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, context):
self.mount_point = mount_point self.mount_point = mount_point
self.fs_type = fs_type self.fs_type = fs_type
self.device = device self.device = device
self.length = length self.length = length
self.device2 = device2
self.context = context self.context = context
try: try:
@ -287,81 +287,44 @@ def LoadRecoveryFSTab(read_helper, fstab_version, recovery_fstab_path,
print("Warning: could not find {}".format(recovery_fstab_path)) print("Warning: could not find {}".format(recovery_fstab_path))
data = "" data = ""
if fstab_version == 1: assert fstab_version == 2
d = {}
for line in data.split("\n"): d = {}
line = line.strip() for line in data.split("\n"):
if not line or line.startswith("#"): line = line.strip()
continue if not line or line.startswith("#"):
pieces = line.split() continue
if not 3 <= len(pieces) <= 4:
raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,)) # <src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
options = None pieces = line.split()
if len(pieces) >= 4: if len(pieces) != 5:
if pieces[3].startswith("/"): raise ValueError("malformed recovery.fstab line: \"%s\"" % (line,))
device2 = pieces[3]
if len(pieces) >= 5: # Ignore entries that are managed by vold.
options = pieces[4] options = pieces[4]
else: if "voldmanaged=" in options:
device2 = None continue
options = pieces[3]
# 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: else:
device2 = None # Ignore all unknown options in the unified fstab.
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)
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
options = pieces[4]
if "voldmanaged=" in options:
continue continue
# It's a good line, parse it mount_flags = pieces[3]
length = 0 # Honor the SELinux context if present.
options = options.split(",") context = None
for i in options: for i in mount_flags.split(","):
if i.startswith("length="): if i.startswith("context="):
length = int(i[7:]) context = i
else:
# Ignore all unknown options in the unified fstab
continue
mount_flags = pieces[3] mount_point = pieces[1]
# Honor the SELinux context if present. d[mount_point] = Partition(mount_point=mount_point, fs_type=pieces[2],
context = None device=pieces[0], length=length, context=context)
for i in mount_flags.split(","):
if i.startswith("context="):
context = i
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,))
# / is used for the system mount point when the root directory is included in # / 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 # system. Other areas assume system is always at "/system" so point /system