[G2 General] feldenthorne:
Hi, all,

I recently helped an acquaintance that was having a terrible time with an assert_failed error with Loki while trying to install CM 10.2, so I figured I'd explain the problem and solution.

Backing up to the beginning, this acquaintance recently upgraded to the G2 (a few weeks ago) and wanted to test out KitKat. Here, we discovered that the phone had been updated to VS98012b before he'd received it - but rather than reverting to stock, we decided to use the root solution detailed here (http://wiki.cyanogenmod.org/w/Install_CM_for_d802), but we swapped the Loki flash method to that detailed here (http://xdaforums.com/showthread.php?t=2449670) and used the CWM no-touch image from here (http://xdaforums.com/showthread.php?t=2498941). [For reference, the touch image doesn't flash properly... but the one without touch is still touch-enabled.]

After gaining root and getting CWM up and running, we decided on the Nightly CM 11 build (ro.build.date=Sat Jan 18 08:04:40 PST 2014) and it flashed with the recommended GApps without a hitch.

Fast-forward three days and said acquaintance is having tons of crashing issues and some apps weren't working too well - certainly not far-fetched for a nightly build. We decided to flash him back to CM 10.2. However, after doing a factory reset, wiping the cache again to be sure, then wiping the dalvik cache, and finally running the CM 10.2 stable version available here (http://download.cyanogenmod.org/get/jenkins/49892/cm-10.2.0-vs980.zip, date: 2013-12-02 21:45:13) we ran into the following error during the install:

script aborted: assert failed: run_program("/tmp/loki.sh") == 0
assert failed: run_program("/tmp/loki.sh") == 0

Neat.

Some digging lead to a Pastebin (http://pastebin.com/uLtw2vG6) with an explanation of the problem and a proposed solution:

Shelnutt2@ : autoprime, thats 9/10 times because old loki_patch
...
Shelnutt2@ : if they are stuck in recovery completely because they wiped everything then just remove the assert line you meniotned and flash the rom then flash the zip I just linked

Since I've poked around with ROMs before, I unzipped the CM 10.2 ROM and popped the /cm-10.2.0-vs980/META-INF/com/google/android/updater-script file open to remove the assert line and the deletion line, incidentally. But reflashing the ROM and the linked zip that Shellnutt2 suggested (http://downloads.codefi.re/shelnutt2/freegee/loki_boot.zip, for the curious) didn't actually work for us. Much of the problem, I suppose, had to do with the data and system partitions not being loaded in the loki_boot.zip updater-script.

So a bit of thought lead me to check the CM 11 commits for updates to enable functionality for the VS98012b update - bingo! A conveniently close-to-the-top update (http://review.cyanogenmod.org/#/c/56181/) mentioned that, as Shellnutt2 suggested, loki_flash was updated for this precise reason. Now, I wasn't about the pull the whole CM 10.2 repo and build with the updated loki_flash.c, so I just copied the newest CM 11 nightly's /system/bin/loki_flash, /system/bin/loki_patch, and /system/bin/loki.sh into the CM 10.2 ROM's /system/bin/ and overwrote the old ones (after reverting the updater-script changes, of course). After rezipping, the install worked like a charm!

---

[TLDR]

If you're having

script aborted: assert failed: run_program("/tmp/loki.sh") == 0
assert failed: run_program("/tmp/loki.sh") == 0

errors,

1) grab the latest CM distribution and copy the loki_flash, loki_patch, and loki.sh files out of /system/bin/ (or from https://www.mediafire.com/?y3ubxgnxzxq89f9, which are from the Tue Jan 21 13:05:13 PST 2014 CM11 Nightly) and

2) paste them over the /system/bin/ equivalents in whatever VS980 ROM you're having problems with,

3) rezip,

4) and clean flash the ROM in recovery.

Presumably, this workaround should work for all VS980 ROMs (tested for CM10.2 and OSE) that haven't updated their loki_patch versions. It probably won't work for any other phone that has loki.sh failed assertions - the GitHub master loki repo (https://github.com/djrbliss/loki/blob/master/loki_flash.c) doesn't say anything like the CM 11 distro, so it's likely a check coded in. But I didn't take the time to look into that on the CM side.

EDIT: This should also work for devices other than the VS980 - I looked up loki_flash.c rather than loki_patch.c (https://github.com/djrbliss/loki/blob/master/loki_patch.c) and incorrectly commented on the situation.

Any phone/software version found in the CyanogenMod 11 Repo listing for loki_patch.c (https://github.com/CyanogenMod/android_device_lge_g2-common/blob/cm-11.0/releasetools/loki_patch.c) file - do a CTRL+F - should be able to apply this workaround to flash a ROM with an out-of-date patcher.

EDIT 2:

This solution should, based on the Loki source used for CM11, work for the following G2 models:

AT&T: D80010d, D80010o (however 10o has a reported failure and no successes)

Verizon: VS98010b, VS98012b

T-Mobile / Canada: D80110c or D803

International: D802b

Sprint: LS980ZV7

KT / LGU: F320K, F320L

SKT: F320S, F320S11c

However, if you're just looking for a CM 10.2 ROM with this fix for the Verizon VS980, I uploaded the zip that I flashed for my acquaintance for convenience: http://www.mediafire.com/download/tmu28ihn3gm2ngw/cm-10.2-vs98012b.zip .

[/TLDR]

---

Hope this helps anyone that's having the same problem - good luck flashing!