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