assert(getprop("ro.product.device") == "x2eu" || getprop("ro.build.product") == "x2eu" || abort("This package is for device: x2eu; this device is " + getprop("ro.product.device") + "."););
ui_print("Target: Lenovo/cm_x2eu/x2eu:6.0.1/MOB31E/28469e6ea7:userdebug/test-keys");
ifelse(is_mounted("/system"), unmount("/system"));
package_extract_dir("install", "/tmp/install");
set_metadata_recursive("/tmp/install", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0644);
set_metadata_recursive("/tmp/install/bin", "uid", 0, "gid", 0, "dmode", 0755, "fmode", 0755);
mount("ext4", "EMMC", "/dev/block/mmcblk0p14", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "backup");
unmount("/system");
if is_mounted("/data") then
package_extract_file("META-INF/org/cyanogenmod/releasekey", "/tmp/releasekey");
run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can't install this package on top of incompatible data. Please try another package or run a factory reset");
else
mount("ext4", "EMMC", "/dev/block/mmcblk0p16", "/data", "");
package_extract_file("META-INF/org/cyanogenmod/releasekey", "/tmp/releasekey");
run_program("/tmp/install/bin/otasigcheck.sh") != "31744" || abort("Can't install this package on top of incompatible data. Please try another package or run a factory reset");
unmount("/data");
endif;
show_progress(0.750000, 0);
ui_print("Patching system image unconditionally...");
block_image_update("/dev/block/mmcblk0p14", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat");
ui_print("Verifying the updated system image...");
if range_sha1("/dev/block/mmcblk0p14", "42,0,32767,32768,32770,32865,32867,33379,65535,65536,65538,98304,98306,98401,98403,98915,131071,131072,131074,163840,163842,163937,163939,164451,196607,196608,196610,229376,229378,229473,229475,229987,259557,262144,262146,294912,294914,295009,295011,327680,327682,360448,360450") == "a61b36a7fa824727a69ab1989b2fc41c1c42d7f1" then
if range_sha1("/dev/block/mmcblk0p14", "56,32767,32768,32770,32865,32867,33379,65535,65536,65538,66050,97792,98304,98306,98401,98403,98915,131071,131072,131074,131586,163328,163840,163842,163937,163939,164451,196607,196608,196610,197122,228864,229376,229378,229473,229475,229987,259557,260069,261632,262144,262146,262658,294400,294912,294914,295009,295011,295523,327168,327680,327682,328194,359936,360448,360450,360962") == "0d1d76135a43547c983799e39a0cda54c89ebfff" then
ui_print("Verified the updated system image.");
else
  abort("system partition has unexpected non-zero contents after OTA update");
endif;
else
  abort("system partition has unexpected contents after OTA update");
endif;
show_progress(0.020000, 10);
mount("ext4", "EMMC", "/dev/block/mmcblk0p14", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "restore");
unmount("/system");
show_progress(0.050000, 5);
package_extract_file("boot.img", "/dev/block/mmcblk0p7");
show_progress(0.200000, 10);
