1FROM ubuntu:18.10
2
3# Dependencies to get the git sources and go binaries
4RUN apt-get update && apt-get install -y  --no-install-recommends \
5        ca-certificates \
6        curl \
7        git \
8    && apt-get clean \
9    && rm -rf /var/lib/apt/lists/*
10
11# Get the git sources. If not cached, this takes O(5 minutes).
12WORKDIR /git
13RUN git config --global advice.detachedHead false
14# Linux Kernel: Released 07 July 2019
15RUN git clone --branch v5.2 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux
16# GNU C library: Released 01 Feb 2019 (we should try to get a secure way to clone this)
17RUN git clone --branch release/2.29/master --depth 1 git://sourceware.org/git/glibc.git
18
19# Get Go
20ENV GOLANG_VERSION 1.13beta1
21ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz
22ENV GOLANG_DOWNLOAD_SHA256 dbd131c92f381a5bc5ca1f0cfd942cb8be7d537007b6f412b5be41ff38a7d0d9
23
24RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \
25    && echo "$GOLANG_DOWNLOAD_SHA256  golang.tar.gz" | sha256sum -c - \
26    && tar -C /usr/local -xzf golang.tar.gz \
27    && rm golang.tar.gz
28
29ENV PATH /usr/local/go/bin:$PATH
30
31# Linux and Glibc build dependencies and emulator
32RUN apt-get update && apt-get install -y  --no-install-recommends \
33        bison gawk make python3 \
34        gcc gcc-multilib \
35        gettext texinfo \
36        qemu-user \
37    && apt-get clean \
38    && rm -rf /var/lib/apt/lists/*
39# Cross compilers (install recommended packages to get cross libc-dev)
40RUN apt-get update && apt-get install -y \
41        gcc-aarch64-linux-gnu       gcc-arm-linux-gnueabi     \
42        gcc-mips-linux-gnu          gcc-mips64-linux-gnuabi64 \
43        gcc-mips64el-linux-gnuabi64 gcc-mipsel-linux-gnu      \
44        gcc-powerpc64-linux-gnu     gcc-powerpc64le-linux-gnu \
45	gcc-riscv64-linux-gnu                                 \
46        gcc-s390x-linux-gnu         gcc-sparc64-linux-gnu     \
47    && apt-get clean \
48    && rm -rf /var/lib/apt/lists/*
49
50# Let the scripts know they are in the docker environment
51ENV GOLANG_SYS_BUILD docker
52WORKDIR /build
53ENTRYPOINT ["go", "run", "linux/mkall.go", "/git/linux", "/git/glibc"]
54