assert(getprop("ro.product.device") == "gtelwifiue" || getprop("ro.build.product") == "gtelwifiue" || getprop("ro.product.device") == "samsung_sm_t560nu" || getprop("ro.build.product") == "samsung_sm_t560nu" || getprop("ro.product.device") == "t560nu" || getprop("ro.build.product") == "t560nu" || abort("This package is for device: gtelwifiue,samsung_sm_t560nu,t560nu; this device is " + getprop("ro.product.device") + "."););
ui_print("Target: samsung/lineage_gtelwifiue/gtelwifiue:6.0.1/MOB31K/cec342c921: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/bootdevice/by-name/system", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "backup");
unmount("/system");
if is_mounted("/data") then
package_extract_file("META-INF/org/lineageos/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/bootdevice/by-name/userdata", "/data", "");
package_extract_file("META-INF/org/lineageos/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/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat");
ui_print("Verifying the updated system image...");
if range_sha1("/dev/block/bootdevice/by-name/system", "58,0,32767,32768,32770,32921,32923,33429,65535,65536,65538,98304,98306,98457,98459,98965,131071,131072,131074,163840,163842,163993,163995,164501,196606,196608,196610,229376,229378,229529,229531,230037,231053,262144,262146,294912,294914,295065,295067,327680,327682,360448,360450,393216,393218,425984,425986,458752,458754,491520,491522,524288,524290,557056,557058,589824,589826,590332,614399") == "21afc83d8587a913cba28e2a7b40c861577a5ea4" then
if range_sha1("/dev/block/bootdevice/by-name/system", "86,32767,32768,32770,32921,32923,33429,65535,65536,65538,66050,97792,98304,98306,98457,98459,98965,131071,131072,131074,131586,163328,163840,163842,163993,163995,164501,196606,196608,196610,197122,228864,229376,229378,229529,229531,230037,231053,231565,261632,262144,262146,262658,294400,294912,294914,295065,295067,295579,327168,327680,327682,328194,359936,360448,360450,360962,392704,393216,393218,393730,425472,425984,425986,426498,458240,458752,458754,459266,491008,491520,491522,492034,523776,524288,524290,524802,556544,557056,557058,557570,589312,589824,589826,590332,614399,614400") == "28140b35ef61757296b857ced01659309cf420ce" 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/bootdevice/by-name/system", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "restore");
unmount("/system");
show_progress(0.050000, 5);
package_extract_file("boot.img", "/dev/block/bootdevice/by-name/boot");
show_progress(0.200000, 10);
