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

Commit 3fd79a35 authored by Doug Zongker's avatar Doug Zongker Committed by Android (Google) Code Review
Browse files

Merge "full support for OTA of vendor partitions"

parents e96f961e c8b4e849
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1335,8 +1335,10 @@ endif
	$(hide) ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root)
	@# Zip everything up, preserving symlinks
	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
	@# Run fs_config on all the system, boot ramdisk, and recovery ramdisk files in the zip, and save the output
	@# Run fs_config on all the system, vendor, boot ramdisk,
	@# and recovery ramdisk files in the zip, and save the output
	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt
	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt
	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt
	$(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt
	$(hide) (cd $(zip_root) && zip -q ../$(notdir $@) META/*filesystem_config.txt)
+2 −2
Original line number Diff line number Diff line
@@ -1008,14 +1008,14 @@ def XZ(path):
  p.communicate()
  assert p.returncode == 0, "Couldn't compress patch"

def MakeSystemPatch(source_file, target_file):
def MakePartitionPatch(source_file, target_file, partition):
  with tempfile.NamedTemporaryFile() as output_file:
    XDelta3(source_file.name, target_file.name, output_file.name)
    XZ(output_file.name)
    with open(output_file.name + ".xz") as patch_file:
      patch_data = patch_file.read()
      os.unlink(patch_file.name)
      return File("system.muimg.p", patch_data)
      return File(partition + ".muimg.p", patch_data)

def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,
                      info_dict=None):
+3 −4
Original line number Diff line number Diff line
@@ -203,11 +203,10 @@ class EdifyGenerator(object):
                          p.device, p.length, p.mount_point))

  def WipeBlockDevice(self, partition):
    if partition != "/system":
      raise ValueError(("WipeBlockDevice currently only works "
                        "on /system, not %s\n") % (partition,))
    if partition not in ("/system", "/vendor"):
      raise ValueError(("WipeBlockDevice doesn't work on %s\n") % (partition,))
    fstab = self.info.get("fstab", None)
    size = self.info.get("system_size", None)
    size = self.info.get(partition.lstrip("/") + "_size", None)
    device = fstab[partition].device

    self.script.append('wipe_block_device("%s", %s);' % (device, size))
+40 −50
Original line number Diff line number Diff line
@@ -59,9 +59,21 @@ def AddSystem(output_zip, sparse=True):
  data = BuildSystem(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
  common.ZipWriteStr(output_zip, "system.img", data)


def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
  print "creating system.img..."
  return CreateImage(input_dir, info_dict, "system",
                     sparse=sparse, map_file=map_file)

def AddVendor(output_zip, sparse=True):
  data = BuildVendor(OPTIONS.input_tmp, OPTIONS.info_dict, sparse=sparse)
  common.ZipWriteStr(output_zip, "vendor.img", data)

def BuildVendor(input_dir, info_dict, sparse=True, map_file=None):
  return CreateImage(input_dir, info_dict, "vendor",
                     sparse=sparse, map_file=map_file)


def CreateImage(input_dir, info_dict, what, sparse=True, map_file=None):
  print "creating " + what + ".img..."

  img = tempfile.NamedTemporaryFile()

@@ -69,8 +81,8 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
  # mkyaffs2image.  It wants "system" but we have a directory named
  # "SYSTEM", so create a symlink.
  try:
    os.symlink(os.path.join(input_dir, "SYSTEM"),
               os.path.join(input_dir, "system"))
    os.symlink(os.path.join(input_dir, what.upper()),
               os.path.join(input_dir, what))
  except OSError, e:
      # bogus error on my mac version?
      #   File "./build/tools/releasetools/img_from_target_files", line 86, in AddSystem
@@ -79,22 +91,28 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
    if (e.errno == errno.EEXIST):
      pass

  image_props = build_image.ImagePropFromGlobalDict(info_dict, "system")
  image_props = build_image.ImagePropFromGlobalDict(info_dict, what)
  fstab = info_dict["fstab"]
  if fstab:
    image_props["fs_type" ] = fstab["/system"].fs_type
    image_props["fs_type" ] = fstab["/" + what].fs_type

  if what == "system":
    fs_config_prefix = ""
  else:
    fs_config_prefix = what + "_"

  fs_config = os.path.join(input_dir, "META/filesystem_config.txt")
  fs_config = os.path.join(
      input_dir, "META/" + fs_config_prefix + "filesystem_config.txt")
  if not os.path.exists(fs_config): fs_config = None

  fc_config = os.path.join(input_dir, "BOOT/RAMDISK/file_contexts")
  if not os.path.exists(fc_config): fc_config = None

  succ = build_image.BuildImage(os.path.join(input_dir, "system"),
  succ = build_image.BuildImage(os.path.join(input_dir, what),
                                image_props, img.name,
                                fs_config=fs_config,
                                fc_config=fc_config)
  assert succ, "build system.img image failed"
  assert succ, "build " + what + ".img image failed"

  mapdata = None

@@ -104,7 +122,7 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
  else:
    success, name = build_image.UnsparseImage(img.name, replace=False)
    if not success:
      assert False, "unsparsing system.img failed"
      assert False, "unsparsing " + what + ".img failed"

    if map_file:
      mmap = tempfile.NamedTemporaryFile()
@@ -131,45 +149,6 @@ def BuildSystem(input_dir, info_dict, sparse=True, map_file=None):
    return mapdata, data


def AddVendor(output_zip):
  """Turn the contents of VENDOR into vendor.img and store it in
  output_zip."""

  image_props = build_image.ImagePropFromGlobalDict(OPTIONS.info_dict,
                                                    "vendor")
  # The build system has to explicitly request for vendor.img.
  if "fs_type" not in image_props:
    return

  print "creating vendor.img..."

  img = tempfile.NamedTemporaryFile()

  # The name of the directory it is making an image out of matters to
  # mkyaffs2image.  It wants "vendor" but we have a directory named
  # "VENDOR", so create a symlink or an empty directory if VENDOR does not
  # exist.
  if not os.path.exists(os.path.join(OPTIONS.input_tmp, "vendor")):
    if os.path.exists(os.path.join(OPTIONS.input_tmp, "VENDOR")):
      os.symlink(os.path.join(OPTIONS.input_tmp, "VENDOR"),
                 os.path.join(OPTIONS.input_tmp, "vendor"))
    else:
      os.mkdir(os.path.join(OPTIONS.input_tmp, "vendor"))

  img = tempfile.NamedTemporaryFile()

  fstab = OPTIONS.info_dict["fstab"]
  if fstab:
    image_props["fs_type" ] = fstab["/vendor"].fs_type
  succ = build_image.BuildImage(os.path.join(OPTIONS.input_tmp, "vendor"),
                                image_props, img.name)
  assert succ, "build vendor.img image failed"

  common.CheckSize(img.name, "vendor.img", OPTIONS.info_dict)
  output_zip.write(img.name, "vendor.img")
  img.close()


def AddUserdata(output_zip):
  """Create an empty userdata image and store it in output_zip."""

@@ -287,10 +266,21 @@ def main(argv):
  if recovery_image:
    recovery_image.AddToZip(output_zip)

  def banner(s):
    print "\n\n++++ " + s + " ++++\n\n"

  if not bootable_only:
    banner("AddSystem")
    AddSystem(output_zip)
    try:
      input_zip.getinfo("VENDOR/")
      banner("AddVendor")
      AddVendor(output_zip)
    except KeyError:
      pass   # no vendor partition for this device
    banner("AddUserdata")
    AddUserdata(output_zip)
    banner("AddCache")
    AddCache(output_zip)
    CopyInfo(output_zip)

+339 −216

File changed.

Preview size limit exceeded, changes collapsed.