diff --git a/Dockerfile b/Dockerfile index c3a005ea70..a9a9d8e562 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,39 @@ FROM debian:9 +ARG TOOLCHAIN_FLAVOR=linux +ENV TOOLCHAIN_FLAVOR=$TOOLCHAIN_FLAVOR + # install build tools and dependencies RUN apt-get update && apt-get install -y \ build-essential wget git python3-pip gcc-multilib +# install dependencies from toolchain source build + +RUN [ "$TOOLCHAIN_FLAVOR" = "src" ] && \ + apt-get install -y autoconf autogen bison dejagnu \ + flex flip gawk git gperf gzip nsis \ + openssh-client p7zip-full perl python-dev \ + libisl-dev tcl tofrodos zip \ + texinfo texlive texlive-extra-utils + # download toolchain ENV TOOLCHAIN_SHORTVER=7-2018q2 ENV TOOLCHAIN_LONGVER=gcc-arm-none-eabi-7-2018-q2-update -ENV TOOLCHAIN_FLAVOR=linux ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_SHORTVER/$TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 # extract toolchain RUN cd /opt && wget $TOOLCHAIN_URL && tar xfj $TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 +# build toolchain (if required) + +RUN [ "$TOOLCHAIN_FLAVOR" = "src" ] && cd /opt/$TOOLCHAIN_LONGVER && ./install-sources.sh --skip_steps=mingw32 +RUN [ "$TOOLCHAIN_FLAVOR" = "src" ] && cd /opt/$TOOLCHAIN_LONGVER && ./build-prerequisites.sh --skip_steps=mingw32 +RUN [ "$TOOLCHAIN_FLAVOR" = "src" ] && cd /opt/$TOOLCHAIN_LONGVER && ./build-toolchain.sh --skip_steps=mingw32,manual + # install additional tools RUN apt-get install -y protobuf-compiler libprotobuf-dev diff --git a/Dockerfile.gcc_source b/Dockerfile.gcc_source deleted file mode 100644 index 9f51aa28a1..0000000000 --- a/Dockerfile.gcc_source +++ /dev/null @@ -1,46 +0,0 @@ -# initialize from the image - -FROM debian:9 - -# install build tools and dependencies - -RUN apt-get update && apt-get install -y \ - build-essential wget git python3-pip gcc-multilib \ - autoconf autogen bison dejagnu flex flip gawk git gperf gzip nsis openssh-client p7zip-full perl python-dev libisl-dev tcl tofrodos zip \ - texinfo texlive texlive-extra-utils - -# download toolchain - -ENV TOOLCHAIN_SHORTVER=7-2018q2 -ENV TOOLCHAIN_LONGVER=gcc-arm-none-eabi-7-2018-q2-update -ENV TOOLCHAIN_FLAVOR=src -ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-rm/$TOOLCHAIN_SHORTVER/$TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 - -# extract toolchain - -RUN cd /opt && wget $TOOLCHAIN_URL && tar xfj $TOOLCHAIN_LONGVER-$TOOLCHAIN_FLAVOR.tar.bz2 - -# build toolchain - -RUN cd /opt/$TOOLCHAIN_LONGVER && ./install-sources.sh --skip_steps=mingw32 -RUN cd /opt/$TOOLCHAIN_LONGVER && ./build-prerequisites.sh --skip_steps=mingw32 -RUN cd /opt/$TOOLCHAIN_LONGVER && ./build-toolchain.sh --skip_steps=mingw32,manual - -# install additional tools - -RUN apt-get install -y protobuf-compiler libprotobuf-dev - -# setup toolchain - -ENV PATH=/opt/$TOOLCHAIN_LONGVER/bin:$PATH - -# install python tools - -RUN pip3 install click pyblake2 scons protobuf -RUN pip3 install --no-deps git+https://github.com/trezor/python-trezor.git@master - -# workarounds for weird default install - -RUN ln -s python3 /usr/bin/python -RUN ln -s dist-packages /usr/local/lib/python3.5/site-packages -ENV LC_ALL=C.UTF-8 LANG=C.UTF-8 diff --git a/build-docker.sh b/build-docker.sh index b1b5897a05..5fa7fed779 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -2,14 +2,13 @@ set -e if [ "$1" = "--gcc_source" ]; then - DOCKERFILE=Dockerfile.gcc_source - IMAGE=trezor-core-build.gcc_source + TOOLCHAIN_FLAVOR=src shift else - DOCKERFILE=Dockerfile - IMAGE=trezor-core-build + TOOLCHAIN_FLAVOR=linux fi +IMAGE=trezor-core-build.$TOOLCHAIN_FLAVOR TAG=${1:-master} REPOSITORY=${2:-trezor} @@ -19,7 +18,7 @@ else REPOSITORY=https://github.com/$REPOSITORY/trezor-core.git fi -docker build -t $IMAGE -f $DOCKERFILE . +docker build -t $IMAGE --build-arg TOOLCHAIN_FLAVOR=$TOOLCHAIN_FLAVOR . docker run -t -v $(pwd):/local -v $(pwd)/build-docker:/build:z $IMAGE /bin/sh -c "\ git clone $REPOSITORY trezor-core && \