Project

General

Profile

Actions

BuildEnvironments

Rationale

Each revision of Android is meant to be compiled with a specific set of dependencies. No effort is made upstream to support multiple build environments.
Building with different environments often yields build errors due to untested dependencies versions.
So we document here how to recreate these recommended build environments.

Recommended environment history

Ubuntu support:

          ,2013-10-15 - Lucid   (10.04)
2013-10-15,2015-03-16 - Precise (12.04), probably with 4.4 KitKat - https://web.archive.org/web/20131015123913/http://source.android.com/source/initializing.html
2015-03-16,           - Trusty  (14.04) https://web.archive.org/web/20150316053136/https://source.android.com/source/initializing.html

Java support:

          ,2014-03-31 - Sun JDK 5/6
2014-03-31,           - OpenJDK 7 - https://web.archive.org/web/20140331004436/https://source.android.com/source/initializing.html

Ubuntu 14.04 with LXC

lxc-create -n replicant -t download -- -d ubuntu -r trusty -a amd64

lxc-start -n replicant -d
lxc-attach -n replicant

# clean-up non-free sources
sed -i -e 's/ restricted//' -e 's/ multiverse//' /etc/apt/sources.list
apt-get update

Trisquel 6.0 Toutatis (based on Ubuntu 12.04 Precise) with LXC

wget http://archive.trisquel.info/trisquel/pool/main/d/debootstrap/debootstrap_1.0.59ubuntu0.3+7.0trisquel1.tar.gz
tar xzf debootstrap_1.0.59ubuntu0.3+7.0trisquel1.tar.gz 
cp -a debootstrap-1.0.59ubuntu0.3+7.0trisquel1/scripts/{toutatis,trisquel} /usr/share/debootstrap/scripts/
cp -a /usr/share/lxc/templates/lxc-ubuntu /usr/share/lxc/templates/lxc-trisquel
sed -i -e 's/main restricted universe multiverse/main/' \
       -e 's/.*lxcguest/#&/' /usr/share/lxc/templates/lxc-trisquel

lxc-create -n replicant -t trisquel --  -r toutatis -a amd64 --mirror http://archive.trisquel.info/trisquel/ \
  --security-mirror http://archive.trisquel.info/trisquel/

Ubuntu 12.04 Precise with LXC

lxc-create -n replicant -t download -- -d ubuntu -r precise -a amd64

lxc-start -n replicant -d
lxc-attach -n replicant

# clean-up non-free sources
sed -i -e 's/ restricted//' -e 's/ multiverse//' /etc/apt/sources.list
apt-get update

Trisquel 4.1 Taranis (based on Ubuntu 10.04 Lucid) with LXC

wget http://archive.trisquel.info/trisquel/pool/main/d/debootstrap/debootstrap_1.0.59ubuntu0.3+7.0trisquel1.tar.gz
tar xzf debootstrap_1.0.59ubuntu0.3+7.0trisquel1.tar.gz 
cp -a debootstrap-1.0.59ubuntu0.3+7.0trisquel1/scripts/{taranis,trisquel} /usr/share/debootstrap/scripts/
cp -a /usr/share/lxc/templates/lxc-ubuntu /usr/share/lxc/templates/lxc-trisquel
sed -i -e 's/main restricted universe multiverse/main/' \
       -e 's/lucid/taranis/' /usr/share/lxc/templates/lxc-trisquel

lxc-create -n replicant -t trisquel --  -r taranis -a amd64 --mirror http://archive.trisquel.info/trisquel/ \
  --security-mirror http://archive.trisquel.info/trisquel/

lxc-start -n replicant -d
lxc-attach -n replicant

# 'lxcguest' fixes a number of issues but seem to disable init..
dhclient
/etc/init.d/ssh restart

You'll need git > 1.7.2 for repo:

cd /usr/src/
apt-get install wget gcc libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat-dev gettext
wget https://www.kernel.org/pub/software/scm/git/git-2.4.6.tar.gz
tar xf git-2.4.6.tar.gz 
cd git-2.4.6/
make -j4  # ~2mn
make install prefix=/usr/local

Ubuntu 10.04 Lucid with LXC

apt-get install ubuntu-archive-keyring rsync
lxc-create -n replicant -t ubuntu -- -r lucid -a amd64

lxc-start -n replicant -d
lxc-attach -n replicant

# clean-up non-free sources
sed -i -e 's/ restricted//' -e 's/ multiverse//' /etc/apt/sources.list
apt-get update

# 'lxcguest' fixes a number of issues but seem to disable init..
dhclient
/etc/init.d/ssh restart

You'll need git > 1.7.2 for repo:

cd /usr/src/
apt-get install wget gcc libssl-dev zlib1g-dev libcurl4-gnutls-dev libexpat-dev gettext
wget https://www.kernel.org/pub/software/scm/git/git-2.4.6.tar.gz
tar xf git-2.4.6.tar.gz 
cd git-2.4.6/
make -j4  # ~2mn
make install prefix=/usr/local

LXC host environment

The simplest way to configure LXC is to combine it with libvirt.

Here are instructions tested on a Debian 8 host:

apt-get install lxc debootstrap xz-utils ca-certificates

apt-get install libvirt-bin dnsmasq ebtables
service dnsmasq stop
update-rc.d dnsmasq remove
virsh net-autostart default
service libvirtd restart
cat > /etc/lxc/default.conf <<'EOF'
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
EOF

You now can run the LXC containers instructions above.

Non-privileged user setup

This can be used in any environment to prepare a non-root user dedicated to builds.

# prepare build user
apt-get install openssh-server
useradd replicant --shell /bin/bash --create-home
mkdir -p -m 700 ~replicant/.ssh
cat <<EOF >> ~replicant/.ssh/authorized_keys
your public key
EOF
chown -R replicant: ~replicant

Updated by Beuc Beuc over 8 years ago · 11 revisions

Also available in: PDF HTML TXT