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