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

Commit 04d290c8 authored by Brint E. Kriebel's avatar Brint E. Kriebel
Browse files

releasetools: Add radio images to fastboot packages

Fastboot packages should include radio images, if they exist. Also
generate a flash-radio.sh file if a filesmap file exists to indicate
the partition that a radio image should be flashed to.

Change-Id: Ic3392cc76407408b98aad00f36f4dfa3b9be176b
parent d0629829
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -201,6 +201,30 @@ def CopyInfo(output_zip):
  output_zip.write(os.path.join(OPTIONS.input_tmp, "OTA", "android-info.txt"),
                   "android-info.txt")

def AddRadio(output_zip):
  """If they exist, add RADIO files to the output."""
  if os.path.isdir(os.path.join(OPTIONS.input_tmp, "RADIO")):
    for radio_root, radio_dirs, radio_files in os.walk(os.path.join(OPTIONS.input_tmp, "RADIO")):
      for radio_file in radio_files:
        output_zip.write(os.path.join(radio_root, radio_file), radio_file)

    # If a filesmap file exists, create a script to flash the radio images based on it
    filesmap = os.path.join(OPTIONS.input_tmp, "RADIO/filesmap")
    if os.path.isfile(filesmap):
      print "creating flash-radio.sh..."
      filesmap_data = open(filesmap, "r")
      filesmap_regex = re.compile(r'^(\S+)\s.+\/by-name\/(\S+)$')
      tmp_flash_radio = tempfile.NamedTemporaryFile()
      for filesmap_line in filesmap_data:
        filesmap_entry = filesmap_regex.search(filesmap_line)
        if filesmap_entry:
          tmp_flash_radio.write("fastboot flash %s %s" % (filesmap_entry.group(2), filesmap_entry.group(1)))
      tmp_flash_radio.flush()
      if os.path.getsize(tmp_flash_radio.name) > 0:
        output_zip.write(tmp_flash_radio.name, "flash-radio.sh")
      else:
        print "flash-radio.sh is empty, skipping..."
      tmp_flash_radio.close()

def main(argv):
  bootable_only = [False]
@@ -251,6 +275,7 @@ def main(argv):
    AddUserdata(output_zip)
    AddCache(output_zip)
    CopyInfo(output_zip)
    AddRadio(output_zip)

  print "cleaning up..."
  output_zip.close()