[Galaxy S II Android Development] Novek:
Made the CM wiki a little easier to understand. Most is taken from here:

http://teamhacksung.org/wiki/index.php/CyanogenMod9:GT-I9100:How_to_build

First off you will need Ubuntu 64-bit for this to work (or one of the many ubuntu editions) I recommend the 11.10 version (will work on 10.x also), as it's the newest stable to date. 32-bit won't work. I'm using Xubuntu 64 bit, and it uses the same terminal codes of course.

Install ADB

Install the Android SDK.

NOTE: You do not need to setup the SDK with an ADV etc., just download and install to get the tools (e.g. adb).

Install the Build Packages

Open the terminal in ubuntu and paste the following code snippets:

To add sun-java to repo (works on various ubuntu versions):

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update

To get the needed build packages:

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 sun-java6-jdk pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib

NOTE: gcc-4.3-multilib g++-4.3-multilib is no longer available for Ubuntu 11.04/11.10 64-bit, but should still build without issue. On 11.10 lib32readline5-dev is no longer available, but lib32readline-gplv2-dev is there instead. Just install it with "apt-get install lib32readline-gplv2-dev"

Create the Directories

You will need to set up some directories in your build environment.

To create them paste these in terminal:

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

Install the Repository

Enter the following in terminal to download make executable the "repo" binary:

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

NOTE: You may need to reboot for these changes to take effect.

Now enter the following to initialize the repository:

cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync -j16

Retrieve the galaxys2 repo

. build/envsetup.sh
brunch cm_galaxys2-userdebug

Copy proprietary files

NOTE: This only needs to be done the first time you build, but it's recommended to redo it when TeamHacksung makes some changes to these in their nightlies (which may occur quite often as of now)..

You will need to have a galaxys2 with the latest nightly of CM9 installed, and ADB working on the computer. This script will copy the proprietary files from the device.

Connect the device to the computer and ensure that ADB is working properly.

Paste this into terminal:

cd ~/android/system/device/samsung/galaxys2/
./extract-files.sh

NOTE: If some hardware isn't working, like camcorder or FM radio, you will need to find the updated prop blobs.

Get prebuilts

~/android/system/vendor/cm/get-prebuilts

Building CyanogenMod

First, check for updates in the source:

Paste into terminal:

cd ~/android/system/
repo sync

Configure Build & Compile

Now, the environment must be configured to build and the ROM compiled, from code, for the galaxys2.

Paste into terminal:

. build/envsetup.sh && brunch cm_galaxys2-userdebug

--------------------

End of tutorial

--------------------