[ZTE Z7, Z7 Max, Z7 Mini] yuhas92:
get_device_compatible("xuantan") == "OK" || abort("This package is for "xuantan" devices; this is a "" + getprop("ro.product.device") + "".");

assert(getprop("ro.product.name") == "P816A06");

ui_print("Verifying current system...");

getprop("ro.build.fingerprint") == "ZTE/P816A06/xuantan:5.1/LMY47O/20150511.164322.6785:user/release-keys" ||

getprop("ro.build.fingerprint") == "ZTE/P816A06/xuantan:5.1/LMY47O/20151015.161210:user/release-keys" ||

abort("Package expects build fingerprint of ZTE/P816A06/xuantan:5.1/LMY47O/20150511.164322.6785:user/release-keys or ZTE/P816A06/xuantan:5.1/LMY47O/20151015.161210:user/release-keys; this device has " + getprop("ro.build.fingerprint") + ".");

ui_print("Source fingerprint is ZTE/P816A06/xuantan:5.1/LMY47O/20150511.164322.6785:user/release-keys.");

ui_print("Target fingerprint is ZTE/P816A06/xuantan:5.1/LMY47O/20151015.161210:user/release-keys.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/sbl1:261612:42012df7669a8bf50ed39611fc0e02cc92620290:261884:2f7ad1e5d60015b0a70319a1c8398bb746b9262e", "42012df7669a8bf50ed39611fc0e02cc92620290", "2f7ad1e5d60015b0a70319a1c8398bb746b9262e") || abort(""EMMC:/dev/block/bootdevice/by-name/sbl1:261612:42012df7669a8bf50ed39611fc0e02cc92620290:261884:2f7ad1e5d60015b0a70319a1c8398bb746b9262e" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/hyp:57344:a32d6980ca93845d9f1b933e58ad7675e149458c:57344:0df1a4ecf04f98fa6ab4c4e574a2011f1c9afdb7", "a32d6980ca93845d9f1b933e58ad7675e149458c", "0df1a4ecf04f98fa6ab4c4e574a2011f1c9afdb7") || abort(""EMMC:/dev/block/bootdevice/by-name/hyp:57344:a32d6980ca93845d9f1b933e58ad7675e149458c:57344:0df1a4ecf04f98fa6ab4c4e574a2011f1c9afdb7" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/rpm:154812:e1c4a31ddeae73c56425ac5770d81429f7479a87:154812:e49f9f1d9b839b1e87ee81208d09ca4b96f37e40", "e1c4a31ddeae73c56425ac5770d81429f7479a87", "e49f9f1d9b839b1e87ee81208d09ca4b96f37e40") || abort(""EMMC:/dev/block/bootdevice/by-name/rpm:154812:e1c4a31ddeae73c56425ac5770d81429f7479a87:154812:e49f9f1d9b839b1e87ee81208d09ca4b96f37e40" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/tz:483468:a9d6d2052cf0d91e54361d97f89cae59cce7e637:487564:aeb866cf7a76c584bb5c4f9fb4f3763d3a194969", "a9d6d2052cf0d91e54361d97f89cae59cce7e637", "aeb866cf7a76c584bb5c4f9fb4f3763d3a194969") || abort(""EMMC:/dev/block/bootdevice/by-name/tz:483468:a9d6d2052cf0d91e54361d97f89cae59cce7e637:487564:aeb866cf7a76c584bb5c4f9fb4f3763d3a194969" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/modem:54281728:2b28a06aae61256905a0380fb52e3461d68e4a00:54756864:8977bf1b66bc2c6e3c6187f2303718b280a2487a", "2b28a06aae61256905a0380fb52e3461d68e4a00", "8977bf1b66bc2c6e3c6187f2303718b280a2487a") || abort(""EMMC:/dev/block/bootdevice/by-name/modem:54281728:2b28a06aae61256905a0380fb52e3461d68e4a00:54756864:8977bf1b66bc2c6e3c6187f2303718b280a2487a" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/aboot:414132:6144383173e8aefa2c7328f001cfa81962c06c26:414468:3d21602a0ce7670f17ed8c7fce643376d1c606b9", "6144383173e8aefa2c7328f001cfa81962c06c26", "3d21602a0ce7670f17ed8c7fce643376d1c606b9") || abort(""EMMC:/dev/block/bootdevice/by-name/aboot:414132:6144383173e8aefa2c7328f001cfa81962c06c26:414468:3d21602a0ce7670f17ed8c7fce643376d1c606b9" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/boot:20109312:58785c71e9e16fa80e0aa9e79e9df460a5ed37a6:20176896:3104532f24d82a6a3ce1c03d215311e9dce8e0e3", "58785c71e9e16fa80e0aa9e79e9df460a5ed37a6", "3104532f24d82a6a3ce1c03d215311e9dce8e0e3") || abort(""EMMC:/dev/block/bootdevice/by-name/boot:20109312:58785c71e9e16fa80e0aa9e79e9df460a5ed37a6:20176896:3104532f24d82a6a3ce1c03d215311e9dce8e0e3" has unexpected contents.");

