blob: 1acb5413c7e7e0b90f0343d94cdf80d15ea65a94 [file] [log] [blame]
Tom Rinia6432252021-03-15 13:19:01 -04001# 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 Rini453c3fb2023-08-25 13:21:27 -04005FROM ubuntu:jammy-20230804
Tom Rinia6432252021-03-15 13:19:01 -04006MAINTAINER 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 -
Tom Rinid7e06782023-03-21 15:07:45 -040015RUN echo deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rinia6432252021-03-15 13:19:01 -040016
Tom Rini11934282023-08-25 13:21:26 -040017# Manually install the kernel.org "Crosstool" based toolchains for gcc-13.2.0
18RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.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/13.2.0/x86_64-gcc-13.2.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ
20RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
21RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
22RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
23RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
24RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
25RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
26RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
27RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
28RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
29RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.2.0/x86_64-gcc-13.2.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
Tom Rinia6432252021-03-15 13:19:01 -040030
31# Manually install other toolchains
Tom Rini7bb1cc32021-07-02 10:41:58 -040032RUN 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
Tom Rinia6432252021-03-15 13:19:01 -040033
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 \
Simon Glassf25820b2023-08-24 13:55:46 -060042 cgpt \
Tom Rinid7e06782023-03-21 15:07:45 -040043 clang-16 \
Tom Rinia6432252021-03-15 13:19:01 -040044 coreutils \
45 cpio \
Tom Rinia6432252021-03-15 13:19:01 -040046 curl \
47 device-tree-compiler \
48 dosfstools \
49 e2fsprogs \
50 efitools \
Huang Jianan2c30aa32022-02-26 15:05:51 +080051 erofs-utils \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010052 expect \
Tom Rinia6432252021-03-15 13:19:01 -040053 fakeroot \
54 flex \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010055 gawk \
Tom Rinia6432252021-03-15 13:19:01 -040056 gdisk \
57 git \
58 gnu-efi \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010059 gnutls-dev \
Tom Rinia6432252021-03-15 13:19:01 -040060 graphviz \
61 grub-efi-amd64-bin \
62 grub-efi-ia32-bin \
63 help2man \
64 iasl \
65 imagemagick \
66 iputils-ping \
Tom Rini85fd4892023-01-11 12:24:57 -050067 libc6-i386 \
Bin Meng3283a052021-08-26 23:33:33 +080068 libconfuse-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040069 libgit2-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010070 libjson-glib-dev \
Tom Rinia6432252021-03-15 13:19:01 -040071 libguestfs-tools \
AKASHI Takahiroad3616e2022-02-01 10:32:36 +090072 libgnutls28-dev \
73 libgnutls30 \
Tom Rinia6432252021-03-15 13:19:01 -040074 liblz4-tool \
75 libpixman-1-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040076 libpython3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040077 libsdl1.2-dev \
78 libsdl2-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010079 libseccomp-dev \
Tom Rinib45ab9c2023-07-13 10:16:28 -040080 libslirp-dev \
Tom Rinia6432252021-03-15 13:19:01 -040081 libssl-dev \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010082 libtool \
Tom Rinia6432252021-03-15 13:19:01 -040083 libudev-dev \
84 libusb-1.0-0-dev \
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +030085 linux-image-kvm \
Tom Rinia6432252021-03-15 13:19:01 -040086 lzma-alone \
87 lzop \
88 mount \
89 mtd-utils \
90 mtools \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +010091 net-tools \
Bin Menga30e53c2021-08-26 23:33:32 +080092 ninja-build \
Tom Rinia6432252021-03-15 13:19:01 -040093 openssl \
94 picocom \
95 parted \
96 pkg-config \
Tom Rinib1c21022021-06-10 10:57:36 -040097 python-is-python3 \
98 python2.7 \
99 python3 \
100 python3-dev \
Tom Rinia6432252021-03-15 13:19:01 -0400101 python3-pip \
Simon Glass33799262022-10-13 06:25:57 -0600102 python3-pyelftools \
Tom Rinia6432252021-03-15 13:19:01 -0400103 python3-sphinx \
Tom Rinib1c21022021-06-10 10:57:36 -0400104 python3-virtualenv \
Tom Rinia6432252021-03-15 13:19:01 -0400105 rpm2cpio \
106 sbsigntool \
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +0100107 socat \
108 softhsm2 \
Tom Rinia6432252021-03-15 13:19:01 -0400109 sparse \
110 srecord \
111 sudo \
112 swig \
Heinrich Schuchardt5f7a5072022-12-30 05:41:01 +0100113 texinfo \
Tom Rinia6432252021-03-15 13:19:01 -0400114 util-linux \
115 uuid-dev \
116 virtualenv \
Simon Glassf25820b2023-08-24 13:55:46 -0600117 vboot-kernel-utils \
118 vboot-utils \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400119 xxd \
Tom Rinia6432252021-03-15 13:19:01 -0400120 zip \
121 && rm -rf /var/lib/apt/lists/*
122
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +0300123# Make kernels readable for libguestfs tools to work correctly
124RUN chmod +r /boot/vmlinu*
125
Tom Rinia6432252021-03-15 13:19:01 -0400126# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
127RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
128 cd /tmp/grub && \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400129 git checkout grub-2.06 && \
Tom Rini09ed7e62022-11-22 12:31:58 -0500130 git config --global user.name "GitLab CI Runner" && \
131 git config --global user.email trini@konsulko.com && \
132 git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
Tom Rini6d6ddab2023-07-13 20:37:35 -0400133 git cherry-pick 403d6540cd608b2706cfa0cb4713f7e4b490ff45 && \
Tom Rinia6432252021-03-15 13:19:01 -0400134 ./bootstrap && \
135 mkdir -p /opt/grub && \
136 ./configure --target=aarch64 --with-platform=efi \
137 CC=gcc \
Tom Rini11934282023-08-25 13:21:26 -0400138 TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
139 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
140 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
141 TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
142 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400143 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 \
Tom Rini11934282023-08-25 13:21:26 -0400152 TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
153 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
154 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
155 TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
156 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400157 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 \
Tom Rini11934282023-08-25 13:21:26 -0400166 TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
167 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
168 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
169 TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
170 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400171 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 && \
Tom Rinia6432252021-03-15 13:19:01 -0400177 rm -rf /tmp/grub
178
Tom Rinie38cdc62023-02-07 12:50:13 -0500179RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
Tom Rinia6432252021-03-15 13:19:01 -0400180 cd /tmp/qemu && \
Tom Rinib45ab9c2023-07-13 10:16:28 -0400181 git checkout v8.0.3 && \
Bin Menga30e53c2021-08-26 23:33:32 +0800182 # config user.name and user.email to make 'git am' happy
183 git config user.name u-boot && \
184 git config user.email u-boot@denx.de && \
Tom Rini38547062023-03-21 15:28:00 -0400185 ./configure --prefix=/opt/qemu --target-list="aarch64-softmmu,arm-softmmu,i386-softmmu,m68k-softmmu,mips-softmmu,mips64-softmmu,mips64el-softmmu,mipsel-softmmu,ppc-softmmu,riscv32-softmmu,riscv64-softmmu,sh4-softmmu,x86_64-softmmu,xtensa-softmmu" && \
Tom Rinia6432252021-03-15 13:19:01 -0400186 make -j$(nproc) all install && \
187 rm -rf /tmp/qemu
188
Heinrich Schuchardted319ba2023-01-13 20:31:33 +0100189# Build QEMU supporting Nokia n900 emulation
190RUN mkdir -p /opt/nokia && \
191 cd /tmp && \
192 git clone https://git.linaro.org/qemu/qemu-linaro.git && \
193 cd /tmp/qemu-linaro && \
194 git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 && \
195 ./configure --enable-system --target-list=arm-softmmu \
196 --python=/usr/bin/python2.7 --disable-sdl --disable-gtk \
197 --disable-curses --audio-drv-list= --audio-card-list= \
198 --disable-werror --disable-xen --disable-xen-pci-passthrough \
199 --disable-brlapi --disable-vnc --disable-curl --disable-slirp \
200 --disable-kvm --disable-user --disable-linux-user --disable-bsd-user \
201 --disable-guest-base --disable-uuid --disable-vde --disable-linux-aio \
202 --disable-cap-ng --disable-attr --disable-blobs --disable-docs \
203 --disable-spice --disable-libiscsi --disable-smartcard-nss \
204 --disable-usb-redir --disable-guest-agent --disable-seccomp \
205 --disable-glusterfs --disable-nptl --disable-fdt && \
206 make -j$(nproc) && \
207 cp /tmp/qemu-linaro/arm-softmmu/qemu-system-arm /opt/nokia && \
208 rm -rf /tmp/qemu-linaro
209
Bin Meng3283a052021-08-26 23:33:33 +0800210# Build genimage (required by some targets to generate disk images)
211RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
212 cd /tmp/genimage-14 && \
213 ./configure && \
214 make -j$(nproc) && \
215 make install && \
216 rm -rf /tmp/genimage-14
217
Heinrich Schuchardt8a87d1a2021-11-09 19:51:20 +0100218# Build libtpms
219RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
220 cd /tmp/libtpms && \
221 ./autogen.sh && \
222 ./configure && \
223 make -j$(nproc) && \
224 make install && \
225 ldconfig && \
226 rm -rf /tmp/libtpms
227
228# Build swtpm
229RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
230 cd /tmp/swtpm && \
231 ./autogen.sh && \
232 ./configure && \
233 make -j$(nproc) && \
234 make install && \
235 rm -rf /tmp/swtpm
236
Simon Glass71d3e792023-01-15 14:15:59 -0700237# Build trace-cmd
238RUN mkdir /tmp/trace && \
239 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
240 cd /tmp/trace/libtraceevent && \
241 make -j$(nproc) && \
242 sudo make install && \
243 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
244 cd /tmp/trace/libtracefs && \
245 make -j$(nproc) && \
246 sudo make install && \
247 git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
248 cd /tmp/trace/trace-cmd && \
249 make -j$(nproc) && \
250 sudo make install && \
251 rm -rf /tmp/trace
252
Heinrich Schuchardt75b031e2023-01-13 19:25:01 +0100253# Files to run Nokia RX-51 (aka N900) tests
254RUN mkdir -p /opt/nokia && \
255 cd /opt/nokia && \
256 wget https://raw.githubusercontent.com/pali/u-boot-maemo/master/debian/u-boot-gen-combined && \
Tom Rini7a826de2023-02-27 10:49:54 -0500257 chmod 0755 u-boot-gen-combined && \
Heinrich Schuchardt75b031e2023-01-13 19:25:01 +0100258 wget http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz && \
259 wget http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb && \
260 wget http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb && \
261 wget http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb
262
Tom Rinia6432252021-03-15 13:19:01 -0400263# Create our user/group
264RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
265RUN useradd -m -U uboot
266USER uboot:uboot
267
Tom Rini866f3022023-03-23 14:57:58 -0400268# Populate the cache for pip to use. Get these via wget as the
269# COPY / ADD directives don't work as we need them to.
270RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt
271RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt
272RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
273 . /tmp/venv/bin/activate && \
274 pip install -r /tmp/pytest-requirements.txt \
275 -r /tmp/sphinx-requirements.txt && \
276 deactivate && \
277 rm -rf /tmp/venv /tmp/pytest-requirements.txt /tmp/sphinx-requirements.txt
278
Tom Rinia6432252021-03-15 13:19:01 -0400279# Create the buildman config file
280RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini11934282023-08-25 13:21:26 -0400281RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
Tom Rini7bb1cc32021-07-02 10:41:58 -0400282RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
Tom Rinia6432252021-03-15 13:19:01 -0400283RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
Tom Rinia6432252021-03-15 13:19:01 -0400284RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
285RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
Safae Ouajihf4449392023-02-06 00:50:21 +0100286
287# Add mkbootimg tool
288RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
289ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"