blob: 579df82b56e72cbebd378ec282c53f7e5bd7a4f5 [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
5FROM ubuntu:bionic-20200807
6MAINTAINER 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 -
15RUN 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
18RUN 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
19RUN 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
20RUN 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
21RUN 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
22RUN 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
23RUN 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
24RUN 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
25RUN 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
26RUN 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
27RUN 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
28RUN 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
31RUN 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
32RUN 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
33RUN 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
36RUN 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 \
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +030074 linux-image-kvm \
Tom Rinia6432252021-03-15 13:19:01 -040075 lzma-alone \
76 lzop \
77 mount \
78 mtd-utils \
79 mtools \
80 openssl \
81 picocom \
82 parted \
83 pkg-config \
84 python \
85 python-dev \
86 python-pip \
87 python-virtualenv \
88 python3-pip \
89 python3-sphinx \
90 rpm2cpio \
91 sbsigntool \
92 sloccount \
93 sparse \
94 srecord \
95 sudo \
96 swig \
97 util-linux \
98 uuid-dev \
99 virtualenv \
100 zip \
101 && rm -rf /var/lib/apt/lists/*
102
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +0300103# Make kernels readable for libguestfs tools to work correctly
104RUN chmod +r /boot/vmlinu*
105
Tom Rinia6432252021-03-15 13:19:01 -0400106# Manually install libmpfr4 for the toolchains
107RUN 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
108
109# Manually install a new enough version of efitools (must be v1.5.2 or later)
110RUN 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
111
112# Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
113RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
114 cd /tmp/sbsigntools && \
115 git checkout -b latest v0.9.4 && \
116 ./autogen.sh && \
117 ./configure && \
118 make && \
119 make install && \
120 rm -rf /tmp/sbsigntools
121
122# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
123RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
124 cd /tmp/grub && \
125 git checkout grub-2.04 && \
126 ./bootstrap && \
127 mkdir -p /opt/grub && \
128 ./configure --target=aarch64 --with-platform=efi \
129 CC=gcc \
130 TARGET_CC=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
131 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
132 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
133 TARGET_NM=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
134 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
135 make && \
136 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
137 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
138 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
139 search search_fs_file search_fs_uuid search_label serial sleep test \
140 true && \
141 make clean && \
142 ./configure --target=arm --with-platform=efi \
143 CC=gcc \
144 TARGET_CC=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
145 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
146 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
147 TARGET_NM=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
148 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
149 make && \
150 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
151 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
152 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
153 search search_fs_file search_fs_uuid search_label serial sleep test \
154 true && \
155 make clean && \
156 ./configure --target=riscv64 --with-platform=efi \
157 CC=gcc \
158 TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
159 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
160 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
161 TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
162 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
163 make && \
164 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
165 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
166 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
167 search search_fs_file search_fs_uuid search_label serial sleep test \
168 true && \
169 make clean && \
170 ./configure --target=riscv32 --with-platform=efi \
171 CC=gcc \
172 TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-gcc \
173 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-objcopy \
174 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-strip \
175 TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-nm \
176 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-ranlib && \
177 make && \
178 ./grub-mkimage -O riscv32-efi -o /opt/grub/grubriscv32.efi --prefix= -d \
179 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
180 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
181 search search_fs_file search_fs_uuid search_label serial sleep test \
182 true && \
183 rm -rf /tmp/grub
184
185RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
186 cd /tmp/qemu && \
187 git submodule update --init dtc && \
188 git checkout v4.2.0 && \
189 ./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" && \
190 make -j$(nproc) all install && \
191 rm -rf /tmp/qemu
192
193# Create our user/group
194RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
195RUN useradd -m -U uboot
196USER uboot:uboot
197
198# Create the buildman config file
199RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
200RUN /bin/echo -e "kernelorg = /opt/gcc-9.2.0-nolibc/*" >> ~/.buildman
201RUN /bin/echo -e "arc = /opt/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
202RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2018.02/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
203RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
204RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
205RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
206RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
207RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;