You just downloaded all the software needed to build Android. Make sure that your Ubuntu machine can use your USB devices by creating /etc/udev/rules.d/51-android.rules (as root user) paste the following inside that file:

You now have the source code of Gingerbread on your Ubuntu machine. Sweet! Of course, you still have to build it.

BUILDING THE SOURCE:

First I will explain how to build a normal generic build. This is a non phone specific build. In the Android source folder type:

. build/envsetup.sh

This will prepare your build environment. This is needed to have tools like lunch, mmm and other nifty Android specific tools. Now it’s time to actually choose our version of 2.3.7:

lunch

You will be asked which Android version you want, choose “generic”. Ubuntu 11.10 introduced some issues when building Android. We have to fix/resolve them first. In the core folder of your Android source, open up the following file:

vim frameworks/base/libs/utils/Android.mk

And change the following line:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS)

to:

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1 $(TOOL_CFLAGS) -fpermissive

Next open up:

vim build/core/combo/HOST_linux-x86.mk

And change:

HOST_GLOBAL_CFLAGS += -D_FORTIFY_SOURCE=0

to:

HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0

Now! It’s time for the real deal, building the source. It’s time to fire up make:

make -j4

Do note that there are diffrent -j parameters of make to build faster. You could use make -j4 if you have 2 cores, and make -j8 if you have 4. This will speed up the building.
If the building ends with something like system.img that the build went ok. Congratulations you’ve just build Android 2.3.7. You can flash it to your phone with fastboot. But this is just a generic build missing device specific features.

BUILDING THE SOURCE FOR THE NEXUS ONE:
Connect your phone to your PC, and make sure that it’s on debugging mode. From the root of your source, go to the Passion (code name for Nexus One) specific folder:

cd device/htc/passion

Import all the needed files:

./extract-files.sh

If this ends with no errors your done, you can now return to the root of your source tree. If you followed this how to go back to:

~/Android/source/Gingerbread

Now use lunch to choose the passion-full-userdebug build.

lunch

And! Now you can use make to build Android:

make -j4

If your build ends with something like this:
Install system fs image: out/target/product/passion/system.img
The build is complete. You can again use fastboot to flash it to your device. You now have the full open source version of Android running on your phone.
If you have any questions about this topic please don’t hesitate to ask them in the comments i’ll do my best to give answers when possible.