Tom Rini | 04549e9 | 2021-03-15 13:19:01 -0400 | [diff] [blame] | 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 | |
| 5 | FROM ubuntu:bionic-20200807 |
| 6 | MAINTAINER Tom Rini <trini@konsulko.com> |
| 7 | LABEL Description=" This image is for building U-Boot inside a container" |
| 8 | |
| 9 | # Make sure apt is happy |
| 10 | ENV DEBIAN_FRONTEND=noninteractive |
| 11 | |
| 12 | # Add LLVM repository |
| 13 | RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/* |
| 14 | RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - |
| 15 | RUN echo deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main | tee /etc/apt/sources.list.d/llvm.list |
| 16 | |
| 17 | # Manually install the kernel.org "Crosstool" based toolchains for gcc-7.3 |
| 18 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-aarch64-linux.tar.xz | tar -C /opt -xJ |
| 19 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ |
| 20 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ |
| 21 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ |
| 22 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ |
| 23 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ |
| 24 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ |
| 25 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ |
| 26 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ |
| 27 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ |
| 28 | RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/9.2.0/x86_64-gcc-9.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ |
| 29 | |
| 30 | # Manually install other toolchains |
| 31 | RUN wget -O - https://github.com/foss-xtensa/toolchain/releases/download/2018.02/x86_64-2018.02-xtensa-dc233c-elf.tar.gz | tar -C /opt -xz |
| 32 | RUN wget -O - https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2019.09-release/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install.tar.gz | tar --no-same-owner -C /opt -xz |
| 33 | RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz |
| 34 | |
| 35 | # Update and install things from apt now |
| 36 | RUN apt-get update && apt-get install -y \ |
| 37 | automake \ |
| 38 | autopoint \ |
| 39 | bc \ |
| 40 | binutils-dev \ |
| 41 | bison \ |
| 42 | build-essential \ |
| 43 | clang-10 \ |
| 44 | coreutils \ |
| 45 | cpio \ |
| 46 | cppcheck \ |
| 47 | curl \ |
| 48 | device-tree-compiler \ |
| 49 | dosfstools \ |
| 50 | e2fsprogs \ |
| 51 | efitools \ |
| 52 | fakeroot \ |
| 53 | flex \ |
| 54 | gdisk \ |
| 55 | git \ |
| 56 | gnu-efi \ |
| 57 | graphviz \ |
| 58 | grub-efi-amd64-bin \ |
| 59 | grub-efi-ia32-bin \ |
| 60 | help2man \ |
| 61 | iasl \ |
| 62 | imagemagick \ |
| 63 | iputils-ping \ |
| 64 | libguestfs-tools \ |
| 65 | libisl15 \ |
| 66 | liblz4-tool \ |
| 67 | libpixman-1-dev \ |
| 68 | libpython-dev \ |
| 69 | libsdl1.2-dev \ |
| 70 | libsdl2-dev \ |
| 71 | libssl-dev \ |
| 72 | libudev-dev \ |
| 73 | libusb-1.0-0-dev \ |
| 74 | lzma-alone \ |
| 75 | lzop \ |
| 76 | mount \ |
| 77 | mtd-utils \ |
| 78 | mtools \ |
| 79 | openssl \ |
| 80 | picocom \ |
| 81 | parted \ |
| 82 | pkg-config \ |
| 83 | python \ |
| 84 | python-dev \ |
| 85 | python-pip \ |
| 86 | python-virtualenv \ |
| 87 | python3-pip \ |
| 88 | python3-sphinx \ |
| 89 | rpm2cpio \ |
| 90 | sbsigntool \ |
| 91 | sloccount \ |
| 92 | sparse \ |
| 93 | srecord \ |
| 94 | sudo \ |
| 95 | swig \ |
| 96 | util-linux \ |
| 97 | uuid-dev \ |
| 98 | virtualenv \ |
| 99 | zip \ |
| 100 | && rm -rf /var/lib/apt/lists/* |
| 101 | |
| 102 | # Manually install libmpfr4 for the toolchains |
| 103 | RUN wget http://mirrors.kernel.org/ubuntu/pool/main/m/mpfr4/libmpfr4_3.1.4-1_amd64.deb && dpkg -i libmpfr4_3.1.4-1_amd64.deb && rm libmpfr4_3.1.4-1_amd64.deb |
| 104 | |
| 105 | # Manually install a new enough version of efitools (must be v1.5.2 or later) |
| 106 | RUN wget http://mirrors.kernel.org/ubuntu/pool/universe/e/efitools/efitools_1.8.1-0ubuntu2_amd64.deb && sudo dpkg -i efitools_1.8.1-0ubuntu2_amd64.deb && rm efitools_1.8.1-0ubuntu2_amd64.deb |
| 107 | |
| 108 | # Manually install a new enough version of sbsigntools (must be v0.9.4 or later) |
| 109 | RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \ |
| 110 | cd /tmp/sbsigntools && \ |
| 111 | git checkout -b latest v0.9.4 && \ |
| 112 | ./autogen.sh && \ |
| 113 | ./configure && \ |
| 114 | make && \ |
| 115 | make install && \ |
| 116 | rm -rf /tmp/sbsigntools |
| 117 | |
| 118 | # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit |
| 119 | RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \ |
| 120 | cd /tmp/grub && \ |
| 121 | git checkout grub-2.04 && \ |
| 122 | ./bootstrap && \ |
| 123 | mkdir -p /opt/grub && \ |
| 124 | ./configure --target=aarch64 --with-platform=efi \ |
| 125 | CC=gcc \ |
| 126 | TARGET_CC=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \ |
| 127 | TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \ |
| 128 | TARGET_STRIP=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \ |
| 129 | TARGET_NM=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \ |
| 130 | TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \ |
| 131 | make && \ |
| 132 | ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \ |
| 133 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 134 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 135 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 136 | true && \ |
| 137 | make clean && \ |
| 138 | ./configure --target=arm --with-platform=efi \ |
| 139 | CC=gcc \ |
| 140 | TARGET_CC=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \ |
| 141 | TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \ |
| 142 | TARGET_STRIP=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \ |
| 143 | TARGET_NM=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \ |
| 144 | TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \ |
| 145 | make && \ |
| 146 | ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \ |
| 147 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 148 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 149 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 150 | true && \ |
| 151 | make clean && \ |
| 152 | ./configure --target=riscv64 --with-platform=efi \ |
| 153 | CC=gcc \ |
| 154 | TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \ |
| 155 | TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \ |
| 156 | TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \ |
| 157 | TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \ |
| 158 | TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \ |
| 159 | make && \ |
| 160 | ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \ |
| 161 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 162 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 163 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 164 | true && \ |
| 165 | make clean && \ |
| 166 | ./configure --target=riscv32 --with-platform=efi \ |
| 167 | CC=gcc \ |
| 168 | TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-gcc \ |
| 169 | TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-objcopy \ |
| 170 | TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-strip \ |
| 171 | TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-nm \ |
| 172 | TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-ranlib && \ |
| 173 | make && \ |
| 174 | ./grub-mkimage -O riscv32-efi -o /opt/grub/grubriscv32.efi --prefix= -d \ |
| 175 | grub-core cat chain configfile echo efinet ext2 fat halt help linux \ |
| 176 | lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \ |
| 177 | search search_fs_file search_fs_uuid search_label serial sleep test \ |
| 178 | true && \ |
| 179 | rm -rf /tmp/grub |
| 180 | |
| 181 | RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \ |
| 182 | cd /tmp/qemu && \ |
| 183 | git submodule update --init dtc && \ |
| 184 | git checkout v4.2.0 && \ |
| 185 | ./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" && \ |
| 186 | make -j$(nproc) all install && \ |
| 187 | rm -rf /tmp/qemu |
| 188 | |
| 189 | # Create our user/group |
| 190 | RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot |
| 191 | RUN useradd -m -U uboot |
| 192 | USER uboot:uboot |
| 193 | |
| 194 | # Create the buildman config file |
| 195 | RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman |
| 196 | RUN /bin/echo -e "kernelorg = /opt/gcc-9.2.0-nolibc/*" >> ~/.buildman |
| 197 | RUN /bin/echo -e "arc = /opt/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman |
| 198 | RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2018.02/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman; |
| 199 | RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman; |
| 200 | RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman |
| 201 | RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman |
| 202 | RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman |
| 203 | RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman; |