From 6dc4621afcd137f7356221dd04b66b7ac78c0437 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Thu, 15 Feb 2018 17:40:10 -0800 Subject: [PATCH] Add Docker instructions for older branches If you've upgraded away from Ubuntu 14.04 Trusty, you may find that older branches (or certain code) doesn't build anymore. These instructions can form a starting point to build these older branches within Docker. Bug: 72993575 Test: Follow instructions, build marshmallow-dev Test: Follow instructions, build lollipop-mr1-dev Change-Id: If4047b1bb5324d75a9d0947cb5280ff1cabccb6a --- tools/docker/.gitignore | 1 + tools/docker/Dockerfile | 25 +++++++++++++++++++++++++ tools/docker/README.md | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tools/docker/.gitignore create mode 100644 tools/docker/Dockerfile create mode 100644 tools/docker/README.md diff --git a/tools/docker/.gitignore b/tools/docker/.gitignore new file mode 100644 index 000000000..df0b367d6 --- /dev/null +++ b/tools/docker/.gitignore @@ -0,0 +1 @@ +gitconfig diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile new file mode 100644 index 000000000..ec65aaf2d --- /dev/null +++ b/tools/docker/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:14.04 +ARG userid +ARG groupid +ARG username + +RUN apt-get update && apt-get install -y git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip python openjdk-7-jdk + +RUN curl -o jdk8.tgz https://android.googlesource.com/platform/prebuilts/jdk/jdk8/+archive/master.tar.gz \ + && tar -zxf jdk8.tgz linux-x86 \ + && mv linux-x86 /usr/lib/jvm/java-8-openjdk-amd64 \ + && rm -rf jdk8.tgz + +RUN curl -o /usr/local/bin/repo https://storage.googleapis.com/git-repo-downloads/repo \ + && echo "e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5 /usr/local/bin/repo" | sha256sum --strict -c - \ + && chmod a+x /usr/local/bin/repo + +RUN groupadd -g $groupid $username \ + && useradd -m -u $userid -g $groupid $username \ + && echo $username >/root/username \ + && echo "export USER="$username >>/home/$username/.gitconfig +COPY gitconfig /home/$username/.gitconfig +RUN chown $userid:$groupid /home/$username/.gitconfig +ENV HOME=/home/$username + +ENTRYPOINT chroot --userspec=$(cat /root/username):$(cat /root/username) / /bin/bash -i diff --git a/tools/docker/README.md b/tools/docker/README.md new file mode 100644 index 000000000..304fd18ff --- /dev/null +++ b/tools/docker/README.md @@ -0,0 +1,18 @@ +The Dockerfile in this directory sets up an Ubuntu Trusty image ready to build +a variety of Android branches (>= Lollipop). It's particulary useful to build +older branches that required 14.04 if you've upgraded to something newer. + +First, build the image: +``` +# Copy your host gitconfig, or create a stripped down version +$ cp ~/.gitconfig gitconfig +$ docker build --build-arg userid=$(id -u) --build-arg groupid=$(id -g) --build-arg username=$(id -un) -t android-build-trusty . +``` + +Then you can start up new instances with: +``` +$ docker run -it --rm -v $ANDROID_BUILD_TOP:/src android-build-trusty +> cd /src; source build/envsetup.sh +> lunch aosp_arm-eng +> m -j50 +```