aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2017-03-02 19:19:08 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-03-02 19:19:09 +0000
commitafc0ea14d8e2f35b695b4e576f44d5c78358a589 (patch)
tree312ce990e51c2a965244807c64a5ffc22a8e0a4a
parent6f8e0d06e48e78453a4068c0c46c69398e5aece0 (diff)
parentd1de6f326e150cf9a44fe0f045b1b049fd0c213c (diff)
downloadplatform_build-afc0ea14d8e2f35b695b4e576f44d5c78358a589.tar.gz
platform_build-afc0ea14d8e2f35b695b4e576f44d5c78358a589.tar.bz2
platform_build-afc0ea14d8e2f35b695b4e576f44d5c78358a589.zip
Merge "releasetools: Drop the support for fstab_version 1."
-rw-r--r--tools/releasetools/common.py115
1 files changed, 39 insertions, 76 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 956f0004ae..b57c1b533a 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -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,81 +287,44 @@ 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)
-
- 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
+ assert fstab_version == 2
- # 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
- continue
+ d = {}
+ for line in data.split("\n"):
+ line = line.strip()
+ if not line or line.startswith("#"):
+ continue
- mount_flags = pieces[3]
- # Honor the SELinux context if present.
- context = None
- for i in mount_flags.split(","):
- if i.startswith("context="):
- context = i
+ # <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,))
- 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)
+ # Ignore entries that are managed by vold.
+ options = pieces[4]
+ if "voldmanaged=" in options:
+ continue
- else:
- raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
+ # 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.
+ continue
+
+ mount_flags = pieces[3]
+ # Honor the SELinux context if present.
+ context = None
+ 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, 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