[Sprint LG Optimus G] I-IoLLoW:
MODIFY A 4.4.x BASED ROM'S UPDATER-SCRIPT TO FLASH WITH TWRP 2.5.0.0!

WARNING

This is a disclaimer: While this has been tested I am not responsible for ANY damage done to your device. I take no responsibility for bootloops, soft bricks, hard bricks, living brick monsters, your phone proving an omnipotent being fallible(thus negating all existence), your great aunt smoking bath salts, flying monkeys, hot pockets, obamacare, dingleberries, carnivorous dingleberries or Sundays. Use at your own risk!!

Secondary disclaimer: If you have carnivorous dingleberries then you have bigger problems to worry about - but for any phone related questions feel free to message me on here either privately or in the thread.

In honor of my 300th post here on xda I thought I should do my first guide. I decided to make this guide because some people have had issues with TWRP 2.6.x which is the version you need to flash kit kat roms. However TWRP 2.5.0.0 has been beyond stable for me and everyone I know who has used it on our wonderful ls970. So how do you flash 4.4 based roms from TWRP 2.5.0.0?! Edit the updater-script, ofcourse!!!!

Now keep in mind, the screenshots I supply will be on Linux because it is what I use - the steps should be the same for Windows, however the programs used will probably be different(Archive Manager vs 7zip/WinRar for instance). If anyone wants to do this on Windows and take screenshots I will gladly post them or give OP privileges so that you can add them yourself.

Are there any downsides to installing roms this way?

Yes - it will essentially break OTA updates for the roms. 4.4 roms built from source will always have an updater-script meant for the newer recovery versions and will not flash in 2.5.0.0. So if you want to dirty flash an update to the rom you are using, you will have to modify that updater-script as well.

Well, let's get down to business!

Things you will need:

A flashable zip file for your rom of choice(I use Vanir for this guide)

An archive manager(7zip/Winrar for Windows)

A text editor(I use gedit but Windows users will want to use Notepad++)

A working brain

Step 1: Open the flashable zip file with an archive manager

Step 2: Navigate to the updater-script found in META-INF/com/google/android/

Step 3: Open the updater-script from within the archive manager. Keep the archive manager open during this process. I'm using Linux Mint 15 so it opens in gedit. Once open, scroll down until you see a bunch of lines that say 'set_metadata' and 'set_metadata_recursive'. These are the lines we need to edit.

Step 4: Now everywhere you see 'metadata' in these lines, you want to replace 'metadata' with 'perm' like in the images below.

Step 5: After replacing metadata with perm, we need to re-organize things a bit to look more like a 4.3 updater-script. After the parentheses you will see directories/files in quotation marks like in the picture below.

We need to move all of these to the end of the parentheses like so.

Step 6: The next thing we need to do is delete everything else in the parentheses EXCEPT the numbers. The numbers and quotations we just moved will be the only things left in parentheses when we are done. Also keep in mind that '0x0' will also be removed.

So - everything highlighted below, needs to go!

When you are done, it will look like this:

And when you are done with ALL of it, here is what it will look like!

Step 7: Remove asserts. This isn't always needed but it also won't hurt. The asserts placed in flashable zips are to protect you from installing a rom that isn't compatible with your device. The problem we lgog users frequently have is that our phone is called many things(ls970, geehrc4g, geespr, etc). If you've ever gotten a "Flash failed this isn't a geespr" error in TWRP, it's because that particular version of TWRP doesn't recognize your device as a geespr(even though it is). So as long as you know the rom was built for your device, it is safe to delete these lines. They are found at the very top of the updater-script like shown below.

Step 8: Save and update! Once you are done editing, simply hit save in the text editor and your archive manager should give you a warning similar to this one below.

Hit the update button and the updater-script will save inside the flashable zip!

And that's it! Your 4.4 based rom will now flash on TWRP 2.5.0.0!!

Just be careful that you edit it exactly, pay attention to the punctuation. This is not difficult but can be time consuming. Using your text editor's "Replace" function properly will help speed up the process!

So why go through all of this?

Certain users here on the lgog forums have experienced a problem with TWRP 2.6.x that essentially bricks the device. Randomly and mysteriously, the phone won't boot into the system. When trying to boot into TWRP, it will ask for a password - even though the user never supplied one in the first place. If you cancel the password, TWRP loses all functionality.

Users in other threads(specifically the nexus4 and nexus5 users) have experienced the same problem but not to the extent our lgog users have. In most cases it is because the data partition became corrupt/encrypted. The solution is to format your data partition(So best case scenario, you lose EVERYTHING). Nexus users seem to still be able to do this after cancelling the password - some lgog users haven't been as fortunate. When they cancel the password, nothing mounts, so nothing works. Even using LGNPST to revert back to stock gives an error so the phone is essentially a paperweight.

What is the cause of this?

It still isn't certain however it may be a bad emmc chip. Can't an emmc chip go bad using TWRP 2.5.0.0? Ofcourse, so this may all be superstition. It may just be a coincidence that a person's emmc chip fried while using the updated versions of TWRP. But until someone has this issue on TWRP 2.5.0.0(None have been reported as far as I know, if it happens to you, please prove me wrong), I'm going to err on the side of caution and stick with what I know works.

For most users it will just be easier to flash a different recovery like Clockworkmod but I personally wanted to stick with one recovery. Using this method, TWRP 2.5.0.0 can flash everything from stock to 4.4.x! You can look here in the lgog forums for working recoveries and their uses/limitations. But at the very least I hope this guide helped you to understand updater-scripts a bit better and the role they play in flashing roms.​

QUESTIONS?

Feel free to ask me any questions you may have. If it doesn't flash, get a recovery log(from TWRP go to advanced->copy log to sd, then boot back into your system and it will be on your internal memory as recovery.log) and send it to me. Or open the recovery log yourself and look for E: (For error) around where the flash failed. Usually you will see a syntax error and it will tell you what line it was on - that means the edit wasn't done properly but you will atleast know where it went wrong. ;)

Thanks

[MENTION=4003363]xboxfanj[/MENTION] - for showing me how to do this in the first place

[MENTION=1280108]engine95[/MENTION] - for all of his guides here in the threads