getprop("ro.product.device") == "citrus" || abort("E3004: This package is for \"citrus\" devices; this is a \"" + getprop("ro.product.device") + "\".");
ui_print("Source: POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.1.0.QJFEUXM:user/release-keys");
ui_print("Target: POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.3.0.QJFEUXM:user/release-keys");
ui_print("Verifying current system...");
getprop("ro.build.fingerprint") == "POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.1.0.QJFEUXM:user/release-keys" ||
    getprop("ro.build.fingerprint") == "POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.3.0.QJFEUXM:user/release-keys" ||
    abort("E3001: Package expects build fingerprint of POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.1.0.QJFEUXM:user/release-keys or POCO/citrus_eea/citrus:10/QKQ1.200830.002/V12.0.3.0.QJFEUXM: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:100663296:6d878f7773b1e6090914d09ec98ff788d86f54d7",
                      "EMMC:/dev/block/bootdevice/by-name/boot:100663296:0580148f67a84b0f7add9affaa1dad3b6b69b8a2") ||
    abort("E3005: \"EMMC:/dev/block/bootdevice/by-name/boot:100663296:6d878f7773b1e6090914d09ec98ff788d86f54d7\" or \"EMMC:/dev/block/bootdevice/by-name/boot:100663296:0580148f67a84b0f7add9affaa1dad3b6b69b8a2\" has unexpected contents.");
