assert(getprop("ro.product.device") == "OnePlus2" || getprop("ro.build.product") == "OnePlus2" || 
       getprop("ro.product.device") == "oneplus2" || getprop("ro.build.product") == "oneplus2" || abort("E3004: This package is for device: OnePlus2,oneplus2; this device is " + getprop("ro.product.device") + "."););
assert(oneplus2.verify_baseband("2.6.2.C1-82470") == "1" || abort("ERROR: This package requires firmware from OOS 3.6.0 or newer. Please upgrade firmware and retry!"););
ui_print("Target: OnePlus/OnePlus2/OnePlus2:6.0.1/MMB29M/1447858500:user/release-keys");
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);
run_program("/tmp/install/bin/backuptool.sh", "backup", "/dev/block/platform/soc.0/f9824900.sdhci/by-name/system", "ext4");
ui_print("Patching system image unconditionally...");
show_progress(0.900000, 0);
block_image_update("/dev/block/platform/soc.0/f9824900.sdhci/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat.br", "system.patch.dat") ||
  abort("E1001: Failed to update system image.");
show_progress(0.020000, 10);
run_program("/tmp/install/bin/backuptool.sh", "restore", "/dev/block/platform/soc.0/f9824900.sdhci/by-name/system", "ext4");
package_extract_file("boot.img", "/dev/block/platform/soc.0/f9824900.sdhci/by-name/boot");
show_progress(0.100000, 10);
set_progress(1.000000);
