Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyLi committed Mar 1, 2018
0 parents commit 549753e
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
.gitignore
*.md
Empty file added .gitignore
Empty file.
72 changes: 72 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
FROM ubuntu:14.04

RUN set -e; \
\
cd /bin; \
ln -sf bash sh; \
ln -sf true git

# install gosu from https://github.com/tianon/gosu/releases
ENV GOSU_VERSION 1.10
RUN set -e; \
\
fetchDeps='ca-certificates wget'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
rm -rf /var/lib/apt/lists/*; \
\
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc; \
chmod +x /usr/local/bin/gosu; \
gosu nobody true; \
\
apt-get purge -y --auto-remove $fetchDeps

# add openjdk ppa
RUN set -e; \
\
fetchDeps='software-properties-common'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
rm -rf /var/lib/apt/lists/*; \
\
add-apt-repository -y ppa:openjdk-r/ppa; \
\
apt-get purge -y --auto-remove $fetchDeps

# install openjdk-8 and other deps
RUN set -e; \
\
fetchDeps=' \
openjdk-8-jdk \
bc bison build-essential \
ccache curl \
flex \
g++-multilib gcc-multilib gnupg gperf \
lib32ncurses5-dev lib32z-dev libc6-dev-i386 \
libgl1-mesa-dev libx11-dev libxml2-utils \
python \
rsync \
unzip \
x11proto-core-dev xsltproc \
zip zlib1g-dev \
'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetchDeps; \
rm -rf /var/lib/apt/lists/*

# install repo
RUN set -e; \
\
curl https://storage.googleapis.com/git-repo-downloads/repo >/bin/repo; \
chmod a+x /bin/repo

COPY docker-entrypoint.sh /usr/local/bin/
COPY build.sh /usr/local/bin/build
ENTRYPOINT [ "docker-entrypoint.sh" ]
CMD [ "build" ]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# cht905x
Automated docker build for CHT using 905x chip and AOSP 7.1

## Docker build
```
docker build -t cht905x .
```

## Build the source code
```
docker run --rm -it \
--mount type=bind,source=/home/johnnyli/Work/CHT_905x/source,target=/src \
--mount type=bind,source=/home/johnnyli/Work/CHT_905x/out,target=/src/out \
--mount type=bind,source=/opt/aml_toolchains,target=/opt/aml_toolchains \
cht905x [[build] [slow] | source]
```

## Debugging
```
docker run [some-options] cht905x [root,user]
```
26 changes: 26 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

CMD=$1
DEVICE=$2
if [ -z "$DEVICE" ]; then
DEVICE=p212-user-32
fi
cd /src && \
source build/envsetup.sh && \
lunch $DEVICE
if [ "$CMD" = "source" ]; then
exec bash
fi

# uboot
cd uboot && ./mk gxl_p212_v1 && cd /src && \
cp -arf uboot/fip/u-boot.bin device/amlogic/p212/ && \
cp -arf uboot/fip/u-boot.bin.* device/amlogic/p212/upgrade/

if [ "$CMD" = "slow" ]; then
MAKE_OPT=""
else
MAKE_OPT="-j12"
fi
# ota
make otapackage $MAKE_OPT
29 changes: 29 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -e
CMD=$1
GCC_ARM_NONE_EABI=/opt/aml_toolchains/gcc-arm-none-eabi-6-2017-q2-update/bin
GCC_LINARO_AARCH64_LINUX_GNU=/opt/aml_toolchains/gcc-linaro-aarch64-linux-gnu-4.9-2014.09_linux/bin
GCC_LINARO_AARCH64_NONE_ELF=/opt/aml_toolchains/gcc-linaro-aarch64-none-elf-4.8-2013.11_linux/bin
GCC_LINARO_ARM_LINUX_GNUEABIHF=/opt/aml_toolchains/gcc-linaro-arm-linux-gnueabihf/bin
export PATH=$GCC_ARM_NONE_EABI:$GCC_LINARO_AARCH64_LINUX_GNU:$GCC_LINARO_AARCH64_NONE_ELF:$GCC_LINARO_ARM_LINUX_GNUEABIHF:$PATH
if [ "$CMD" = "root" ]; then
exec bash
fi

if mount | grep "on /src" >/dev/null 2>&1; then
USER_ID=$(stat -c %u /src)
USER_NAME=user_$USER_ID
if ! id -u $USER_NAME >/dev/null 2>&1; then
useradd -m -u $USER_ID $USER_NAME
fi
else
echo "need to have a /src mount"
exit -1
fi

export USER=$USER_NAME
if [ "$CMD" = "user" ]; then
set -- bash
fi
exec gosu $USER_NAME "$@"

0 comments on commit 549753e

Please sign in to comment.