blob: 27821ae43a051454ac2371c778413c87896b8d67 [file] [log] [blame]
Tom Rini04549e92021-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 Rini13a1c8f2023-07-13 20:37:36 -04005FROM ubuntu:jammy-20230624
Tom Rini04549e92021-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 Riniad9b2fd2023-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 Rini04549e92021-03-15 13:19:01 -040016
Tom Rini3bd5ed72023-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 Rini04549e92021-03-15 13:19:01 -040030
31# Manually install other toolchains
Tom Rini0a78bc32021-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 Rini04549e92021-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 Glassbe17cb32023-08-24 13:55:46 -060042 cgpt \
Tom Riniad9b2fd2023-03-21 15:07:45 -040043 clang-16 \
Tom Rini04549e92021-03-15 13:19:01 -040044 coreutils \
45 cpio \
46 cppcheck \
47 curl \
48 device-tree-compiler \
49 dosfstools \
50 e2fsprogs \
51 efitools \
Huang Jianan11e04432022-02-26 15:05:51 +080052 erofs-utils \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010053 expect \
Tom Rini04549e92021-03-15 13:19:01 -040054 fakeroot \
55 flex \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010056 gawk \
Tom Rini04549e92021-03-15 13:19:01 -040057 gdisk \
58 git \
59 gnu-efi \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010060 gnutls-dev \
Tom Rini04549e92021-03-15 13:19:01 -040061 graphviz \
62 grub-efi-amd64-bin \
63 grub-efi-ia32-bin \
64 help2man \
65 iasl \
66 imagemagick \
67 iputils-ping \
Tom Riniac6c3332023-01-11 12:24:57 -050068 libc6-i386 \
Bin Mengf551a532021-08-26 23:33:33 +080069 libconfuse-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040070 libgit2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010071 libjson-glib-dev \
Tom Rini04549e92021-03-15 13:19:01 -040072 libguestfs-tools \
AKASHI Takahiro3edc3472022-02-01 10:32:36 +090073 libgnutls28-dev \
74 libgnutls30 \
Tom Rini04549e92021-03-15 13:19:01 -040075 liblz4-tool \
76 libpixman-1-dev \
Tom Rinic8982d22021-06-10 10:57:36 -040077 libpython3-dev \
Tom Rini04549e92021-03-15 13:19:01 -040078 libsdl1.2-dev \
79 libsdl2-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010080 libseccomp-dev \
Tom Rini83da2322023-07-13 10:16:28 -040081 libslirp-dev \
Tom Rini04549e92021-03-15 13:19:01 -040082 libssl-dev \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010083 libtool \
Tom Rini04549e92021-03-15 13:19:01 -040084 libudev-dev \
85 libusb-1.0-0-dev \
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +030086 linux-image-kvm \
Tom Rini04549e92021-03-15 13:19:01 -040087 lzma-alone \
88 lzop \
89 mount \
90 mtd-utils \
91 mtools \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +010092 net-tools \
Bin Meng00afccd2021-08-26 23:33:32 +080093 ninja-build \
Tom Rini04549e92021-03-15 13:19:01 -040094 openssl \
95 picocom \
96 parted \
97 pkg-config \
Tom Rinic8982d22021-06-10 10:57:36 -040098 python-is-python3 \
99 python2.7 \
100 python3 \
101 python3-dev \
Tom Rini04549e92021-03-15 13:19:01 -0400102 python3-pip \
Simon Glassb955cd22022-10-13 06:25:57 -0600103 python3-pyelftools \
Tom Rini04549e92021-03-15 13:19:01 -0400104 python3-sphinx \
Tom Rinic8982d22021-06-10 10:57:36 -0400105 python3-virtualenv \
Tom Rini04549e92021-03-15 13:19:01 -0400106 rpm2cpio \
107 sbsigntool \
108 sloccount \
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100109 socat \
110 softhsm2 \
Tom Rini04549e92021-03-15 13:19:01 -0400111 sparse \
112 srecord \
113 sudo \
114 swig \
Heinrich Schuchardtc2c98ea2022-12-30 05:41:01 +0100115 texinfo \
Tom Rini04549e92021-03-15 13:19:01 -0400116 util-linux \
117 uuid-dev \
118 virtualenv \
Simon Glassbe17cb32023-08-24 13:55:46 -0600119 vboot-kernel-utils \
120 vboot-utils \
Tom Rini0a78bc32021-07-02 10:41:58 -0400121 xxd \
Tom Rini04549e92021-03-15 13:19:01 -0400122 zip \
123 && rm -rf /var/lib/apt/lists/*
124
Alper Nebi Yasak5d249e92021-06-21 21:51:54 +0300125# Make kernels readable for libguestfs tools to work correctly
126RUN chmod +r /boot/vmlinu*
127
Tom Rini04549e92021-03-15 13:19:01 -0400128# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
129RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
130 cd /tmp/grub && \
Tom Rini0a78bc32021-07-02 10:41:58 -0400131 git checkout grub-2.06 && \
Tom Rini77d48f12022-11-22 12:31:58 -0500132 git config --global user.name "GitLab CI Runner" && \
133 git config --global user.email trini@konsulko.com && \
134 git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
Tom Rini619eb212023-07-13 20:37:35 -0400135 git cherry-pick 403d6540cd608b2706cfa0cb4713f7e4b490ff45 && \
Tom Rini04549e92021-03-15 13:19:01 -0400136 ./bootstrap && \
137 mkdir -p /opt/grub && \
138 ./configure --target=aarch64 --with-platform=efi \
139 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400140 TARGET_CC=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
141 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
142 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
143 TARGET_NM=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
144 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400145 make && \
146 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.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=arm --with-platform=efi \
153 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400154 TARGET_CC=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
155 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
156 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
157 TARGET_NM=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
158 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400159 make && \
160 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.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=riscv64 --with-platform=efi \
167 CC=gcc \
Tom Rini3bd5ed72023-08-25 13:21:26 -0400168 TARGET_CC=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
169 TARGET_OBJCOPY=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
170 TARGET_STRIP=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
171 TARGET_NM=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
172 TARGET_RANLIB=/opt/gcc-13.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rini04549e92021-03-15 13:19:01 -0400173 make && \
174 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.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 && \
Tom Rini04549e92021-03-15 13:19:01 -0400179 rm -rf /tmp/grub
180
Tom Rinib60c1d72023-02-07 12:50:13 -0500181RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
Tom Rini04549e92021-03-15 13:19:01 -0400182 cd /tmp/qemu && \
Tom Rini83da2322023-07-13 10:16:28 -0400183 git checkout v8.0.3 && \
Bin Meng00afccd2021-08-26 23:33:32 +0800184 # config user.name and user.email to make 'git am' happy
185 git config user.name u-boot && \
186 git config user.email u-boot@denx.de && \
Tom Rini26a41832023-03-21 15:28:00 -0400187 ./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 Rini04549e92021-03-15 13:19:01 -0400188 make -j$(nproc) all install && \
189 rm -rf /tmp/qemu
190
Heinrich Schuchardt4c04c442023-01-13 20:31:33 +0100191# Build QEMU supporting Nokia n900 emulation
192RUN mkdir -p /opt/nokia && \
193 cd /tmp && \
194 git clone https://git.linaro.org/qemu/qemu-linaro.git && \
195 cd /tmp/qemu-linaro && \
196 git checkout 8f8d8e0796efe1a6f34cdd83fb798f3c41217ec1 && \
197 ./configure --enable-system --target-list=arm-softmmu \
198 --python=/usr/bin/python2.7 --disable-sdl --disable-gtk \
199 --disable-curses --audio-drv-list= --audio-card-list= \
200 --disable-werror --disable-xen --disable-xen-pci-passthrough \
201 --disable-brlapi --disable-vnc --disable-curl --disable-slirp \
202 --disable-kvm --disable-user --disable-linux-user --disable-bsd-user \
203 --disable-guest-base --disable-uuid --disable-vde --disable-linux-aio \
204 --disable-cap-ng --disable-attr --disable-blobs --disable-docs \
205 --disable-spice --disable-libiscsi --disable-smartcard-nss \
206 --disable-usb-redir --disable-guest-agent --disable-seccomp \
207 --disable-glusterfs --disable-nptl --disable-fdt && \
208 make -j$(nproc) && \
209 cp /tmp/qemu-linaro/arm-softmmu/qemu-system-arm /opt/nokia && \
210 rm -rf /tmp/qemu-linaro
211
Bin Mengf551a532021-08-26 23:33:33 +0800212# Build genimage (required by some targets to generate disk images)
213RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
214 cd /tmp/genimage-14 && \
215 ./configure && \
216 make -j$(nproc) && \
217 make install && \
218 rm -rf /tmp/genimage-14
219
Heinrich Schuchardt4e202672021-11-09 19:51:20 +0100220# Build libtpms
221RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
222 cd /tmp/libtpms && \
223 ./autogen.sh && \
224 ./configure && \
225 make -j$(nproc) && \
226 make install && \
227 ldconfig && \
228 rm -rf /tmp/libtpms
229
230# Build swtpm
231RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
232 cd /tmp/swtpm && \
233 ./autogen.sh && \
234 ./configure && \
235 make -j$(nproc) && \
236 make install && \
237 rm -rf /tmp/swtpm
238
Simon Glass523cb6d2023-01-15 14:15:59 -0700239# Build trace-cmd
240RUN mkdir /tmp/trace && \
241 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
242 cd /tmp/trace/libtraceevent && \
243 make -j$(nproc) && \
244 sudo make install && \
245 git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
246 cd /tmp/trace/libtracefs && \
247 make -j$(nproc) && \
248 sudo make install && \
249 git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
250 cd /tmp/trace/trace-cmd && \
251 make -j$(nproc) && \
252 sudo make install && \
253 rm -rf /tmp/trace
254
Heinrich Schuchardtc49eca02023-01-13 19:25:01 +0100255# Files to run Nokia RX-51 (aka N900) tests
256RUN mkdir -p /opt/nokia && \
257 cd /opt/nokia && \
258 wget https://raw.githubusercontent.com/pali/u-boot-maemo/master/debian/u-boot-gen-combined && \
Tom Riniccf4de52023-02-27 10:49:54 -0500259 chmod 0755 u-boot-gen-combined && \
Heinrich Schuchardtc49eca02023-01-13 19:25:01 +0100260 wget http://repository.maemo.org/qemu-n900/qemu-n900.tar.gz && \
261 wget http://repository.maemo.org/pool/maemo5.0/free/k/kernel/kernel_2.6.28-20103103+0m5_armel.deb && \
262 wget http://repository.maemo.org/pool/maemo5.0/free/g/glibc/libc6_2.5.1-1eglibc27+0m5_armel.deb && \
263 wget http://repository.maemo.org/pool/maemo5.0/free/b/busybox/busybox_1.10.2.legal-1osso30+0m5_armel.deb
264
Tom Rini04549e92021-03-15 13:19:01 -0400265# Create our user/group
266RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
267RUN useradd -m -U uboot
268USER uboot:uboot
269
Tom Rini54573e02023-03-23 14:57:58 -0400270# Populate the cache for pip to use. Get these via wget as the
271# COPY / ADD directives don't work as we need them to.
272RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt
273RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt
274RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
275 . /tmp/venv/bin/activate && \
276 pip install -r /tmp/pytest-requirements.txt \
277 -r /tmp/sphinx-requirements.txt && \
278 deactivate && \
279 rm -rf /tmp/venv /tmp/pytest-requirements.txt /tmp/sphinx-requirements.txt
280
Tom Rini04549e92021-03-15 13:19:01 -0400281# Create the buildman config file
282RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini3bd5ed72023-08-25 13:21:26 -0400283RUN /bin/echo -e "kernelorg = /opt/gcc-13.2.0-nolibc/*" >> ~/.buildman
Tom Rini0a78bc32021-07-02 10:41:58 -0400284RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
Tom Rini04549e92021-03-15 13:19:01 -0400285RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
Tom Rini04549e92021-03-15 13:19:01 -0400286RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
287RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
Safae Ouajihaaa366f2023-02-06 00:50:21 +0100288
289# Add mkbootimg tool
290RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
291ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"