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

Commit bae09ac4 authored by Chris Soyars's avatar Chris Soyars Committed by Giulio Cervera
Browse files

Add otapackage support for backuptool

Change-Id: I512554c579d444067cd3ccbb0e6946a5eb6bc964
parent 9961c15f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1061,11 +1061,18 @@ INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip

$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)

ifdef CYANOGEN_WITH_GOOGLE
$(INTERNAL_OTA_PACKAGE_TARGET): backuptool := false
else
$(INTERNAL_OTA_PACKAGE_TARGET): backuptool := true
endif

$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(OTATOOLS)
	@echo "Package OTA: $@"
	$(hide) ./build/tools/releasetools/ota_from_target_files -v \
	   -p $(HOST_OUT) \
           -k $(KEY_CERT_PAIR) \
           --backup=$(backuptool) \
           $(BUILT_TARGET_FILES_PACKAGE) $@

.PHONY: otapackage
+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 −1
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ Usage: ota_from_target_files [flags] input_target_files output_ota_package
  -e  (--extra_script)  <file>
      Insert the contents of file at the end of the update script.

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

"""

import sys
@@ -75,6 +79,7 @@ OPTIONS.wipe_user_data = False
OPTIONS.omit_prereq = False
OPTIONS.extra_script = None
OPTIONS.worker_threads = 3
OPTIONS.backuptool = False

def MostPopularKey(d, default):
  """Given a dict, return the key corresponding to the largest
@@ -367,6 +372,8 @@ def WriteFullOTAPackage(input_zip, output_zip):

  AppendAssertions(script, input_zip)
  device_specific.FullOTA_Assertions()
  if OPTIONS.backuptool:
    script.RunBackup("backup")

  script.ShowProgress(0.5, 0)

@@ -394,6 +401,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")

@@ -710,6 +721,8 @@ def main(argv):
      OPTIONS.extra_script = a
    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
@@ -722,7 +735,8 @@ def main(argv):
                                              "wipe_user_data",
                                              "no_prereq",
                                              "extra_script=",
                                              "worker_threads="],
                                              "worker_threads=",
                                              "backup="],
                             extra_option_handler=option_handler)

  if len(args) != 2: