[LG Optimus 2x] aMpeX:
aMpeX proudly presents:

The Step-By-Step guide for building CM7

for the Optimus 2X​

Disclaimer:

I'm taking no responsibility for any damage that might occur to your phone or your PC

This guide illustrates how to setup an UBUNTU 11.04 equipped PC to build CM7 from source

It does not provide any support beyond that operating system, so if you insist on using other

Linux distributions, either adapt the guide yourself or look elsewhere.

Moreover I'm not providing any support for any problems that might occur during the course

of this guide, if they are not introduced by faults within the guide itself. I will only

troubleshoot the activities that this guide is based upon and won't be able to help with your

general linux problems. Feedback however is greatly appreciated.

Reposting this on other forums:

Feel free to post this guide on other forums. I'd like to be given credit though. Thanks

I am new to this myself, but I thought I'd share my findings after successfully building my first kang.

News & changelog:

v0.92 2011/06/01 Fix:

Added "change directory" before init repository (thanks to peewster)

v0.91 2011/05/31 Fix:

Fixed PATH exports (thanks to bhanvadia)

v0.9 2011/05/31 Initial release:

Still much formatting to be done, typos possible. Leave me some feedback if you encounter them.

Alright, so you want to build your own CM7 KANG's ?

Step 0: The starting point + info

When you start this guide, I assume that you just installed your Ubuntu 11.04 copy to your PC and set up all the drivers to your hearts content.

All commands are supplied, as they would be typed in from a USER ACCOUNT, if you operate from the root account, you will

have to add /home/<yourusername> to the most commands. I suggest, after performing the actions required by root, that you log out by typing

exit

What you need:

A working copy of Cyanogenmod7 installed on your phone

A PC with Ubuntu 11.04 installed (NOTE: If you're about to install Ubuntu from scratch, use the 64Bit version.

I can build CM7 on a 32Bit OS just fine. But AOSP for example won't build beyond Froyo on 32Bit.

At least 20GB of free space (including space required for the operating system itself)

A considerably fast internet connection (syncing the repo takes everal Gbs)

At least 3 hours of time.

All done? Then let's get started:

Step 1: Install the Java JDK

Go to System → Administration → Synaptics Package Manager

Here, we have to enable the partner repositories.

Go to Settings → Repositories → Other Software → Tick Canonical Partners and hit Close

Now push the „Reload“ button, and use the Search button to find the sun-java6-jdk package

tick the box in front of it and choose „Mark for installation“ and accept the following dialogue.

Click the „Apply“ button. Accept the dialogues, you now have the Java JDK installed.

Step 2: Install the Android SDK

Go here and download this.

Extract the archive to a directory of your choice.

Open a Terminal, navigate to the „tools“ subfolder and run the AVD Manager using ./android

In the new Window hit „Available Packages“ tick the „Android Repository“ and select „Install selected“

Once thats done, close everything up, time for step 3.

Step 3: Set up udev

The description from the CyanogenMod wiki struck me as being a slightly bit overkill, and, while it might be necessary for other devices, for LG phones this works just fine:

Create a new file on your desktop named

99-android.rules

and fill them with the following content:

SUBSYSTEM=="usb", SYSFS{idVendor}=="1004", MODE="0666"

This will enable the debugging for LG devices, if you have time, it won#t hurt to add the other vendors. Just add another line

like above and replace the „1004“ with the appropriate vendor ID from http://developer.android.com/guide/developing/device.html (scroll to the bottom)

Log in as root using

sudo su

and paste our file to

/etc/udev/rules.d

using the terminal (cp)

Set permissions for the file using

chmod a+r /etc/udev/rules.d/99-android.rules

Now would probably be a good time to check if adb is working correctly.

But first, lets update the PATH so we can type „adb“ anywhere on the file system.

Navigate to your user home directory, press CTRL+H to show hidden files and edit the

.bashrc

file by adding the following

export PATH="/home/<yourusername>/<path to the android SDK >/platform-tools/:${PATH}"
export PATH="/home/<yourusername>/bin/:${PATH}"

(The 2nd line is necessary for later)

NOTE:

This only enable the use of adb everywhere when logged in with your username. When working as root, you'll have

to add a separate line with /home/<yourusername> in front of the path above.

You have to log out and in again for the changes to take effect.

Now check if you can see your phone with

adb devices

Alright, still awake? Good, because now it gets interesting

Step 4: Install build packages and create directories

Since we already installed the JDK this command differs a bit from the Cyanogen Wiki:

For 32 and 64 Bit

sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool

For 64 Bit only

sudo apt-get install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.4-multilib g++-4.4-multilib

Now we need 2 directories

mkdir -p ~/bin
mkdir -p ~/android/system

Almost there ….

Step 5: Install the repository

Now we need our repo binary:

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo

(credits to p.valenta for notifying me of the adress change)

NOTE:

You may need to reboot now

Change to your previously created directory:

cd ~/android/system/

Initialize the repository:

repo init -u git://github.com/CyanogenMod/android.git -b gingerbread

Enter your Name, eMail adress and select if you want colors or not.

AND NOW THE FINALE

repo sync -j16

Get yourself a BIG coffee, because this is going to take MUCH MUCH time, because basically you are now checking out all there is to CyanogenMod.

But wait, we're not done yet. Hang on

Step 6: Getting proprietary files for the Optimus 2X

For this step, you need an O2X with a running Cyanogenmod build, so if you're still on stock, this is the time to flash Cyanogenmod for the first time.

Connect your phone to your PC via USB and

navigate to the device tree in your repo folder:

cd ~/android/system/device/lge/p990/

and run

./extract-files.sh

This will extract some libs from your device. But sadly, not all of them (build will still fail) but we will fix this now.

Go to

https://github.com/koush/proprietary_vendor_lge/tree/gingerbread/p990

and click the download button on the right.

Extract the „p990“ folder located in the subfolder

/koush-proprietary_vendor_lge-a43238f/

in the archive to

~/android/system/vendor/lge/

Step 7: Get latest ROMManager

I know I must be annoying the sh** out of you by now, but hang in there ;)

~/android/system/vendor/cyanogen/get-rommanager

Step 8: BUILD F***ING EVERYTHING

Now this is what you've been waiting for huh?

Sync the repository again:

cd ~/android/system/
repo sync

Build the ROM

. build/envsetup.sh && brunch p990

Wait

When everything is finished, your KANG will be stored in

~/android/system/out/target/product/p990/

And THATS IT!

Congratulations, you have just built your own CM7 KANG, don't forget to share it to other nightly testers :)

Cheers aMpeX