am 44281a1f: Add unified fstab support to release tools

* commit '44281a1f3ec99d650595b01b34185e1ffb129c6f':
  Add unified fstab support to release tools
This commit is contained in:
Ken Sumrall 2013-02-23 00:49:39 -08:00 committed by Android Git Automerger
commit 8d27d6d378
1 changed files with 66 additions and 26 deletions

View File

@ -117,6 +117,9 @@ def LoadInfoDict(zip):
# ok if extensions don't exist
pass
if "fstab_version" not in d:
d["fstab_version"] = "1"
try:
data = zip.read("META/imagesizes.txt")
for line in data.split("\n"):
@ -141,8 +144,9 @@ def LoadInfoDict(zip):
makeint("cache_size")
makeint("recovery_size")
makeint("boot_size")
makeint("fstab_version")
d["fstab"] = LoadRecoveryFSTab(zip)
d["fstab"] = LoadRecoveryFSTab(zip, d["fstab_version"])
d["build.prop"] = LoadBuildProp(zip)
return d
@ -161,7 +165,7 @@ def LoadBuildProp(zip):
d[name] = value
return d
def LoadRecoveryFSTab(zip):
def LoadRecoveryFSTab(zip, fstab_version):
class Partition(object):
pass
@ -171,6 +175,7 @@ def LoadRecoveryFSTab(zip):
print "Warning: could not find RECOVERY/RAMDISK/etc/recovery.fstab in %s." % zip
data = ""
if fstab_version == 1:
d = {}
for line in data.split("\n"):
line = line.strip()
@ -205,6 +210,41 @@ def LoadRecoveryFSTab(zip):
print "%s: unknown option \"%s\"" % (p.mount_point, i)
d[p.mount_point] = p
elif fstab_version == 2:
d = {}
for line in data.split("\n"):
line = line.strip()
if not line or line.startswith("#"): continue
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
# It's a good line, parse it
p = Partition()
p.device = pieces[0]
p.mount_point = pieces[1]
p.fs_type = pieces[2]
p.device2 = None
p.length = 0
options = options.split(",")
for i in options:
if i.startswith("length="):
p.length = int(i[7:])
else:
# Ignore all unknown options in the unified fstab
continue
d[p.mount_point] = p
else:
raise ValueError("Unknown fstab_version: \"%d\"" % (fstab_version,))
return d