getprop("ro.product.device") == "gauguin" || abort("E3004: This package is for \"gauguin\" devices; this is a \"" + getprop("ro.product.device") + "\".");
ui_print("Source: Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.2.0.QJSTWXM:user/release-keys");
ui_print("Target: Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.3.0.QJSTWXM:user/release-keys");
ui_print("Verifying current system...");
getprop("ro.build.fingerprint") == "Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.2.0.QJSTWXM:user/release-keys" ||
    getprop("ro.build.fingerprint") == "Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.3.0.QJSTWXM:user/release-keys" ||
    abort("E3001: Package expects build fingerprint of Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.2.0.QJSTWXM:user/release-keys or Redmi/gauguin/gauguin:10/QKQ1.200628.002/V12.0.3.0.QJSTWXM:user/release-keys; this device has " + getprop("ro.build.fingerprint") + ".");
show_progress(0.100000, 10);
patch_partition_check("EMMC:/dev/block/bootdevice/by-name/boot:134217728:58e5392bf37443eb7bd4866a5d13def83e52d439",
                      "EMMC:/dev/block/bootdevice/by-name/boot:134217728:d3f09fd9a095697c56445b306e8990f6fbd140a2") ||
    abort("E3005: \"EMMC:/dev/block/bootdevice/by-name/boot:134217728:58e5392bf37443eb7bd4866a5d13def83e52d439\" or \"EMMC:/dev/block/bootdevice/by-name/boot:134217728:d3f09fd9a095697c56445b306e8990f6fbd140a2\" has unexpected contents.");
