blob: de0c6cee8c76f7eae6f25b938404f592a1994c2a [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 Rinib1c21022021-06-10 10:57:36 -04005FROM ubuntu:focal-20210609
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 Rinib1c21022021-06-10 10:57:36 -040015RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-10 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rinia6432252021-03-15 13:19:01 -040016
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 \
Tom Rinib1c21022021-06-10 10:57:36 -040064 libgit2-dev \
Tom Rinia6432252021-03-15 13:19:01 -040065 libguestfs-tools \
Tom Rinia6432252021-03-15 13:19:01 -040066 liblz4-tool \
67 libpixman-1-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040068 libpython3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040069 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 \
Tom Rinib1c21022021-06-10 10:57:36 -040084 python-is-python3 \
85 python2.7 \
86 python3 \
87 python3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040088 python3-pip \
89 python3-sphinx \
Tom Rinib1c21022021-06-10 10:57:36 -040090 python3-virtualenv \
Tom Rinia6432252021-03-15 13:19:01 -040091 rpm2cpio \
92 sbsigntool \
93 sloccount \
94 sparse \
95 srecord \
96 sudo \
97 swig \
98 util-linux \
99 uuid-dev \
100 virtualenv \
101 zip \
102 && rm -rf /var/lib/apt/lists/*
103
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +0300104# Make kernels readable for libguestfs tools to work correctly
105RUN chmod +r /boot/vmlinu*
106
Tom Rinia6432252021-03-15 13:19:01 -0400107# Manually install libmpfr4 for the toolchains
108RUN 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
109
Tom Rinia6432252021-03-15 13:19:01 -0400110# Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
111RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
112 cd /tmp/sbsigntools && \
113 git checkout -b latest v0.9.4 && \
114 ./autogen.sh && \
115 ./configure && \
116 make && \
117 make install && \
118 rm -rf /tmp/sbsigntools
119
120# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
121RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
122 cd /tmp/grub && \
123 git checkout grub-2.04 && \
124 ./bootstrap && \
125 mkdir -p /opt/grub && \
126 ./configure --target=aarch64 --with-platform=efi \
127 CC=gcc \
128 TARGET_CC=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
129 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
130 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
131 TARGET_NM=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
132 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
133 make && \
134 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
135 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
136 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
137 search search_fs_file search_fs_uuid search_label serial sleep test \
138 true && \
139 make clean && \
140 ./configure --target=arm --with-platform=efi \
141 CC=gcc \
142 TARGET_CC=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
143 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
144 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
145 TARGET_NM=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
146 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
147 make && \
148 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
149 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
150 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
151 search search_fs_file search_fs_uuid search_label serial sleep test \
152 true && \
153 make clean && \
154 ./configure --target=riscv64 --with-platform=efi \
155 CC=gcc \
156 TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
157 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
158 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
159 TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
160 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
161 make && \
162 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
163 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
164 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
165 search search_fs_file search_fs_uuid search_label serial sleep test \
166 true && \
167 make clean && \
168 ./configure --target=riscv32 --with-platform=efi \
169 CC=gcc \
170 TARGET_CC=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-gcc \
171 TARGET_OBJCOPY=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-objcopy \
172 TARGET_STRIP=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-strip \
173 TARGET_NM=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-nm \
174 TARGET_RANLIB=/opt/gcc-9.2.0-nolibc/riscv32-linux/bin/riscv32-linux-ranlib && \
175 make && \
176 ./grub-mkimage -O riscv32-efi -o /opt/grub/grubriscv32.efi --prefix= -d \
177 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
178 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
179 search search_fs_file search_fs_uuid search_label serial sleep test \
180 true && \
181 rm -rf /tmp/grub
182
183RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
184 cd /tmp/qemu && \
185 git submodule update --init dtc && \
186 git checkout v4.2.0 && \
187 ./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" && \
188 make -j$(nproc) all install && \
189 rm -rf /tmp/qemu
190
191# Create our user/group
192RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
193RUN useradd -m -U uboot
194USER uboot:uboot
195
196# Create the buildman config file
197RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
198RUN /bin/echo -e "kernelorg = /opt/gcc-9.2.0-nolibc/*" >> ~/.buildman
199RUN /bin/echo -e "arc = /opt/arc_gnu_2019.09_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
200RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2018.02/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
201RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
202RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
203RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
204RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
205RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;