apply_patch_check("EMMC:/dev/block/bootdevice/by-name/recovery:18522112:364745622f87c03f806d7c51205bb98f61539b68:18591744:ea362c8a53cd0915daf4979c0cb340cf5ac71817", "364745622f87c03f806d7c51205bb98f61539b68", "ea362c8a53cd0915daf4979c0cb340cf5ac71817") || abort(""EMMC:/dev/block/bootdevice/by-name/recovery:18522112:364745622f87c03f806d7c51205bb98f61539b68:18591744:ea362c8a53cd0915daf4979c0cb340cf5ac71817" has unexpected contents.");

if block_image_verify("/dev/block/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") then

ui_print("Verified system image...");

else

(range_sha1("/dev/block/bootdevice/by-name/system", "74,0,32770,32913,32915,33416,65535,65536,65538,66039,98303,98304,98306,98449,98451,98952,131071,131072,131074,131575,163839,163840,163842,163985,163987,164488,196607,196608,196610,197111,229375,229376,229378,229521,229523,230024,262143,262144,262146,262647,294911,294912,294914,295057,295059,295560,327679,327680,327682,328183,360447,360448,360450,360951,393215,393216,393218,393719,425983,425984,425986,426487,454193,458752,458754,491520,491522,524288,524290,557056,557058,557559,577042,577043,581597") == "2252ee19d0bf2a113c3b3d0985a046a92035985a") ||

abort("system partition has unexpected contents");

endif;

# ---- start making changes here ----

ui_print("Patching system image after verification.");

show_progress(0.900000, 0);

block_image_update("/dev/block/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat");

ui_print("Patching sbl1 image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/sbl1:261612:42012df7669a8bf50ed39611fc0e02cc92620290:261884:2f7ad1e5d60015b0a70319a1c8398bb746b9262e",

"-", 2f7ad1e5d60015b0a70319a1c8398bb746b9262e, 261884,

42012df7669a8bf50ed39611fc0e02cc92620290, package_extract_file("patch/sbl1.mbn.p"));

ui_print("Patching hyp image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/hyp:57344:a32d6980ca93845d9f1b933e58ad7675e149458c:57344:0df1a4ecf04f98fa6ab4c4e574a2011f1c9afdb7",

"-", 0df1a4ecf04f98fa6ab4c4e574a2011f1c9afdb7, 57344,

a32d6980ca93845d9f1b933e58ad7675e149458c, package_extract_file("patch/hyp.mbn.p"));

ui_print("Patching rpm image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/rpm:154812:e1c4a31ddeae73c56425ac5770d81429f7479a87:154812:e49f9f1d9b839b1e87ee81208d09ca4b96f37e40",

"-", e49f9f1d9b839b1e87ee81208d09ca4b96f37e40, 154812,

e1c4a31ddeae73c56425ac5770d81429f7479a87, package_extract_file("patch/rpm.mbn.p"));

ui_print("Patching tz image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/tz:483468:a9d6d2052cf0d91e54361d97f89cae59cce7e637:487564:aeb866cf7a76c584bb5c4f9fb4f3763d3a194969",

"-", aeb866cf7a76c584bb5c4f9fb4f3763d3a194969, 487564,

a9d6d2052cf0d91e54361d97f89cae59cce7e637, package_extract_file("patch/tz.mbn.p"));

ui_print("Patching modem image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/modem:54281728:2b28a06aae61256905a0380fb52e3461d68e4a00:54756864:8977bf1b66bc2c6e3c6187f2303718b280a2487a",

"-", 8977bf1b66bc2c6e3c6187f2303718b280a2487a, 54756864,

2b28a06aae61256905a0380fb52e3461d68e4a00, package_extract_file("patch/modem.mbn.p"));

ui_print("Patching appsbl image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/aboot:414132:6144383173e8aefa2c7328f001cfa81962c06c26:414468:3d21602a0ce7670f17ed8c7fce643376d1c606b9",

"-", 3d21602a0ce7670f17ed8c7fce643376d1c606b9, 414468,

6144383173e8aefa2c7328f001cfa81962c06c26, package_extract_file("patch/appsbl.mbn.p"));

ui_print("Patching boot image...");

show_progress(0.100000, 10);

apply_patch("EMMC:/dev/block/bootdevice/by-name/boot:20109312:58785c71e9e16fa80e0aa9e79e9df460a5ed37a6:20176896:3104532f24d82a6a3ce1c03d215311e9dce8e0e3",

"-", 3104532f24d82a6a3ce1c03d215311e9dce8e0e3, 20176896,

58785c71e9e16fa80e0aa9e79e9df460a5ed37a6, package_extract_file("patch/boot.img.p"));

ui_print("Patching recovery image...");

apply_patch("EMMC:/dev/block/bootdevice/by-name/recovery:18522112:364745622f87c03f806d7c51205bb98f61539b68:18591744:ea362c8a53cd0915daf4979c0cb340cf5ac71817",

"-", ea362c8a53cd0915daf4979c0cb340cf5ac71817, 18591744,

364745622f87c03f806d7c51205bb98f61539b68, package_extract_file("patch/recovery.img.p"));

set_progress(1.000000);

here's what the update script looks like