ui_print("Target: oneplus/bacon/A0001:6.0.1/MHC19Q/ZNH2KAS1KN:user/release-keys");
ifelse(is_mounted("/system"), unmount("/system"));
ui_print("#######################################");
ui_print("# _____            __  __  ______     #");
ui_print("#/\  __`\  /'\_/`\/\ \/\ \/\__  _\    #");
ui_print("#\ \ \/\ \/\  ``  \ \ ` \ \/_/\ \/    #");
ui_print("# \ \ \ \ \ \ \__\ \ \ . ` \ \ \ \    #");
ui_print("#  \ \ \_\ \ \ \_/\ \ \ \`\ \ \_\ \__ #");
ui_print("#   \ \_____\ \_\, \_\ \_\ \_\/\_____\#");
ui_print("#    \/_____/\/_/ \/_/\/_/\/_/\/_____/#");
ui_print("#                                     #");
ui_print("#######################################");
ui_print("Backup");
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
run_program("/system/bin/backuptool.sh", "backup");
unmount("/system");
show_progress(0.750000, 0);
ui_print("Patching system image unconditionally...");
block_image_update("/dev/block/platform/msm_sdcc.1/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") ||
  abort("E1001: Failed to update system image.");
ui_print("Restore");
show_progress(0.020000, 10);
mount("ext4", "EMMC", "/dev/block/platform/msm_sdcc.1/by-name/system", "/system", "");
run_program("/system/bin/backuptool.sh", "restore");
unmount("/system");
show_progress(0.050000, 5);
package_extract_file("boot.img", "/dev/block/platform/msm_sdcc.1/by-name/boot");
show_progress(0.200000, 10);
set_progress(1.000000);
