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

Unverified Commit 1d55bc11 authored by Ricardo Cerqueira's avatar Ricardo Cerqueira Committed by Michael Bestas
Browse files

ota: Let devices specify their own recovery-from-boot.p installer

Some devices apply transformations to the installed images, making
the sha1 checksums fail (or, worse, generating invalid images). If
"/system/etc/recovery-transform.sh" exists, run that instead, passing
the expected sizes and checksums as arguments in the form of

recovery-transform.sh <recovery_size> <recovery_sha1> <boot_size> <boot_sha1>

A direct emulation of the standard patcher could look like this, transformations
should be added as needed.

----------------
RECSIZE=$1
RECSHA1=$2
BOOTSIZE=$3
BOOTSHA1=$4

dd if=/dev/block/platform/msm_sdcc.1/by-name/recovery of=$C/recovery.img
dd if=/dev/block/platform/msm_sdcc.1/by-name/boot of=$C/boot.img

if ! applypatch -c EMMC:$C/recovery.img:$RECSIZE:$RECSHA1; then
  log -t recovery "Installing new recovery image"
  applypatch -b /system/etc/recovery-resource.dat EMMC:$C/boot.img:$BOOTSIZE:$BOOTSHA1 EMMC:$C/recovery.img $RECSHA1 $RECSIZE $BOOTSHA1:/system/recovery-from-boot.p || exit 1
else
  log -t recovery "Recovery image already installed"
fi
----------------

Conflicts:
	tools/releasetools/ota_from_target_files

Change-Id: Ie601841ca1cdad6b8f3b16e593d2718a92e8ca09
parent 252e5255
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1666,6 +1666,9 @@ def MakeRecoveryPatch(input_dir, output_sink, recovery_img, boot_img,

  if full_recovery_image:
    sh = """#!/system/bin/sh
if [ -f /system/etc/recovery-transform.sh ]; then
  exec sh /system/etc/recovery-transform.sh %(recovery_size)d %(recovery_sha1)s %(boot_size)d %(boot_sha1)s
fi
if ! applypatch -c %(type)s:%(device)s:%(size)d:%(sha1)s; then
  applypatch /system/etc/recovery.img %(type)s:%(device)s %(sha1)s %(size)d && log -t recovery "Installing new recovery image: succeeded" || log -t recovery "Installing new recovery image: failed"
else