apply_patch_space(134217728) || abort("E3006: Not enough free space on /cache to apply patches.");
show_progress(0.100000, 70);
if (range_sha1(map_partition("system"), "64,1,199,227,236,238,239,499,503,515,516,535,536,1853,1854,2285,2286,26188,26189,27556,27557,32768,32770,32933,32953,32968,32969,33183,33185,33345,33349,33357,33358,33366,33370,33375,33376,33405,33409,33413,33414,33905,33909,33925,33926,33938,33944,33945,98306,98469,163842,164005,229378,229541,294914,295077,622611,622612,655361,655380,665744,667776,678358,678501,678502") == "5de5551283984d7bce99cc611bbf0ef95229338d" || block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat")) then
ui_print("Verified system image...");
else
check_first_block(map_partition("system"));
ifelse (block_image_recover(map_partition("system"), "64,1,199,227,236,238,239,499,503,515,516,535,536,1853,1854,2285,2286,26188,26189,27556,27557,32768,32770,32933,32953,32968,32969,33183,33185,33345,33349,33357,33358,33366,33370,33375,33376,33405,33409,33413,33414,33905,33909,33925,33926,33938,33944,33945,98306,98469,163842,164005,229378,229541,294914,295077,622611,622612,655361,655380,665744,667776,678358,678501,678502") && block_image_verify(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat"), ui_print("system recovered successfully."), abort("E1004: system partition fails to recover"));
endif;
if (range_sha1(map_partition("vendor"), "1020,1,117,127,131,136,137,218,222,227,228,234,238,242,243,248,249,512,516,520,521,523,524,526,537,1065,1069,1073,1074,1234,1235,1247,1253,1254,1255,1258,1264,1265,1266,1269,1270,3900,3901,5169,5944,15226,15227,16335,16336,16340,16342,16361,16362,16366,16367,16372,16373,16374,16375,16378,16379,16380,16381,16384,16385,16386,16387,16390,16391,16392,16393,16396,16397,16398,16399,16402,16403,16404,16405,16409,16410,16415,16416,16420,16421,16425,16426,16430,16431,16435,16436,16437,16438,16441,16442,16443,16444,16447,16448,16449,16450,16453,16454,16455,16456,16459,16460,16461,16462,16465,16466,16467,16468,16471,16472,16473,16474,16479,16480,16902,16903,17082,17083,17985,17993,30528,30529,30628,30630,32489,32490,32768,32770,32858,32885,37316,37318,37985,37987,38541,38542,39061,39062,47260,47261,47877,47878,49605,49606,65536,65562,77023,77024,77028,77030,77047,77048,77083,77084,77093,77094,77237,77238,77293,77294,77999,78000,78008,78009,78051,78052,78077,78078,78113,78114,78235,78236,78784,78785,82919,82920,82922,82924,82988,82989,83059,83060,83127,83128,83130,83131,83133,83134,83193,83195,83197,83198,83262,83263,83333,83334,83401,83402,83404,83405,83407,83414,83416,83417,83419,83421,83423,83433,83493,83494,83496,83497,83507,83508,83574,83575,83652,83653,83730,83731,83807,83808,83887,83888,83964,83965,84041,84042,84118,84119,84133,84134,84197,84198,84273,84274,84351,84352,84428,84429,84501,84502,84504,84505,84517,84523,84583,84584,84586,84587,84653,84654,84656,84657,84721,84722,84724,84725,84788,84789,84791,84792,84855,84856,84858,84859,84922,84923,84925,84926,84989,84990,84992,84993,85057,85058,85060,85061,85126,85127,85196,85197,85273,85274,85349,85350,85427,85428,85430,85431,85494,85495,85497,85498,85562,85563,85565,85566,85629,85630,85632,85633,85696,85697,85699,85700,85762,85763,85765,85766,85827,85828,85830,85831,85907,85908,85981,85982,85984,85985,86049,86050,86052,86053,86120,86121,86123,86124,86189,86190,86192,86193,86260,86261,86263,86264,86330,86331,86333,86334,86337,86338,86403,86404,86405,86406,86476,86477,86478,86479,86552,86553,86555,86556,86624,86625,86627,86628,86636,86637,86696,86697,86699,86700,86765,86766,86768,86769,86838,86839,86841,86842,86907,86908,86910,86911,86979,86980,86982,86983,87048,87049,87051,87052,87118,87119,87121,87122,87182,87183,87185,87186,87248,87249,87317,87318,87383,87384,87386,87387,87447,87448,87450,87451,87513,87514,87579,87580,87582,87583,87642,87643,87645,87646,87714,87715,87717,87718,87786,87787,87859,87860,87936,87937,87950,87951,88015,88016,88090,88091,88093,88094,88157,88158,88160,88161,88224,88225,88227,88228,88291,88292,88294,88295,88358,88359,88361,88362,88423,88424,88426,88427,88488,88489,88491,88492,88568,88569,88641,88642,88644,88645,88709,88710,88712,88713,88779,88780,88782,88783,88848,88849,88851,88852,88919,88920,88922,88923,88991,88992,88994,88995,89063,89064,89065,89066,89138,89139,89140,89141,89213,89214,89216,89217,89285,89286,89288,89289,89291,89292,89358,89359,89361,89362,89430,89431,89499,89500,89502,89503,89568,89569,89571,89572,89639,89640,89642,89643,89708,89709,89711,89712,89777,89778,89780,89781,89841,89842,89844,89845,89907,89908,89975,89976,90041,90042,90044,90045,90105,90106,90108,90109,90171,90172,90237,90238,90240,90241,90300,90301,90303,90304,90371,90372,90374,90375,94760,94761,94893,94894,94985,94986,95336,95337,95398,95399,95548,95549,95628,95629,95661,95662,95738,95739,95807,95808,95904,95905,95997,95998,96070,96071,96116,96117,96237,96238,96264,96265,96267,96268,96300,96301,96462,96463,96534,96535,96587,96588,96912,96913,96915,96916,97010,97011,97135,97136,97229,97230,97269,97270,97297,97298,97361,97362,97433,97434,97499,97501,97502,97504,97606,97608,97614,97618,97944,97945,97947,97948,97953,97954,97956,97957,97972,97973,97977,97978,98304,98306,98394,98424,98449,98450,98631,98632,99230,99231,99729,99730,99962,99963,100293,100294,100453,100454,100459,100460,100462,100463,100489,100490,101003,101004,101152,101153,101365,101369,101930,101935,102286,102287,102490,102491,102494,102495,102497,102498,102505,102508,102901,102902,103049,103050,103051,103053,103054,103059,103091,103092,103101,103106,103584,103585,103596,103597,103798,103802,105406,105407,105643,105644,106955,106956,107249,107250,107252,107253,107481,107482,107752,107753,107756,107757,108860,108861,108863,108864,108865,108866,112845,112846,113513,115955,119684,119685,120282,120297,120599,120600,127109,127111,128903,128904,130691,130692,130695,130696,131072,131105,134881,134882,139413,139414,142211,142422,143162,143163,144742,144743,144859,144860,145542,145543,146020,146021,150209,150210,151323,151324,152487,152488,152949,153035,155146,155147,157883,157884,157897,160266,160270,163842,163930,163991,165750,165751,167780,167781,170367,170369,173236,173237,173870,173875,175612,175613,179588,179589,179927,179928,179968,179969,180747,182883,186553,186558,186561,186567,186696,186697,187574,187575,196366,196367,196608,196627,197849,197850,199071,199072,199240,199302,204321,204322,208479,209009,211154,211155,211489,211500,211514,211525,211562,211563,211575,211576,229376,229378,229466,229491,230166,230167,231538,231600,240702,240703,240707,240708,243836,243837,246294,246295,247036,247037,248664,248665,248667,248668,248675,248676,248760,248761,249001,249002,251590,251591,252272,252273,252279,252280,254677,254678,254681,254682,260052,260053,262144,262170,265575,265578,265611,265612,266117,266118,266321,266322,269093,269094,273459,273460,273462,273463,275044,275045,275049,275050,283046,283047,283053,283055,283062,283063,288507,288508,288706,288707,288709,288710,288714,288715,288723,288724,288732,288733,288734,288735,288780,288781,288796,288797,288799,288800,288805,288806,288808,288809,288810,288812,288995,288996,290576,290577,290583,290585,290592,290593,291787,292134,292367,292368,293163,293164,293302,293303,294912,294914,295002,295021,295449,295450,296678,296679,304137,304138,309577,309579,309833,309834,309851,309852,311167,311168,311378,311379,312115,312116,325898,325899,327680,327699,328516,328517,331326,331327,334954,334955,340207,340208,341971,341972,343364,343365,343367,343368,343375,343376,348299,348300,348305,348306,348313,348314,349061,349062,349086,349087,349950,349951,350339,350340,351906,351912,351913,351914,355256,355258,359515,359516,360448,360462,360502,360503,360532,360533,360553,360559,363045,363047,363067,363068,363094,363125,363131,363142,364291,370067,370152,370153") == "91a2cd988f85bce024c479acf0b9dc9444cf9c20" || block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat")) then
ui_print("Verified vendor image...");
else
check_first_block(map_partition("vendor"));
ifelse (block_image_recover(map_partition("vendor"), "1020,1,117,127,131,136,137,218,222,227,228,234,238,242,243,248,249,512,516,520,521,523,524,526,537,1065,1069,1073,1074,1234,1235,1247,1253,1254,1255,1258,1264,1265,1266,1269,1270,3900,3901,5169,5944,15226,15227,16335,16336,16340,16342,16361,16362,16366,16367,16372,16373,16374,16375,16378,16379,16380,16381,16384,16385,16386,16387,16390,16391,16392,16393,16396,16397,16398,16399,16402,16403,16404,16405,16409,16410,16415,16416,16420,16421,16425,16426,16430,16431,16435,16436,16437,16438,16441,16442,16443,16444,16447,16448,16449,16450,16453,16454,16455,16456,16459,16460,16461,16462,16465,16466,16467,16468,16471,16472,16473,16474,16479,16480,16902,16903,17082,17083,17985,17993,30528,30529,30628,30630,32489,32490,32768,32770,32858,32885,37316,37318,37985,37987,38541,38542,39061,39062,47260,47261,47877,47878,49605,49606,65536,65562,77023,77024,77028,77030,77047,77048,77083,77084,77093,77094,77237,77238,77293,77294,77999,78000,78008,78009,78051,78052,78077,78078,78113,78114,78235,78236,78784,78785,82919,82920,82922,82924,82988,82989,83059,83060,83127,83128,83130,83131,83133,83134,83193,83195,83197,83198,83262,83263,83333,83334,83401,83402,83404,83405,83407,83414,83416,83417,83419,83421,83423,83433,83493,83494,83496,83497,83507,83508,83574,83575,83652,83653,83730,83731,83807,83808,83887,83888,83964,83965,84041,84042,84118,84119,84133,84134,84197,84198,84273,84274,84351,84352,84428,84429,84501,84502,84504,84505,84517,84523,84583,84584,84586,84587,84653,84654,84656,84657,84721,84722,84724,84725,84788,84789,84791,84792,84855,84856,84858,84859,84922,84923,84925,84926,84989,84990,84992,84993,85057,85058,85060,85061,85126,85127,85196,85197,85273,85274,85349,85350,85427,85428,85430,85431,85494,85495,85497,85498,85562,85563,85565,85566,85629,85630,85632,85633,85696,85697,85699,85700,85762,85763,85765,85766,85827,85828,85830,85831,85907,85908,85981,85982,85984,85985,86049,86050,86052,86053,86120,86121,86123,86124,86189,86190,86192,86193,86260,86261,86263,86264,86330,86331,86333,86334,86337,86338,86403,86404,86405,86406,86476,86477,86478,86479,86552,86553,86555,86556,86624,86625,86627,86628,86636,86637,86696,86697,86699,86700,86765,86766,86768,86769,86838,86839,86841,86842,86907,86908,86910,86911,86979,86980,86982,86983,87048,87049,87051,87052,87118,87119,87121,87122,87182,87183,87185,87186,87248,87249,87317,87318,87383,87384,87386,87387,87447,87448,87450,87451,87513,87514,87579,87580,87582,87583,87642,87643,87645,87646,87714,87715,87717,87718,87786,87787,87859,87860,87936,87937,87950,87951,88015,88016,88090,88091,88093,88094,88157,88158,88160,88161,88224,88225,88227,88228,88291,88292,88294,88295,88358,88359,88361,88362,88423,88424,88426,88427,88488,88489,88491,88492,88568,88569,88641,88642,88644,88645,88709,88710,88712,88713,88779,88780,88782,88783,88848,88849,88851,88852,88919,88920,88922,88923,88991,88992,88994,88995,89063,89064,89065,89066,89138,89139,89140,89141,89213,89214,89216,89217,89285,89286,89288,89289,89291,89292,89358,89359,89361,89362,89430,89431,89499,89500,89502,89503,89568,89569,89571,89572,89639,89640,89642,89643,89708,89709,89711,89712,89777,89778,89780,89781,89841,89842,89844,89845,89907,89908,89975,89976,90041,90042,90044,90045,90105,90106,90108,90109,90171,90172,90237,90238,90240,90241,90300,90301,90303,90304,90371,90372,90374,90375,94760,94761,94893,94894,94985,94986,95336,95337,95398,95399,95548,95549,95628,95629,95661,95662,95738,95739,95807,95808,95904,95905,95997,95998,96070,96071,96116,96117,96237,96238,96264,96265,96267,96268,96300,96301,96462,96463,96534,96535,96587,96588,96912,96913,96915,96916,97010,97011,97135,97136,97229,97230,97269,97270,97297,97298,97361,97362,97433,97434,97499,97501,97502,97504,97606,97608,97614,97618,97944,97945,97947,97948,97953,97954,97956,97957,97972,97973,97977,97978,98304,98306,98394,98424,98449,98450,98631,98632,99230,99231,99729,99730,99962,99963,100293,100294,100453,100454,100459,100460,100462,100463,100489,100490,101003,101004,101152,101153,101365,101369,101930,101935,102286,102287,102490,102491,102494,102495,102497,102498,102505,102508,102901,102902,103049,103050,103051,103053,103054,103059,103091,103092,103101,103106,103584,103585,103596,103597,103798,103802,105406,105407,105643,105644,106955,106956,107249,107250,107252,107253,107481,107482,107752,107753,107756,107757,108860,108861,108863,108864,108865,108866,112845,112846,113513,115955,119684,119685,120282,120297,120599,120600,127109,127111,128903,128904,130691,130692,130695,130696,131072,131105,134881,134882,139413,139414,142211,142422,143162,143163,144742,144743,144859,144860,145542,145543,146020,146021,150209,150210,151323,151324,152487,152488,152949,153035,155146,155147,157883,157884,157897,160266,160270,163842,163930,163991,165750,165751,167780,167781,170367,170369,173236,173237,173870,173875,175612,175613,179588,179589,179927,179928,179968,179969,180747,182883,186553,186558,186561,186567,186696,186697,187574,187575,196366,196367,196608,196627,197849,197850,199071,199072,199240,199302,204321,204322,208479,209009,211154,211155,211489,211500,211514,211525,211562,211563,211575,211576,229376,229378,229466,229491,230166,230167,231538,231600,240702,240703,240707,240708,243836,243837,246294,246295,247036,247037,248664,248665,248667,248668,248675,248676,248760,248761,249001,249002,251590,251591,252272,252273,252279,252280,254677,254678,254681,254682,260052,260053,262144,262170,265575,265578,265611,265612,266117,266118,266321,266322,269093,269094,273459,273460,273462,273463,275044,275045,275049,275050,283046,283047,283053,283055,283062,283063,288507,288508,288706,288707,288709,288710,288714,288715,288723,288724,288732,288733,288734,288735,288780,288781,288796,288797,288799,288800,288805,288806,288808,288809,288810,288812,288995,288996,290576,290577,290583,290585,290592,290593,291787,292134,292367,292368,293163,293164,293302,293303,294912,294914,295002,295021,295449,295450,296678,296679,304137,304138,309577,309579,309833,309834,309851,309852,311167,311168,311378,311379,312115,312116,325898,325899,327680,327699,328516,328517,331326,331327,334954,334955,340207,340208,341971,341972,343364,343365,343367,343368,343375,343376,348299,348300,348305,348306,348313,348314,349061,349062,349086,349087,349950,349951,350339,350340,351906,351912,351913,351914,355256,355258,359515,359516,360448,360462,360502,360503,360532,360533,360553,360559,363045,363047,363067,363068,363094,363125,363131,363142,364291,370067,370152,370153") && block_image_verify(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat"), ui_print("vendor recovered successfully."), abort("E2004: vendor partition fails to recover"));
endif;
if (range_sha1(map_partition("product"), "356,1,86,5376,5377,5393,5397,5401,5402,9692,9693,9738,9742,11217,11218,11882,11885,11889,11890,11931,11932,11939,11945,11946,11947,11953,11959,11960,11961,11976,11982,11983,11984,12044,12048,12053,12054,14809,14810,18282,18283,18646,18650,19157,19158,19170,19176,19177,19178,21018,21022,22459,22460,29353,29354,29755,29756,32768,32770,32835,32846,36991,36992,45002,45003,46466,46467,57536,57537,57543,57544,57546,57547,57553,57559,57560,57561,57689,57695,57696,57697,57709,57715,57716,57717,57720,57721,57727,57733,57734,57735,57758,57764,57765,57766,58610,58611,65536,65547,65548,65549,72340,72341,88010,88011,88132,88133,88309,88310,88677,88678,89429,89430,95813,95814,98304,98306,98371,98382,100644,100645,102896,102897,103084,103085,103096,103102,103103,103104,103114,103115,103120,103124,103129,103130,103134,103140,103144,103145,103151,103157,103158,103159,103171,103177,103178,103179,103181,103188,103194,103195,104952,104953,104959,104960,105094,105095,106303,106310,106364,106371,106376,106383,106408,106415,106435,106442,106460,106467,106483,106484,106495,106497,106666,106667,106668,106669,106670,106671,106672,106673,106710,106712,106720,106721,106727,106728,107037,107041,107045,107047,107052,107056,107057,107061,107062,107066,107067,107071,107072,107076,107077,107081,107082,107086,107087,107089,107096,107100,107101,107105,107106,107110,107111,107115,107116,107118,107119,107123,107124,107128,107129,107131,107132,107136,107137,107141,107142,107146,107147,107151,107152,107156,107157,107161,107162,107166,107167,107171,107172,107174,107178,107182,107183,107187,107188,107192,107193,107197,107198,107200,107201,107205,107206,107208,107209,107213,107214,107216,107217,107221,107222,107226,107227,107229,107230,107234,107235,107274,107277,107386,108445,108446,112199,112200,122821,122823,122875,122879,125694,125696,131045,131047,131072,131085,134992,134993,139042,139044,140574,140576,140802,140803,142493,142503,146013,146014,150724,150725,150728,150729,151331,151333,151759,151761,151940,151942,151987,151989,152129,152131,153387,153389,154466,154468,154616,154620,154736,154738,157852,157854,158366,158367,159995,159996,160640,160641,163840,163842,163907,163923,164356,164357,166990,166991,171754,171755,171780,171782,171800,199174,199663,199665,202463,202465,204361,204362,204787,204789,204813,229378,229443,265836,266653,270882,270947,270948") == "fa6e380b638b6d53ade98d55ad3a420633b4a9aa" || block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat")) then
ui_print("Verified product image...");
else
check_first_block(map_partition("product"));
ifelse (block_image_recover(map_partition("product"), "356,1,86,5376,5377,5393,5397,5401,5402,9692,9693,9738,9742,11217,11218,11882,11885,11889,11890,11931,11932,11939,11945,11946,11947,11953,11959,11960,11961,11976,11982,11983,11984,12044,12048,12053,12054,14809,14810,18282,18283,18646,18650,19157,19158,19170,19176,19177,19178,21018,21022,22459,22460,29353,29354,29755,29756,32768,32770,32835,32846,36991,36992,45002,45003,46466,46467,57536,57537,57543,57544,57546,57547,57553,57559,57560,57561,57689,57695,57696,57697,57709,57715,57716,57717,57720,57721,57727,57733,57734,57735,57758,57764,57765,57766,58610,58611,65536,65547,65548,65549,72340,72341,88010,88011,88132,88133,88309,88310,88677,88678,89429,89430,95813,95814,98304,98306,98371,98382,100644,100645,102896,102897,103084,103085,103096,103102,103103,103104,103114,103115,103120,103124,103129,103130,103134,103140,103144,103145,103151,103157,103158,103159,103171,103177,103178,103179,103181,103188,103194,103195,104952,104953,104959,104960,105094,105095,106303,106310,106364,106371,106376,106383,106408,106415,106435,106442,106460,106467,106483,106484,106495,106497,106666,106667,106668,106669,106670,106671,106672,106673,106710,106712,106720,106721,106727,106728,107037,107041,107045,107047,107052,107056,107057,107061,107062,107066,107067,107071,107072,107076,107077,107081,107082,107086,107087,107089,107096,107100,107101,107105,107106,107110,107111,107115,107116,107118,107119,107123,107124,107128,107129,107131,107132,107136,107137,107141,107142,107146,107147,107151,107152,107156,107157,107161,107162,107166,107167,107171,107172,107174,107178,107182,107183,107187,107188,107192,107193,107197,107198,107200,107201,107205,107206,107208,107209,107213,107214,107216,107217,107221,107222,107226,107227,107229,107230,107234,107235,107274,107277,107386,108445,108446,112199,112200,122821,122823,122875,122879,125694,125696,131045,131047,131072,131085,134992,134993,139042,139044,140574,140576,140802,140803,142493,142503,146013,146014,150724,150725,150728,150729,151331,151333,151759,151761,151940,151942,151987,151989,152129,152131,153387,153389,154466,154468,154616,154620,154736,154738,157852,157854,158366,158367,159995,159996,160640,160641,163840,163842,163907,163923,164356,164357,166990,166991,171754,171755,171780,171782,171800,199174,199663,199665,202463,202465,204361,204362,204787,204789,204813,229378,229443,265836,266653,270882,270947,270948") && block_image_verify(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat"), ui_print("product recovered successfully."), abort("E2004: product partition fails to recover"));
endif;
if (range_sha1(map_partition("odm"), "8,1,11,12,17,220,226,242,243") == "87f44f74a6a7e4920df949ece723150f6fe9920d" || block_image_verify(map_partition("odm"), package_extract_file("odm.transfer.list"), "odm.new.dat", "odm.patch.dat")) then
ui_print("Verified odm image...");
else
check_first_block(map_partition("odm"));
ifelse (block_image_recover(map_partition("odm"), "8,1,11,12,17,220,226,242,243") && block_image_verify(map_partition("odm"), package_extract_file("odm.transfer.list"), "odm.new.dat", "odm.patch.dat"), ui_print("odm recovered successfully."), abort("E2004: odm partition fails to recover"));
endif;

# ---- start making changes here ----


# ---- radio update tasks ----

ui_print("Patching firmware images...");
package_extract_file("firmware-update/cmnlib64.mbn", "/dev/block/bootdevice/by-name/cmnlib64");
package_extract_file("firmware-update/abl_ecc.elf", "/dev/block/bootdevice/by-name/abl");
package_extract_file("firmware-update/NON-HLOS.bin", "/dev/block/bootdevice/by-name/modem");
package_extract_file("firmware-update/cmnlib.mbn", "/dev/block/bootdevice/by-name/cmnlib");
package_extract_file("firmware-update/hyp.mbn", "/dev/block/bootdevice/by-name/hyp");
package_extract_file("firmware-update/BTFM.bin", "/dev/block/bootdevice/by-name/bluetooth");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tz");
package_extract_file("firmware-update/aop.mbn", "/dev/block/bootdevice/by-name/aop");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_config");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsec");
package_extract_file("firmware-update/uefi_sec.mbn", "/dev/block/bootdevice/by-name/uefisecapp");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfw");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfg");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xbl");
package_extract_file("firmware-update/km4.mbn", "/dev/block/bootdevice/by-name/keymaster");
package_extract_file("firmware-update/cmnlib64.mbn", "/dev/block/bootdevice/by-name/cmnlib64bak");
package_extract_file("firmware-update/abl_ecc.elf", "/dev/block/bootdevice/by-name/ablbak");
package_extract_file("firmware-update/cmnlib.mbn", "/dev/block/bootdevice/by-name/cmnlibbak");
package_extract_file("firmware-update/hyp.mbn", "/dev/block/bootdevice/by-name/hypbak");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tzbak");
package_extract_file("firmware-update/aop.mbn", "/dev/block/bootdevice/by-name/aopbak");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_configbak");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsecbak");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfwbak");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfgbak");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xblbak");
ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/bootdevice/by-name/boot:134217728:58e5392bf37443eb7bd4866a5d13def83e52d439",
                "EMMC:/dev/block/bootdevice/by-name/boot:134217728:d3f09fd9a095697c56445b306e8990f6fbd140a2",
                package_extract_file("boot.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/bootdevice/by-name/boot:134217728:d3f09fd9a095697c56445b306e8990f6fbd140a2");

# ---- radio update tasks ----

ui_print("Patching firmware images...");
package_extract_file("firmware-update/cmnlib64.mbn", "/dev/block/bootdevice/by-name/cmnlib64");
package_extract_file("firmware-update/abl_ecc.elf", "/dev/block/bootdevice/by-name/abl");
package_extract_file("firmware-update/NON-HLOS.bin", "/dev/block/bootdevice/by-name/modem");
package_extract_file("firmware-update/cmnlib.mbn", "/dev/block/bootdevice/by-name/cmnlib");
package_extract_file("firmware-update/hyp.mbn", "/dev/block/bootdevice/by-name/hyp");
package_extract_file("firmware-update/BTFM.bin", "/dev/block/bootdevice/by-name/bluetooth");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tz");
package_extract_file("firmware-update/aop.mbn", "/dev/block/bootdevice/by-name/aop");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_config");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsec");
package_extract_file("firmware-update/uefi_sec.mbn", "/dev/block/bootdevice/by-name/uefisecapp");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfw");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfg");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xbl");
package_extract_file("firmware-update/km4.mbn", "/dev/block/bootdevice/by-name/keymaster");
package_extract_file("firmware-update/cmnlib64.mbn", "/dev/block/bootdevice/by-name/cmnlib64bak");
package_extract_file("firmware-update/abl_ecc.elf", "/dev/block/bootdevice/by-name/ablbak");
package_extract_file("firmware-update/cmnlib.mbn", "/dev/block/bootdevice/by-name/cmnlibbak");
package_extract_file("firmware-update/hyp.mbn", "/dev/block/bootdevice/by-name/hypbak");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tzbak");
package_extract_file("firmware-update/aop.mbn", "/dev/block/bootdevice/by-name/aopbak");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_configbak");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsecbak");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfwbak");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfgbak");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xblbak");
show_progress(0.600000, 600);

# --- Start patching dynamic partitions ---


# Patch partition product

ui_print("Patching product image after verification.");
block_image_update(map_partition("product"), package_extract_file("product.transfer.list"), "product.new.dat", "product.patch.dat") ||
  abort("E2001: Failed to update product image.");

# Update dynamic partition metadata

assert(update_dynamic_partitions(package_extract_file("dynamic_partitions_op_list")));

# Patch partition vendor

ui_print("Patching vendor image after verification.");
block_image_update(map_partition("vendor"), package_extract_file("vendor.transfer.list"), "vendor.new.dat", "vendor.patch.dat") ||
  abort("E2001: Failed to update vendor image.");

# Patch partition system

ui_print("Patching system image after verification.");
block_image_update(map_partition("system"), package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") ||
  abort("E1001: Failed to update system image.");

# Patch partition odm

ui_print("Patching odm image after verification.");
block_image_update(map_partition("odm"), package_extract_file("odm.transfer.list"), "odm.new.dat", "odm.patch.dat") ||
  abort("E2001: Failed to update odm image.");

# --- End patching dynamic partitions ---

show_progress(0.100000, 2);

# ---- radio update tasks 2 ----

ui_print("Patching vbmeta dtbo logo binimages...");
package_extract_file("firmware-update/vbmeta_system.img", "/dev/block/bootdevice/by-name/vbmeta_system");
package_extract_file("firmware-update/dtbo.img", "/dev/block/bootdevice/by-name/dtbo");
package_extract_file("firmware-update/vbmeta.img", "/dev/block/bootdevice/by-name/vbmeta");
