uboot/tools/docker/Dockerfile
<<
>>
Prefs
   1# SPDX-License-Identifier: GPL-2.0+
   2# This Dockerfile is used to build an image containing basic stuff to be used
   3# to build U-Boot and run our test suites.
   4
   5FROM ubuntu:focal-20220113
   6MAINTAINER Tom Rini <trini@konsulko.com>
   7LABEL Description=" This image is for building U-Boot inside a container"
   8
   9# Make sure apt is happy
  10ENV DEBIAN_FRONTEND=noninteractive
  11
  12# Add LLVM repository
  13RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
  14RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
  15RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main | tee /etc/apt/sources.list.d/llvm.list
  16
  17# Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0
  18RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ
  19RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
  20RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
  21RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
  22RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
  23RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
  24RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
  25RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
  26RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
  27RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
  28
  29# Manually install other toolchains
  30RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2020.07/x86_64-2020.07-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz
  31RUN wget -O - https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2021.03-release/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install.tar.gz | tar --no-same-owner -C /opt -xz
  32RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
  33
  34# Update and install things from apt now
  35RUN apt-get update && apt-get install -y \
  36        automake \
  37        autopoint \
  38        bc \
  39        binutils-dev \
  40        bison \
  41        build-essential \
  42        clang-13 \
  43        coreutils \
  44        cpio \
  45        cppcheck \
  46        curl \
  47        device-tree-compiler \
  48        dosfstools \
  49        e2fsprogs \
  50        efitools \
  51        expect \
  52        fakeroot \
  53        flex \
  54        gawk \
  55        gdisk \
  56        git \
  57        gnu-efi \
  58        gnutls-dev \
  59        graphviz \
  60        grub-efi-amd64-bin \
  61        grub-efi-ia32-bin \
  62        help2man \
  63        iasl \
  64        imagemagick \
  65        iputils-ping \
  66        libconfuse-dev \
  67        libgit2-dev \
  68        libjson-glib-dev \
  69        libguestfs-tools \
  70        libgnutls28-dev \
  71        libgnutls30 \
  72        liblz4-tool \
  73        libpixman-1-dev \
  74        libpython3-dev \
  75        libsdl1.2-dev \
  76        libsdl2-dev \
  77        libseccomp-dev \
  78        libssl-dev \
  79        libtool \
  80        libudev-dev \
  81        libusb-1.0-0-dev \
  82        linux-image-kvm \
  83        lzma-alone \
  84        lzop \
  85        mount \
  86        mtd-utils \
  87        mtools \
  88        net-tools \
  89        ninja-build \
  90        openssl \
  91        picocom \
  92        parted \
  93        pkg-config \
  94        python-is-python3 \
  95        python2.7 \
  96        python3 \
  97        python3-dev \
  98        python3-pip \
  99        python3-sphinx \
 100        python3-virtualenv \
 101        rpm2cpio \
 102        sbsigntool \
 103        sloccount \
 104        socat \
 105        softhsm2 \
 106        sparse \
 107        srecord \
 108        sudo \
 109        swig \
 110        util-linux \
 111        uuid-dev \
 112        virtualenv \
 113        xxd \
 114        zip \
 115        && rm -rf /var/lib/apt/lists/*
 116
 117# Make kernels readable for libguestfs tools to work correctly
 118RUN chmod +r /boot/vmlinu*
 119
 120# Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
 121RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
 122        cd /tmp/sbsigntools && \
 123        git checkout -b latest v0.9.4 && \
 124        ./autogen.sh && \
 125        ./configure && \
 126        make && \
 127        make install && \
 128        rm -rf /tmp/sbsigntools
 129
 130# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
 131RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
 132        cd /tmp/grub && \
 133        git checkout grub-2.06 && \
 134        ./bootstrap && \
 135        mkdir -p /opt/grub && \
 136        ./configure --target=aarch64 --with-platform=efi \
 137        CC=gcc \
 138        TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
 139        TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
 140        TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
 141        TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
 142        TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
 143        make && \
 144        ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
 145        grub-core cat chain configfile echo efinet ext2 fat halt help linux \
 146        lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
 147        search search_fs_file search_fs_uuid search_label serial sleep test \
 148        true && \
 149        make clean && \
 150        ./configure --target=arm --with-platform=efi \
 151        CC=gcc \
 152        TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
 153        TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
 154        TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
 155        TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
 156        TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
 157        make && \
 158        ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
 159        grub-core cat chain configfile echo efinet ext2 fat halt help linux \
 160        lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
 161        search search_fs_file search_fs_uuid search_label serial sleep test \
 162        true && \
 163        make clean && \
 164        ./configure --target=riscv64 --with-platform=efi \
 165        CC=gcc \
 166        TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
 167        TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
 168        TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
 169        TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
 170        TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
 171        make && \
 172        ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
 173        grub-core cat chain configfile echo efinet ext2 fat halt help linux \
 174        lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
 175        search search_fs_file search_fs_uuid search_label serial sleep test \
 176        true && \
 177        rm -rf /tmp/grub
 178
 179RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
 180        cd /tmp/qemu && \
 181        git submodule update --init dtc && \
 182        git checkout v6.1.0 && \
 183        # config user.name and user.email to make 'git am' happy
 184        git config user.name u-boot && \
 185        git config user.email u-boot@denx.de && \
 186        # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes
 187        wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \
 188        ./configure --prefix=/opt/qemu --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu" && \
 189        make -j$(nproc) all install && \
 190        rm -rf /tmp/qemu
 191
 192# Build genimage (required by some targets to generate disk images)
 193RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
 194        cd /tmp/genimage-14 && \
 195        ./configure && \
 196        make -j$(nproc) && \
 197        make install && \
 198        rm -rf /tmp/genimage-14
 199
 200# Build libtpms
 201RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
 202        cd /tmp/libtpms && \
 203        ./autogen.sh && \
 204        ./configure && \
 205        make -j$(nproc) && \
 206        make install && \
 207        ldconfig && \
 208        rm -rf /tmp/libtpms
 209
 210# Build swtpm
 211RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
 212        cd /tmp/swtpm && \
 213        ./autogen.sh && \
 214        ./configure && \
 215        make -j$(nproc) && \
 216        make install && \
 217        rm -rf /tmp/swtpm
 218
 219# Create our user/group
 220RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
 221RUN useradd -m -U uboot
 222USER uboot:uboot
 223
 224# Create the buildman config file
 225RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
 226RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
 227RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
 228RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
 229RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
 230RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
 231RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
 232RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
 233RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
 234