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

Commit 3e99026e authored by Chris Soyars's avatar Chris Soyars Committed by Steve Kondik
Browse files

Add otapackage support for backuptool

Change-Id: I512554c579d444067cd3ccbb0e6946a5eb6bc964a
parent d2d3d7ca
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1270,11 +1270,18 @@ else
    OTA_FROM_TARGET_SCRIPT := $(TARGET_RELEASETOOL_OTA_FROM_TARGET_SCRIPT)
endif

ifeq ($(CM_BUILD),true)
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := true
else
    $(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
endif

$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(DISTTOOLS) $(SELINUX_DEPENDS)
	@echo "Package OTA: $@"
	$(OTA_FROM_TARGET_SCRIPT) -v \
	   -p $(HOST_OUT) \
	   -k $(KEY_CERT_PAIR) \
       --backup=$(backuptool) \
	   $(BUILT_TARGET_FILES_PACKAGE) $@

.PHONY: otapackage bacon
+5 −0
Original line number Diff line number Diff line
@@ -99,6 +99,11 @@ class EdifyGenerator(object):
           ");")
    self.script.append(self._WordWrap(cmd))

  def RunBackup(self, command):
    self.script.append('package_extract_file("system/bin/backuptool.sh", "/tmp/backuptool.sh");')
    self.script.append('set_perm(0, 0, 0777, "/tmp/backuptool.sh");')
    self.script.append(('run_program("/tmp/backuptool.sh", "%s");' % command))

  def ShowProgress(self, frac, dur):
    """Update the progress bar, advancing it over 'frac' over the next
    'dur' seconds.  'dur' may be zero to advance it via SetProgress
+15 −0
Original line number Diff line number Diff line
@@ -52,6 +52,10 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
  -a  (--aslr_mode)  <on|off>
      Specify whether to turn on ASLR for the package (on by default).

  --backup <boolean>
      Enable or disable the execution of backuptool.sh.
      Disabled by default.

"""

import sys
@@ -88,6 +92,7 @@ OPTIONS.omit_prereq = False
OPTIONS.extra_script = None
OPTIONS.aslr_mode = True
OPTIONS.worker_threads = 3
OPTIONS.backuptool = False

def MostPopularKey(d, default):
  """Given a dict, return the key corresponding to the largest
@@ -380,6 +385,9 @@ def WriteFullOTAPackage(input_zip, output_zip):
  device_specific.FullOTA_Assertions()
  device_specific.FullOTA_InstallBegin()

  if OPTIONS.backuptool:
    script.RunBackup("backup")

  script.ShowProgress(0.5, 0)

  if OPTIONS.wipe_user_data:
@@ -409,6 +417,10 @@ def WriteFullOTAPackage(input_zip, output_zip):
  common.ZipWriteStr(output_zip, "boot.img", boot_img.data)
  script.ShowProgress(0.2, 0)

  if OPTIONS.backuptool:
    script.ShowProgress(0.2, 10)
    script.RunBackup("restore")

  script.ShowProgress(0.2, 10)
  script.WriteRawImage("/boot", "boot.img")

@@ -748,6 +760,8 @@ def main(argv):
        OPTIONS.aslr_mode = False
    elif o in ("--worker_threads"):
      OPTIONS.worker_threads = int(a)
    elif o in ("--backup"):
      OPTIONS.backuptool = bool(a.lower() == 'true')
    else:
      return False
    return True
@@ -762,6 +776,7 @@ def main(argv):
                                              "extra_script=",
                                              "worker_threads=",
                                              "aslr_mode=",
                                              "backup=",
                                              ],
                             extra_option_handler=option_handler)