assert(getprop("ro.product.device") == "raphael" || getprop("ro.build.product") == "raphael" || 
       getprop("ro.product.device") == "raphaelin" || getprop("ro.build.product") == "raphaelin" || abort("E3004: This package is for device: raphael,raphaelin; this device is " + getprop("ro.product.device") + "."););
assert(raphael.verify_trustzone("TZ.XF.5.2.C1-00019") == "1" || abort("ERROR: This package requires firmware from an Android 10 based MIUI build. Please upgrade firmware and retry!"););
assert(getprop("ro.boot.hwc") == "INDIA" && (raphael.verify_vendor("V12.0.3.0.QFKINXM", "1599411566") == "1" || abort("ERROR: This package requires vendor from atleast V12.0.3.0.QFKINXM. Please upgrade firmware and retry!");) || true);
assert(getprop("ro.boot.hwc") == "CN" && (raphael.verify_vendor("V12.0.5.0.QFKCNXM", "1602505832") == "1" || abort("ERROR: This package requires vendor from atleast V12.0.5.0.QFKCNXM. Please upgrade firmware and retry!");) || true);
assert(getprop("ro.boot.hwc") == "GLOBAL" && (raphael.verify_vendor("V12.0.1.0.QFKMIXM", "1591985769") == "1" || abort("ERROR: This package requires vendor from atleast V12.0.1.0.QFKMIXM. Please upgrade firmware and retry!");) || true);
ui_print("Target: Xiaomi/corvus_raphael/raphael:11/RQ1A.201205.008.A1/572eb64af8:userdebug/release-keys");
ui_print("----------------------------------------------");
ui_print("    _____ ____  _______      ___    _  _____  ");
ui_print("   / ____/ __ \|  __ \ \    / / |  | |/ ____| ");
ui_print("  | |   | |  | | |__) \ \  / /| |  | | (___   ");
ui_print("  | |   | |  | |  _  / \ \/ / | |  | |\___ \  ");
ui_print("  | |___| |__| | | \ \  \  /  | |__| |____) | ");
ui_print("   \_____\____/|_|  \_\  \/    \____/|_____/  ");
ui_print("                                              ");
ui_print("    by Ritzz, DeadmanxXD,Jughead & Taran      ");
ui_print("----------------------------------------------");
ui_print(" Android version: 11");
ui_print(" Build id: RQ1A.201205.008.A1");
ui_print(" Build date: 15122020");
ui_print(" Security Patch: 2020-12-05");
ui_print(" Device: raphael");
ui_print("----------------------------------------------");
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/bootdevice/by-name/system", "ext4");
ui_print("Patching system image unconditionally...");
show_progress(0.900000, 0);
block_image_update("/dev/block/bootdevice/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/bootdevice/by-name/system", "ext4");
package_extract_file("boot.img", "/dev/block/bootdevice/by-name/boot");
show_progress(0.100000, 10);
ui_print("Patching firmware images...");
package_extract_file("dtbo.img", "/dev/block/bootdevice/by-name/dtbo");
package_extract_file("vbmeta.img", "/dev/block/bootdevice/by-name/vbmeta");
set_progress(1.000000);
