assert(get_device_compatible("espresso-common") == "OK" || getprop("ro.build.product") == "espresso-common" || get_device_compatible("p3110") == "OK" || getprop("ro.build.product") == "p3110" || get_device_compatible("GT-P3110") == "OK" || getprop("ro.build.product") == "GT-P3110" || get_device_compatible("p3113") == "OK" || getprop("ro.build.product") == "p3113" || get_device_compatible("GT-P3113") == "OK" || getprop("ro.build.product") == "GT-P3113" || get_device_compatible("espressowifi") == "OK" || getprop("ro.build.product") == "espressowifi" || get_device_compatible("espressowifixx") == "OK" || getprop("ro.build.product") == "espressowifixx" || get_device_compatible("p5110") == "OK" || getprop("ro.build.product") == "p5110" || get_device_compatible("GT-P5110") == "OK" || getprop("ro.build.product") == "GT-P5110" || get_device_compatible("p5113") == "OK" || getprop("ro.build.product") == "p5113" || get_device_compatible("GT-P5113") == "OK" || getprop("ro.build.product") == "GT-P5113" || get_device_compatible("espresso10wifi") == "OK" || getprop("ro.build.product") == "espresso10wifi" || get_device_compatible("espresso10wifixx") == "OK" || getprop("ro.build.product") == "espresso10wifixx" || abort("This package is for device: espresso-common,p3110,GT-P3110,p3113,GT-P3113,espressowifi,espressowifixx,p5110,GT-P5110,p5113,GT-P5113,espresso10wifi,espresso10wifixx; this device is " + getprop("ro.product.device") + "."););
ui_print("Target: Android/orion_espressowifi/espressowifi:6.0.1/MOB31K/957d5d3a7e: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/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "backup");
unmount("/system");
ui_print("");
ui_print("  ____       _               ____  ______");
ui_print(" / __ \     (_)             / __ \|  ____|");
ui_print("| |  | |_ __ _  ___  _ __  | |  | | |____");
ui_print("| |  | | '__| |/ _ \| '_ \ | |  | |____  |");
ui_print("| |__| | |  | | (_) | | | || |__| |____| |");
ui_print(" \____/|_|  |_|\___/|_| |_| \____/|______|");
ui_print("");
ui_print("");
if is_mounted("/data") then
package_extract_file("META-INF/org/orion/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("f2fs", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/DATAFS", "/data", "");
package_extract_file("META-INF/org/orion/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/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat");
ui_print("Verifying the updated system image...");
if range_sha1("/dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "30,0,32767,32768,32770,32833,32835,33347,65535,65536,65538,98304,98306,98369,98371,98883,131006,131072,131074,163840,163842,163905,163907,164419,173397,196608,196610,229376,229378,229441,229443") == "074d43522ae66327cfa59a5da86a10343991709f" then
if range_sha1("/dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "38,32767,32768,32770,32833,32835,33347,65535,65536,65538,66050,97792,98304,98306,98369,98371,98883,131006,131072,131074,131586,163328,163840,163842,163905,163907,164419,173397,173909,196096,196608,196610,197122,228864,229376,229378,229441,229443,229955") == "df4b0e23f939aeea5b315a40312286c8de8afff6" then
ui_print(" ");
ui_print("OrionOs System files verified.");
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/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "/system", "");
run_program("/tmp/install/bin/backuptool.sh", "restore");
unmount("/system");
ui_print("Flashing SuperSU...");
mount("ext4", "EMMC", "/dev/block/platform/omap/omap_hsmmc.1/by-name/FACTORYFS", "/system", "");
package_extract_dir("supersu", "/tmp/supersu");
run_program("/sbin/busybox", "unzip", "/tmp/supersu/supersu.zip", "META-INF/com/google/android/*", "-d", "/tmp/supersu");
run_program("/sbin/busybox", "sh", "/tmp/supersu/META-INF/com/google/android/update-binary", "dummy", "1", "/tmp/supersu/supersu.zip");
show_progress(0.050000, 5);
package_extract_file("boot.img", "/dev/block/mmcblk0p5");
show_progress(0.200000, 10);
unmount("/system");