apply_patch_space(100663296) || abort("E3006: Not enough free space on /cache to apply patches.");
show_progress(0.100000, 70);
if (range_sha1(map_partition("system"), "534,1,200,228,237,257,258,518,522,534,535,554,555,1872,1873,2303,2304,26210,26211,27578,27579,32768,32770,32935,32954,32992,32993,33207,33209,33372,33374,33384,33385,33393,33395,33402,33403,38280,38281,38293,38295,38301,38302,39601,39605,39639,39640,39646,39648,39653,39654,39659,39661,39666,39667,39787,39791,39799,39800,41599,41600,41651,41652,41738,41739,41839,41840,41907,41908,42292,42294,42335,42336,43300,43301,43951,43953,45884,45886,45894,45895,45917,45918,45922,45923,46356,46357,46388,46390,46395,46396,46495,46497,46502,46503,49268,49270,49300,49301,49315,49317,49322,49323,49325,49326,52696,52698,52742,52743,53113,53115,53125,53126,53213,53217,53224,53225,53871,53872,53974,53989,53994,53997,53998,54034,54320,54321,54337,54338,54469,54470,54472,54473,54475,54476,61767,61769,61796,61797,61926,61928,61936,61937,62415,62417,62435,62436,65536,65555,67095,67097,67193,67194,67199,67201,67206,67207,67245,67247,67252,67253,67940,67942,67966,67967,68215,68216,68249,68251,68256,68257,68733,68735,68753,68754,69225,69227,69232,69233,70995,70997,71042,71043,71047,71049,71054,71055,71077,71079,71105,71106,72810,72812,72838,72839,73685,73687,73712,73713,73796,73798,73805,73806,77113,77115,80901,80902,82471,82473,84637,84638,84970,84972,84973,84974,85006,85008,85032,85033,85483,85485,85890,85891,86574,86576,86593,86594,88979,88981,89030,89031,89441,89443,89458,89459,91525,91526,97481,97483,97574,97575,98304,98306,98471,98490,99182,99184,99213,99214,104153,104154,106182,106183,106715,106717,106841,106842,119431,119433,119458,119459,121852,121854,121906,121907,123661,123663,123699,123700,123738,123742,123748,123749,127097,127098,127636,127638,127678,127679,130332,130333,131072,131091,131555,131557,131582,131583,131993,131997,132014,132015,133128,133130,133158,133159,134208,134210,134233,134234,140587,140588,151024,151025,156465,156467,156712,156713,156723,156725,156734,156735,161515,161516,163840,163842,164007,164026,164553,164555,164640,164641,167206,167208,167250,167251,167302,167304,167310,167311,167314,167318,167324,167325,167330,167332,167337,167338,171211,171213,171282,171283,171367,171369,171376,171377,171379,171381,171386,171387,171431,171433,171438,171439,173249,173253,173297,173298,173687,173691,173703,173704,173900,173902,173908,173909,180833,180834,182097,182101,182180,182181,182187,182188,182229,182230,182267,182269,182274,182275,185350,185352,185392,185393,185463,185465,185471,185472,185575,185577,185584,185585,186800,186802,186830,186831,192390,192466,192488,192489,194424,194426,194561,194562,194570,194572,194577,194578,195203,195205,195222,195223,196608,196627,196730,196732,196749,196750,199077,199079,199107,199108,199998,200000,200028,200029,200033,200035,200040,200041,200063,200065,200070,200071,200075,200077,200087,200088,200103,200105,200110,200111,201094,201096,202845,202846,202870,202872,202877,202878,205940,205942,205992,205993,206296,206298,206312,206313,206671,206675,206686,229378,229543,294914,295079,649760,649809,649810,649825,649827,649832,654930,654973,654974,655360,655377,656614,656616,657797,657798,657956,657958,657964,657965,657973,657975,657980,657981,658023,658025,658030,658031,666396,666398,666464,666465,666493,666497,666503,666504,668666,668668,668709,668710,669483,669485,669512,669513,669600,669602,669610,669611,669920,669922,669938,669941,670025,673409,673748,673749,673752,673753,673772,673773,673827,673829,673838,673840,673955,673956,673957,673960,676044,686758,686903,686904") == "41836babbedd5500bcd7c4ecf54876f44eada4c6" || 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"), "534,1,200,228,237,257,258,518,522,534,535,554,555,1872,1873,2303,2304,26210,26211,27578,27579,32768,32770,32935,32954,32992,32993,33207,33209,33372,33374,33384,33385,33393,33395,33402,33403,38280,38281,38293,38295,38301,38302,39601,39605,39639,39640,39646,39648,39653,39654,39659,39661,39666,39667,39787,39791,39799,39800,41599,41600,41651,41652,41738,41739,41839,41840,41907,41908,42292,42294,42335,42336,43300,43301,43951,43953,45884,45886,45894,45895,45917,45918,45922,45923,46356,46357,46388,46390,46395,46396,46495,46497,46502,46503,49268,49270,49300,49301,49315,49317,49322,49323,49325,49326,52696,52698,52742,52743,53113,53115,53125,53126,53213,53217,53224,53225,53871,53872,53974,53989,53994,53997,53998,54034,54320,54321,54337,54338,54469,54470,54472,54473,54475,54476,61767,61769,61796,61797,61926,61928,61936,61937,62415,62417,62435,62436,65536,65555,67095,67097,67193,67194,67199,67201,67206,67207,67245,67247,67252,67253,67940,67942,67966,67967,68215,68216,68249,68251,68256,68257,68733,68735,68753,68754,69225,69227,69232,69233,70995,70997,71042,71043,71047,71049,71054,71055,71077,71079,71105,71106,72810,72812,72838,72839,73685,73687,73712,73713,73796,73798,73805,73806,77113,77115,80901,80902,82471,82473,84637,84638,84970,84972,84973,84974,85006,85008,85032,85033,85483,85485,85890,85891,86574,86576,86593,86594,88979,88981,89030,89031,89441,89443,89458,89459,91525,91526,97481,97483,97574,97575,98304,98306,98471,98490,99182,99184,99213,99214,104153,104154,106182,106183,106715,106717,106841,106842,119431,119433,119458,119459,121852,121854,121906,121907,123661,123663,123699,123700,123738,123742,123748,123749,127097,127098,127636,127638,127678,127679,130332,130333,131072,131091,131555,131557,131582,131583,131993,131997,132014,132015,133128,133130,133158,133159,134208,134210,134233,134234,140587,140588,151024,151025,156465,156467,156712,156713,156723,156725,156734,156735,161515,161516,163840,163842,164007,164026,164553,164555,164640,164641,167206,167208,167250,167251,167302,167304,167310,167311,167314,167318,167324,167325,167330,167332,167337,167338,171211,171213,171282,171283,171367,171369,171376,171377,171379,171381,171386,171387,171431,171433,171438,171439,173249,173253,173297,173298,173687,173691,173703,173704,173900,173902,173908,173909,180833,180834,182097,182101,182180,182181,182187,182188,182229,182230,182267,182269,182274,182275,185350,185352,185392,185393,185463,185465,185471,185472,185575,185577,185584,185585,186800,186802,186830,186831,192390,192466,192488,192489,194424,194426,194561,194562,194570,194572,194577,194578,195203,195205,195222,195223,196608,196627,196730,196732,196749,196750,199077,199079,199107,199108,199998,200000,200028,200029,200033,200035,200040,200041,200063,200065,200070,200071,200075,200077,200087,200088,200103,200105,200110,200111,201094,201096,202845,202846,202870,202872,202877,202878,205940,205942,205992,205993,206296,206298,206312,206313,206671,206675,206686,229378,229543,294914,295079,649760,649809,649810,649825,649827,649832,654930,654973,654974,655360,655377,656614,656616,657797,657798,657956,657958,657964,657965,657973,657975,657980,657981,658023,658025,658030,658031,666396,666398,666464,666465,666493,666497,666503,666504,668666,668668,668709,668710,669483,669485,669512,669513,669600,669602,669610,669611,669920,669922,669938,669941,670025,673409,673748,673749,673752,673753,673772,673773,673827,673829,673838,673840,673955,673956,673957,673960,676044,686758,686903,686904") && 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"), "502,1,102,112,114,121,122,204,206,213,214,1888,1890,2369,2370,2633,2635,2641,2642,2644,2648,2650,2661,2684,2685,2721,2723,2775,2776,2937,2938,2950,2952,2958,2959,2962,2964,2969,2970,2982,2984,2990,2993,3006,3007,5220,5221,8708,8709,9476,9477,9481,9482,9486,9487,9491,9492,9497,9498,9502,9503,9504,9505,9508,9509,9510,9511,9514,9515,9516,9517,9519,9521,9522,9523,9526,9527,9528,9529,9532,9533,9534,9535,9538,9539,9545,9546,9550,9551,9554,9556,9559,9561,9565,9566,9570,9571,9572,9573,9576,9577,9578,9579,9582,9583,9584,9585,9588,9589,9590,9591,9594,9595,9596,9597,9600,9601,9606,9607,9608,9609,9613,9614,10026,10027,11116,11121,25290,25291,25390,25392,29972,29976,32768,32770,32842,32881,43205,43206,43208,43210,43274,43275,43345,43346,43413,43414,43416,43417,43419,43420,43479,43481,43483,43484,43548,43549,43619,43620,43687,43688,43690,43691,43693,43696,43697,43699,43701,43702,43708,43709,43711,43712,43715,43716,43726,43729,43731,43732,43734,43736,43739,43740,43749,43750,43752,43753,43755,43766,43826,43827,43829,43830,43840,43841,43907,43908,43985,43986,43996,43997,44063,44064,44140,44141,44220,44221,44297,44298,44374,44375,44451,44452,44462,44463,44466,44467,44530,44531,44606,44607,44617,44618,44684,44685,44761,44762,44834,44835,44837,44838,44850,44854,44856,44857,44859,44861,44864,44865,44869,44870,44872,44873,44876,44877,46143,46145,46150,46152,46190,46192,46372,46373,46383,46384,46388,46389,46522,46523,47800,47801,52021,52022,52625,55360,58911,58912,59506,59521,59823,59824,65536,65575,66482,66483,67886,67948,71724,71725,72169,72170,78687,78688,79429,79430,81399,81400,81403,81404,85557,85558,92008,92009,92015,92017,92024,92025,92105,92106,92166,92167,98304,98306,98378,98416,98559,98561,98640,98641,105174,105175,109005,109006,109098,109099,109560,109561,113601,113602,117528,117529,117916,117917,119886,119915,121731,121732,128888,128889,131072,131094,133324,133325,133338,134937,134940,137354,138595,138596,138984,138985,141987,141989,144963,144964,144968,144969,145185,145187,147031,147032,163840,163842,163914,163939,174335,174336,174795,174796,175646,178010,181385,181390,181393,181399,181528,181529,182415,182416,191435,191436,192839,192901,196608,196634,196885,196886,197075,197076,198043,198044,203611,203612,206055,206056,206797,206798,210542,210543,210546,210547,215917,215918,221414,221417,221450,221451,222322,222323,224453,224454,224460,224462,224469,224470,229376,229378,229450,229471,231610,231611,231615,231616,231622,231623,237264,237265,237281,237282,237283,237285,237286,237288,237289,237291,237292,237294,237295,237296,237352,237354,237355,237356,237358,237359,237361,237362,237548,237549,238464,238465,243781,243782,255286,255288,255622,255624,256976,256977,258167,258168,260860,260861,262144,262164,263302,263303,268945,268946,272286,272287,273728,273729,278372,278373,278379,278381,278388,278389,279538,279539,279563,279564,280427,280428,280641,280642,282205,282211,282212,282213,284609,284610,286272,286273,287663,287665,292214,292215,294754,294756,294807,294818,294912,294914,294986,295002,295006,295046,295877,300568,300641,300642") == "d17d3212c171368a27db3b96a1b2f75f1dee343b" || 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"), "502,1,102,112,114,121,122,204,206,213,214,1888,1890,2369,2370,2633,2635,2641,2642,2644,2648,2650,2661,2684,2685,2721,2723,2775,2776,2937,2938,2950,2952,2958,2959,2962,2964,2969,2970,2982,2984,2990,2993,3006,3007,5220,5221,8708,8709,9476,9477,9481,9482,9486,9487,9491,9492,9497,9498,9502,9503,9504,9505,9508,9509,9510,9511,9514,9515,9516,9517,9519,9521,9522,9523,9526,9527,9528,9529,9532,9533,9534,9535,9538,9539,9545,9546,9550,9551,9554,9556,9559,9561,9565,9566,9570,9571,9572,9573,9576,9577,9578,9579,9582,9583,9584,9585,9588,9589,9590,9591,9594,9595,9596,9597,9600,9601,9606,9607,9608,9609,9613,9614,10026,10027,11116,11121,25290,25291,25390,25392,29972,29976,32768,32770,32842,32881,43205,43206,43208,43210,43274,43275,43345,43346,43413,43414,43416,43417,43419,43420,43479,43481,43483,43484,43548,43549,43619,43620,43687,43688,43690,43691,43693,43696,43697,43699,43701,43702,43708,43709,43711,43712,43715,43716,43726,43729,43731,43732,43734,43736,43739,43740,43749,43750,43752,43753,43755,43766,43826,43827,43829,43830,43840,43841,43907,43908,43985,43986,43996,43997,44063,44064,44140,44141,44220,44221,44297,44298,44374,44375,44451,44452,44462,44463,44466,44467,44530,44531,44606,44607,44617,44618,44684,44685,44761,44762,44834,44835,44837,44838,44850,44854,44856,44857,44859,44861,44864,44865,44869,44870,44872,44873,44876,44877,46143,46145,46150,46152,46190,46192,46372,46373,46383,46384,46388,46389,46522,46523,47800,47801,52021,52022,52625,55360,58911,58912,59506,59521,59823,59824,65536,65575,66482,66483,67886,67948,71724,71725,72169,72170,78687,78688,79429,79430,81399,81400,81403,81404,85557,85558,92008,92009,92015,92017,92024,92025,92105,92106,92166,92167,98304,98306,98378,98416,98559,98561,98640,98641,105174,105175,109005,109006,109098,109099,109560,109561,113601,113602,117528,117529,117916,117917,119886,119915,121731,121732,128888,128889,131072,131094,133324,133325,133338,134937,134940,137354,138595,138596,138984,138985,141987,141989,144963,144964,144968,144969,145185,145187,147031,147032,163840,163842,163914,163939,174335,174336,174795,174796,175646,178010,181385,181390,181393,181399,181528,181529,182415,182416,191435,191436,192839,192901,196608,196634,196885,196886,197075,197076,198043,198044,203611,203612,206055,206056,206797,206798,210542,210543,210546,210547,215917,215918,221414,221417,221450,221451,222322,222323,224453,224454,224460,224462,224469,224470,229376,229378,229450,229471,231610,231611,231615,231616,231622,231623,237264,237265,237281,237282,237283,237285,237286,237288,237289,237291,237292,237294,237295,237296,237352,237354,237355,237356,237358,237359,237361,237362,237548,237549,238464,238465,243781,243782,255286,255288,255622,255624,256976,256977,258167,258168,260860,260861,262144,262164,263302,263303,268945,268946,272286,272287,273728,273729,278372,278373,278379,278381,278388,278389,279538,279539,279563,279564,280427,280428,280641,280642,282205,282211,282212,282213,284609,284610,286272,286273,287663,287665,292214,292215,294754,294756,294807,294818,294912,294914,294986,295002,295006,295046,295877,300568,300641,300642") && 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"), "320,1,93,5383,5384,5400,5402,5408,5409,9699,9700,9745,9747,11224,11225,11889,11890,11896,11897,11938,11939,11946,11948,11953,11954,12671,12673,12682,12683,12689,12691,12696,12697,15452,15453,18925,18926,21333,21334,21697,21699,22208,22209,22221,22223,22228,22229,24069,24071,25510,25511,32404,32405,32768,32770,32841,32853,32891,32892,40057,40058,48060,48061,49524,49525,60594,60595,62853,62854,63230,63231,63309,63311,65536,65548,66691,66693,74173,74174,74180,74181,74187,74189,74194,74195,74323,74325,74330,74331,74343,74345,74350,74351,74354,74355,74361,74363,74368,74369,74392,74394,74399,74400,75244,75245,88943,88944,88963,88964,90930,90931,98304,98306,98377,98389,104834,104835,105011,105012,105379,105380,106131,106132,112515,112516,117268,117269,119520,119521,119708,119709,119720,119722,119727,119728,119738,119739,119744,119746,119753,119754,119758,119762,119768,119769,119775,119777,119782,119783,119795,119797,119802,119803,119813,119815,119820,119821,119823,119826,119836,119837,121594,121595,121601,121602,121736,121737,122945,122948,123021,123024,123033,123036,123070,123073,123096,123099,123121,123124,123144,123145,123156,123158,123328,123329,123330,123331,123332,123333,123334,123335,123373,123375,123383,123384,123390,123391,123752,123754,123967,123968,124016,124017,124083,124084,125150,125151,128959,128960,130164,130165,131072,131084,135240,135241,136863,136866,152049,152051,155983,155984,160033,160035,161565,161567,161793,161794,163484,163494,163840,163842,163913,163927,167091,167092,171802,171803,171806,171807,175061,175064,178113,178114,185138,185139,186766,186767,187411,187412,191044,191045,193678,193679,196608,196673,198507,198508,205589,205590,217004,217005,217071,217072,217138,217139,219010,219011,219013,219014,219029,219030,219111,219112,229376,229378,229449,229498,230986,230987,231780,231782,231808,231809,241992,241993,242503,242504,243133,243137,262144,262148,264353,264355,269414,269416,277750,277751,277781,277783,277788,277789,280351,280352,280360,280362,280366,280367,280653,280657,280668,280671,280697,280700,280714,280717,284051,284052,291444,296065,296137,296138") == "c7e22e45de8d52396a981405decd242d7da03e42" || 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
ifelse (block_image_recover(map_partition("product"), "320,1,93,5383,5384,5400,5402,5408,5409,9699,9700,9745,9747,11224,11225,11889,11890,11896,11897,11938,11939,11946,11948,11953,11954,12671,12673,12682,12683,12689,12691,12696,12697,15452,15453,18925,18926,21333,21334,21697,21699,22208,22209,22221,22223,22228,22229,24069,24071,25510,25511,32404,32405,32768,32770,32841,32853,32891,32892,40057,40058,48060,48061,49524,49525,60594,60595,62853,62854,63230,63231,63309,63311,65536,65548,66691,66693,74173,74174,74180,74181,74187,74189,74194,74195,74323,74325,74330,74331,74343,74345,74350,74351,74354,74355,74361,74363,74368,74369,74392,74394,74399,74400,75244,75245,88943,88944,88963,88964,90930,90931,98304,98306,98377,98389,104834,104835,105011,105012,105379,105380,106131,106132,112515,112516,117268,117269,119520,119521,119708,119709,119720,119722,119727,119728,119738,119739,119744,119746,119753,119754,119758,119762,119768,119769,119775,119777,119782,119783,119795,119797,119802,119803,119813,119815,119820,119821,119823,119826,119836,119837,121594,121595,121601,121602,121736,121737,122945,122948,123021,123024,123033,123036,123070,123073,123096,123099,123121,123124,123144,123145,123156,123158,123328,123329,123330,123331,123332,123333,123334,123335,123373,123375,123383,123384,123390,123391,123752,123754,123967,123968,124016,124017,124083,124084,125150,125151,128959,128960,130164,130165,131072,131084,135240,135241,136863,136866,152049,152051,155983,155984,160033,160035,161565,161567,161793,161794,163484,163494,163840,163842,163913,163927,167091,167092,171802,171803,171806,171807,175061,175064,178113,178114,185138,185139,186766,186767,187411,187412,191044,191045,193678,193679,196608,196673,198507,198508,205589,205590,217004,217005,217071,217072,217138,217139,219010,219011,219013,219014,219029,219030,219111,219112,229376,229378,229449,229498,230986,230987,231780,231782,231808,231809,241992,241993,242503,242504,243133,243137,262144,262148,264353,264355,269414,269416,277750,277751,277781,277783,277788,277789,280351,280352,280360,280362,280366,280367,280653,280657,280668,280671,280697,280700,280714,280717,284051,284052,291444,296065,296137,296138") && 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;

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

ui_print("Patching boot image...");
show_progress(0.100000, 10);
patch_partition("EMMC:/dev/block/bootdevice/by-name/boot:100663296:6d878f7773b1e6090914d09ec98ff788d86f54d7",
                "EMMC:/dev/block/bootdevice/by-name/boot:100663296:0580148f67a84b0f7add9affaa1dad3b6b69b8a2",
                package_extract_file("boot.img.p")) ||
    abort("E3008: Failed to apply patch to EMMC:/dev/block/bootdevice/by-name/boot:100663296:0580148f67a84b0f7add9affaa1dad3b6b69b8a2");

# ---- 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/imagefv.elf", "/dev/block/bootdevice/by-name/ImageFv");
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/km4.mbn", "/dev/block/bootdevice/by-name/keymaster");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tz");
package_extract_file("firmware-update/featenabler.mbn", "/dev/block/bootdevice/by-name/featenabler");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_config");
package_extract_file("firmware-update/BTFM.bin", "/dev/block/bootdevice/by-name/bluetooth");
package_extract_file("firmware-update/uefi_sec.mbn", "/dev/block/bootdevice/by-name/uefisecapp");
package_extract_file("firmware-update/NON-HLOS.bin", "/dev/block/bootdevice/by-name/modem");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfw");
package_extract_file("firmware-update/abl.elf", "/dev/block/bootdevice/by-name/abl");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfg");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsec");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xbl");
package_extract_file("firmware-update/rpm.mbn", "/dev/block/bootdevice/by-name/rpm");
package_extract_file("firmware-update/cmnlib64.mbn", "/dev/block/bootdevice/by-name/cmnlib64bak");
package_extract_file("firmware-update/imagefv.elf", "/dev/block/bootdevice/by-name/ImageFvbak");
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/km4.mbn", "/dev/block/bootdevice/by-name/keymasterbak");
package_extract_file("firmware-update/tz.mbn", "/dev/block/bootdevice/by-name/tzbak");
package_extract_file("firmware-update/xbl_config.elf", "/dev/block/bootdevice/by-name/xbl_configbak");
package_extract_file("firmware-update/uefi_sec.mbn", "/dev/block/bootdevice/by-name/uefisecappbak");
package_extract_file("firmware-update/qupv3fw.elf", "/dev/block/bootdevice/by-name/qupfwbak");
package_extract_file("firmware-update/abl.elf", "/dev/block/bootdevice/by-name/ablbak");
package_extract_file("firmware-update/devcfg.mbn", "/dev/block/bootdevice/by-name/devcfgbak");
package_extract_file("firmware-update/storsec.mbn", "/dev/block/bootdevice/by-name/storsecbak");
package_extract_file("firmware-update/xbl.elf", "/dev/block/bootdevice/by-name/xblbak");
package_extract_file("firmware-update/rpm.mbn", "/dev/block/bootdevice/by-name/rpmbak");
show_progress(0.600000, 600);

# --- Start patching dynamic partitions ---


# Update dynamic partition metadata

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

# 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.");

# 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.");

# --- 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/dtbo.img", "/dev/block/bootdevice/by-name/dtbo");
package_extract_file("firmware-update/vbmeta.img", "/dev/block/bootdevice/by-name/vbmeta");
package_extract_file("firmware-update/vbmeta_system.img", "/dev/block/bootdevice/by-name/vbmeta_system");
