AOSP Building Guide on CentOS7 And RHEL7

Install libraries

# fetch source
sudo yum install git
sudo yum install wget
# to compile
sudo yum install java-1.7.0-openjdk
sudo yum install java-1.7.0-openjdk-devel
sudo yum install glibc.i686
sudo yum install libstdc++.i686
sudo yum install bison
sudo yum install zip
sudo yum install unzip

Install repo

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

Fetch source

pick the branch you want

mkdir ~/aosp
cd ~/aosp
repo init -u https://android.googlesource.com/platform/manifest -b android-6.0.0_r1
repo sync

Fetch and extract binaries for hammerhead

https://developers.google.com/android/nexus/drivers#hammerheadmra58k

cd ~/aosp
wget https://dl.google.com/dl/android/hammerhead/qcom-hammerhead-mra58k-ff98ab07.tgz
wget https://dl.google.com/dl/android/hammerhead/lge-hammerhead-mra58k-25d00e3d.tgz
wget https://dl.google.com/dl/android/hammerhead/broadcom-hammerhead-mra58k-bed5b700.tgz
ls *.tgz |xargs -n1 tar -zxvf
for i in extract*; do sed -n '/tail/p' $i | sed "s/\$0/$i/" | sh; done

Fetch and extract binaries for fugu

https://developers.google.com/android/nexus/drivers#fugumra58k

cd ~/aosp
wget https://dl.google.com/dl/android/aosp/asus-fugu-mra58k-d95031a4.tgz
wget https://dl.google.com/dl/android/aosp/broadcom-fugu-mra58k-47a937a0.tgz
wget https://dl.google.com/dl/android/aosp/google-fugu-mra58k-97e3d519.tgz
wget https://dl.google.com/dl/android/aosp/intel-fugu-mra58k-3a7b47c4.tgz
wget https://dl.google.com/dl/android/aosp/widevine-fugu-mra58k-34f49f9a.tgz
ls *.tgz |xargs -n1 tar -zxvf 
rm *.tgz
for i in extract*.sh; do sed -n '/tail/p' $i | sed "s/\$0/$i/" | sh; done
rm extract*.sh

Setup envornment for hammerhead

cd ~/aosp
. build/envsetup.sh
lunch 17

Setup envornment for fugu

cd ~/aosp
. build/envsetup.sh
lunch 10

Run

cd ~/aosp
export USE_CCACHE=1
export CCACHE_DIR=~/.ccache
prebuilts/misc/linux-x86/ccache/ccache -M 50G
make -j16

Download images for hammerhead

REMOTE_PATH="<ip-address>:~/aosp/out/target/product/hammerhead/"
scp ${REMOTE_PATH}\{android-info.txt,boot.img,recovery.img,cache.img,userdata.img,system.img\} .

Download images for fugu

REMOTE_PATH="<ip-address>:~/aosp/out/target/product/fugu/"
scp ${REMOTE_PATH}\{android-info.txt,boot.img,recovery.img,cache.img,userdata.img,system.img\} .

Flash images

fastboot flash boot boot.img 
fastboot flash cache cache.img 
fastboot flash recovery recovery.img 
fastboot flash system system.img 
fastboot flash userdata userdata.img 
fastboot reboot
CentOS 7 AOSP Building Guide
CentOS 7 AOSP Building Guide. GitHub Gist: instantly share code, notes, and snippets.