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

Commit 96f56b6f authored by Dave Langemak's avatar Dave Langemak Committed by Android (Google) Code Review
Browse files

Merge "Revert "Enable incremental builder to find files that moved, and try to...

Merge "Revert "Enable incremental builder to find files that moved, and try to process them via patch + rename, instead of delete + add."" into klp-dev
parents 221fcf31 90c60d3b
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -1262,7 +1262,6 @@ ifdef PRODUCT_EXTRA_RECOVERY_KEYS
endif
endif
	$(hide) echo "mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt
	$(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt
	$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
	$(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt)
	@# Zip everything up, preserving symlinks
	@# Zip everything up, preserving symlinks
	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
	$(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .)
+0 −5
Original line number Original line Diff line number Diff line
@@ -184,11 +184,6 @@ class EdifyGenerator(object):
    cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
    cmd = "delete(" + ",\0".join(['"%s"' % (i,) for i in file_list]) + ");"
    self.script.append(self._WordWrap(cmd))
    self.script.append(self._WordWrap(cmd))


  def RenameFile(self, srcfile, tgtfile):
    """Moves a file from one location to another."""
    if self.info.get("update_rename_support", False):
      self.script.append('rename("%s", "%s");' % (srcfile, tgtfile))

  def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
  def ApplyPatch(self, srcfile, tgtfile, tgtsize, tgtsha1, *patchpairs):
    """Apply binary patches (in *patchpairs) to the given srcfile to
    """Apply binary patches (in *patchpairs) to the given srcfile to
    produce tgtfile (which may be "-" to indicate overwriting the
    produce tgtfile (which may be "-" to indicate overwriting the
+5 −54
Original line number Original line Diff line number Diff line
@@ -108,31 +108,6 @@ def IsRegular(info):
  symlink."""
  symlink."""
  return (info.external_attr >> 28) == 010
  return (info.external_attr >> 28) == 010


def ClosestFileMatch(src, tgtfiles, existing):
  """Returns the closest file match between a source file and list
     of potential matches.  The exact filename match is preferred,
     then the sha1 is searched for, and finally a file with the same
     basename is evaluated.  Rename support in the updater-binary is
     required for the latter checks to be used."""

  result = tgtfiles.get("path:" + src.name)
  if result is not None:
    return result

  if not OPTIONS.target_info_dict.get("update_rename_support", False):
    return None

  if src.size < 1000:
    return None

  result = tgtfiles.get("sha1:" + src.sha1)
  if result is not None and existing.get(result.name) is None:
    return result
  result = tgtfiles.get("file:" + src.name.split("/")[-1])
  if result is not None and existing.get(result.name) is None:
    return result
  return None

class Item:
class Item:
  """Items represent the metadata (user, group, mode) of files and
  """Items represent the metadata (user, group, mode) of files and
  directories in the system image."""
  directories in the system image."""
@@ -539,27 +514,11 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
  verbatim_targets = []
  verbatim_targets = []
  patch_list = []
  patch_list = []
  diffs = []
  diffs = []
  renames = {}
  largest_source_size = 0
  largest_source_size = 0

  matching_file_cache = {}
  for fn in source_data.keys():
    sf = source_data[fn]
    assert fn == sf.name
    matching_file_cache["path:" + fn] = sf
    # Only allow eligability for filename/sha matching
    # if there isn't a perfect path match.
    if target_data.get(sf.name) is None:
      matching_file_cache["file:" + fn.split("/")[-1]] = sf
      matching_file_cache["sha:" + sf.sha1] = sf

  for fn in sorted(target_data.keys()):
  for fn in sorted(target_data.keys()):
    tf = target_data[fn]
    tf = target_data[fn]
    assert fn == tf.name
    assert fn == tf.name
    sf = ClosestFileMatch(tf, matching_file_cache, renames)
    sf = source_data.get(fn, None)
    if sf is not None and sf.name != tf.name:
      print "File has moved from " + sf.name + " to " + tf.name
      renames[sf.name] = tf


    if sf is None or fn in OPTIONS.require_verbatim:
    if sf is None or fn in OPTIONS.require_verbatim:
      # This file should be included verbatim
      # This file should be included verbatim
@@ -572,7 +531,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
      # File is different; consider sending as a patch
      # File is different; consider sending as a patch
      diffs.append(common.Difference(tf, sf))
      diffs.append(common.Difference(tf, sf))
    else:
    else:
      # Target file data identical to source (may still be renamed)
      # Target file identical to source.
      pass
      pass


  common.ComputeDifferences(diffs)
  common.ComputeDifferences(diffs)
@@ -584,8 +543,8 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
      tf.AddToZip(output_zip)
      tf.AddToZip(output_zip)
      verbatim_targets.append((tf.name, tf.size))
      verbatim_targets.append((tf.name, tf.size))
    else:
    else:
      common.ZipWriteStr(output_zip, "patch/" + sf.name + ".p", d)
      common.ZipWriteStr(output_zip, "patch/" + tf.name + ".p", d)
      patch_list.append((sf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
      patch_list.append((tf.name, tf, sf, tf.size, common.sha1(d).hexdigest()))
      largest_source_size = max(largest_source_size, sf.size)
      largest_source_size = max(largest_source_size, sf.size)


  source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
  source_fp = GetBuildProp("ro.build.fingerprint", OPTIONS.source_info_dict)
@@ -667,8 +626,7 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
  script.Print("Removing unneeded files...")
  script.Print("Removing unneeded files...")
  script.DeleteFiles(["/"+i[0] for i in verbatim_targets] +
  script.DeleteFiles(["/"+i[0] for i in verbatim_targets] +
                     ["/"+i for i in sorted(source_data)
                     ["/"+i for i in sorted(source_data)
                            if i not in target_data and
                            if i not in target_data] +
                            i not in renames] +
                     ["/system/recovery.img"])
                     ["/system/recovery.img"])


  script.ShowProgress(0.8, 0)
  script.ShowProgress(0.8, 0)
@@ -755,13 +713,6 @@ def WriteIncrementalOTAPackage(target_zip, source_zip, output_zip):
    script.Print("Unpacking new recovery...")
    script.Print("Unpacking new recovery...")
    script.UnpackPackageDir("recovery", "/system")
    script.UnpackPackageDir("recovery", "/system")


  if len(renames) > 0:
    script.Print("Renaming files...")

  for src in renames:
    print "Renaming " + src + " to " + renames[src].name
    script.RenameFile(src, renames[src].name)

  script.Print("Symlinks and permissions...")
  script.Print("Symlinks and permissions...")


  # Create all the symlinks that don't already exist, or point to
  # Create all the symlinks that don't already exist, or point to