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

Commit 9f0c8dfa authored by Tao Bao's avatar Tao Bao
Browse files

Scan all init.*.rc files for flash_recovery service.

Clockwork builds may rename init.rc to init.core.rc. Change the OTA
script to scan all init.*.rc files to determine the proper location for
install-recovery.sh.

Bug: 22128990
Change-Id: Icad3497d1663e074b938919b40fc239c84fbeb2b
(cherry picked from commit 610754e5)
parent 48a27bcb
Loading
Loading
Loading
Loading
+16 −6
Original line number Original line Diff line number Diff line
@@ -1375,18 +1375,28 @@ fi
       'bonus_args': bonus_args}
       'bonus_args': bonus_args}


  # The install script location moved from /system/etc to /system/bin
  # The install script location moved from /system/etc to /system/bin
  # in the L release.  Parse the init.rc file to find out where the
  # in the L release.  Parse init.*.rc files to find out where the
  # target-files expects it to be, and put it there.
  # target-files expects it to be, and put it there.
  sh_location = "etc/install-recovery.sh"
  sh_location = "etc/install-recovery.sh"
  try:
  found = False
    with open(os.path.join(input_dir, "BOOT", "RAMDISK", "init.rc")) as f:
  init_rc_dir = os.path.join(input_dir, "BOOT", "RAMDISK")
  init_rc_files = os.listdir(init_rc_dir)
  for init_rc_file in init_rc_files:
    if (not init_rc_file.startswith('init.') or
        not init_rc_file.endswith('.rc')):
      continue

    with open(os.path.join(init_rc_dir, init_rc_file)) as f:
      for line in f:
      for line in f:
        m = re.match(r"^service flash_recovery /system/(\S+)\s*$", line)
        m = re.match(r"^service flash_recovery /system/(\S+)\s*$", line)
        if m:
        if m:
          sh_location = m.group(1)
          sh_location = m.group(1)
          print "putting script in", sh_location
          found = True
          break
          break
  except (OSError, IOError) as e:

    print "failed to read init.rc: %s" % (e,)
    if found:
      break

  print "putting script in", sh_location


  output_sink(sh_location, sh)
  output_sink(sh_location, sh)