[LG V20 Questions & Answers] Team DevDigitel:
Need some help debugging this code to apply the latest update.

This one is a little tricky. Its checking SHA1 against device, when that was removed it

showed the device had been flashed "r/w" system 22 times " in my case"

Here is the code from the updater script

getprop("ro.product.device") == "elsa" || abort("E3004: This package is for \"elsa\" devices; this is a \"" + getprop("ro.product.device") + "\".");
ui_print("Verifying current system...");
ui_print("Source: lge/elsa_spr_us/elsa:7.0/NRD90M/163481120ca2d:user/release-keys");
ui_print("Target: lge/elsa_spr_us/elsa:7.0/NRD90M/1705318128257:user/release-keys");
ui_print("Verifying current system...");
getprop("ro.build.fingerprint") == "lge/elsa_spr_us/elsa:7.0/NRD90M/163481120ca2d:user/release-keys" ||
getprop("ro.build.fingerprint") == "lge/elsa_spr_us/elsa:7.0/NRD90M/1705318128257:user/release-keys" ||
abort("E3001: Package expects build fingerprint of lge/elsa_spr_us/elsa:7.0/NRD90M/163481120ca2d:user/release-keys or lge/elsa_spr_us/elsa:7.0/NRD90M/1705318128257:user/release-keys; this device has " + getprop("ro.build.fingerprint") + ".");
#
#
#
apply_patch_check("EMMC:/dev/block/bootdevice/by-name/boot:25462996:ca84bd966d575b27f6f31f405dfb3b229b037ff4:25446612:12e9d438ebc09a7c58ece761f26886d148d7104a") || abort("E3005: \"EMMC:/dev/block/bootdevice/by-name/boot:25462996:ca84bd966d575b27f6f31f405dfb3b229b037ff4:25446612:12e9d438ebc09a7c58ece761f26886d148d7104a\" has unexpected contents.");
#
#need to figure this out?
#
ui_print("Skipping CacheFreeSpaceCheck for Block OTA...");
if (range_sha1("/dev/block/bootdevice/by-name/system", "210,1,352,353,814,856,857,22875,22880,22896,22897,28366,28368,29500,29503,31323,31326,32754,32758,32764,32767,32768,32770,33121,33122,33624,65534,65536,65537,66039,98302,98304,98306,98657,98658,112604,131070,131072,131073,131575,163838,163840,163842,164193,164194,164696,196606,196608,196609,197111,229374,229376,229378,229729,229730,230232,262142,262144,262145,262647,294910,294912,294914,295265,295266,295768,327678,327680,327681,328183,360446,360448,360449,360951,393214,393216,393217,393719,420352,420623,425982,425984,425985,426487,435788,435789,458750,458752,458753,459255,470858,491520,491521,492023,493619,524288,524289,524791,557054,557056,557057,557559,589822,589824,589825,590327,590506,622592,622593,623095,623146,655360,655361,655863,668041,688128,688129,688631,688637,720896,720897,721399,753662,753664,753665,754167,786430,786432,786433,786935,819198,819200,819202,819553,819554,820056,851966,851968,851969,852471,884734,884736,884738,885089,885090,885592,917502,917504,917505,918007,950270,950272,950273,950775,983038,983040,983041,983543,1015806,1015808,1015809,1016311,1048574,1048576,1048577,1049079,1081342,1081344,1081345,1081847,1114110,1114112,1114113,1114615,1146878,1146880,1146881,1147383,1179646,1179648,1179649,1180151,1212414,1212416,1212417,1212919,1245182,1245184,1245185,1245687,1277950,1277952,1277953,1278455,1310718,1310720,1310721,1311223,1343486,1343488,1343489,1343991,1376254,1376256,1376257,1376759,1409022,1409217,1420316,1420323,1431552") == "97b8c50f1c397394bf25b3799ab8d9be4f835e6b" || block_image_verify("/dev/block/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat")) then
ui_print("Verified system image...");
else
check_first_block("/dev/block/bootdevice/by-name/system");
ifelse (block_image_recover("/dev/block/bootdevice/by-name/system", "210,1,352,353,814,856,857,22875,22880,22896,22897,28366,28368,29500,29503,31323,31326,32754,32758,32764,32767,32768,32770,33121,33122,33624,65534,65536,65537,66039,98302,98304,98306,98657,98658,112604,131070,131072,131073,131575,163838,163840,163842,164193,164194,164696,196606,196608,196609,197111,229374,229376,229378,229729,229730,230232,262142,262144,262145,262647,294910,294912,294914,295265,295266,295768,327678,327680,327681,328183,360446,360448,360449,360951,393214,393216,393217,393719,420352,420623,425982,425984,425985,426487,435788,435789,458750,458752,458753,459255,470858,491520,491521,492023,493619,524288,524289,524791,557054,557056,557057,557559,589822,589824,589825,590327,590506,622592,622593,623095,623146,655360,655361,655863,668041,688128,688129,688631,688637,720896,720897,721399,753662,753664,753665,754167,786430,786432,786433,786935,819198,819200,819202,819553,819554,820056,851966,851968,851969,852471,884734,884736,884738,885089,885090,885592,917502,917504,917505,918007,950270,950272,950273,950775,983038,983040,983041,983543,1015806,1015808,1015809,1016311,1048574,1048576,1048577,1049079,1081342,1081344,1081345,1081847,1114110,1114112,1114113,1114615,1146878,1146880,1146881,1147383,1179646,1179648,1179649,1180151,1212414,1212416,1212417,1212919,1245182,1245184,1245185,1245687,1277950,1277952,1277953,1278455,1310718,1310720,1310721,1311223,1343486,1343488,1343489,1343991,1376254,1376256,1376257,1376759,1409022,1409217,1420316,1420323,1431552") && block_image_verify("/dev/block/bootdevice/by-name/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;
#
#Above is SHA1 checks to system that fail.
#
# ---- start making changes here ----

ui_print("Patching system image after verification.");
show_progress(0.900000, 0);
block_image_update("/dev/block/bootdevice/by-name/system", package_extract_file("system.transfer.list"), "system.new.dat", "system.patch.dat") ||
abort("E1001: Failed to update system image.");
ui_print("Patching boot image...");
show_progress(0.100000, 10);
apply_patch("EMMC:/dev/block/bootdevice/by-name/boot:25462996:ca84bd966d575b27f6f31f405dfb3b229b037ff4:25446612:12e9d438ebc09a7c58ece761f26886d148d7104a",
"-", 12e9d438ebc09a7c58ece761f26886d148d7104a, 25446612,
ca84bd966d575b27f6f31f405dfb3b229b037ff4,
package_extract_file("patch/boot.img.p")) ||
abort("E3008: Failed to apply patch to EMMC:/dev/block/bootdevice/by-name/boot:25462996:ca84bd966d575b27f6f31f405dfb3b229b037ff4:25446612:12e9d438ebc09a7c58ece761f26886d148d7104a");

if get_stage("/dev/block/bootdevice/by-name/misc", "stage") == "" then
set_stage("/dev/block/bootdevice/by-name/misc", "S-1/3");
endif;
#
#This is backing up stuff and verifying stuff
#
ui_print("Writing radio image...");

if get_stage("/dev/block/bootdevice/by-name/misc", "stage") == "S-1/3" then

ui_print("Step_S1/3");
assert(lge.backupbootloader());

assert(lge.update_gpt());

set_stage("/dev/block/bootdevice/by-name/misc", "S-2/3");
endif;
#
#This is where it actually makes changes
#
if get_stage("/dev/block/bootdevice/by-name/misc", "stage") == "S-2/3" then
ui_print("Step_S2/3");
ui_print("package_extract_file devcfg - /dev/block/bootdevice/by-name/devcfg");
assert(package_extract_file("devcfg", "/dev/block/bootdevice/by-name/devcfg"));
ui_print("package_extract_file modem - /dev/block/bootdevice/by-name/modem");
assert(package_extract_file("modem", "/dev/block/bootdevice/by-name/modem"));
ui_print("package_extract_file xbl - /dev/block/bootdevice/by-name/xbl");
assert(package_extract_file("xbl", "/dev/block/bootdevice/by-name/xbl"));
ui_print("package_extract_file raw_resources - /dev/block/bootdevice/by-name/raw_resources");
assert(package_extract_file("raw_resources", "/dev/block/bootdevice/by-name/raw_resources"));
ui_print("package_extract_file factory - /dev/block/bootdevice/by-name/factory");
assert(package_extract_file("factory", "/dev/block/bootdevice/by-name/factory"));
ui_print("package_extract_file keymaster - /dev/block/bootdevice/by-name/keymaster");
assert(package_extract_file("keymaster", "/dev/block/bootdevice/by-name/keymaster"));
ui_print("package_extract_file pmic - /dev/block/bootdevice/by-name/pmic");
assert(package_extract_file("pmic", "/dev/block/bootdevice/by-name/pmic"));
ui_print("package_extract_file rpm - /dev/block/bootdevice/by-name/rpm");
assert(package_extract_file("rpm", "/dev/block/bootdevice/by-name/rpm"));
ui_print("package_extract_file laf - /dev/block/bootdevice/by-name/laf");
assert(package_extract_file("laf", "/dev/block/bootdevice/by-name/laf"));
ui_print("package_extract_file hyp - /dev/block/bootdevice/by-name/hyp");
assert(package_extract_file("hyp", "/dev/block/bootdevice/by-name/hyp"));
ui_print("package_extract_file cmnlib64 - /dev/block/bootdevice/by-name/cmnlib64");
assert(package_extract_file("cmnlib64", "/dev/block/bootdevice/by-name/cmnlib64"));
ui_print("package_extract_file tz - /dev/block/bootdevice/by-name/tz");
assert(package_extract_file("tz", "/dev/block/bootdevice/by-name/tz"));
ui_print("package_extract_file xbl2 - /dev/block/bootdevice/by-name/xbl2");
assert(package_extract_file("xbl2", "/dev/block/bootdevice/by-name/xbl2"));
ui_print("package_extract_file cmnlib - /dev/block/bootdevice/by-name/cmnlib");
assert(package_extract_file("cmnlib", "/dev/block/bootdevice/by-name/cmnlib"));
ui_print("package_extract_file sec - /dev/block/bootdevice/by-name/sec");
assert(package_extract_file("sec", "/dev/block/bootdevice/by-name/sec"));
set_stage("/dev/block/bootdevice/by-name/misc", "S-3/3");
endif;
#
#Not Sure what this is?
#
if get_stage("/dev/block/bootdevice/by-name/misc", "stage") == "S-3/3" then
ui_print("Step_S3/3");
assert(lge.recover_gpt());
endif;
#
#
#
set_progress(1.000000);