blob: ced4457ab20d87827ec1b697e15e536f92904450 [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 Rini7bb1cc32021-07-02 10:41:58 -040015RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main | tee /etc/apt/sources.list.d/llvm.list
Tom Rinia6432252021-03-15 13:19:01 -040016
Tom Rini7bb1cc32021-07-02 10:41:58 -040017# Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0
18RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.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/11.1.0/x86_64-gcc-11.1.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
27RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/11.1.0/x86_64-gcc-11.1.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
Tom Rinia6432252021-03-15 13:19:01 -040028
29# Manually install other toolchains
Tom Rini7bb1cc32021-07-02 10:41:58 -040030RUN 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
31RUN 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 Rinia6432252021-03-15 13:19:01 -040032RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
33
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 \
42 clang-10 \
43 coreutils \
44 cpio \
45 cppcheck \
46 curl \
47 device-tree-compiler \
48 dosfstools \
49 e2fsprogs \
50 efitools \
51 fakeroot \
52 flex \
53 gdisk \
54 git \
55 gnu-efi \
56 graphviz \
57 grub-efi-amd64-bin \
58 grub-efi-ia32-bin \
59 help2man \
60 iasl \
61 imagemagick \
62 iputils-ping \
Tom Rinib1c21022021-06-10 10:57:36 -040063 libgit2-dev \
Tom Rinia6432252021-03-15 13:19:01 -040064 libguestfs-tools \
Tom Rinia6432252021-03-15 13:19:01 -040065 liblz4-tool \
66 libpixman-1-dev \
Tom Rinib1c21022021-06-10 10:57:36 -040067 libpython3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040068 libsdl1.2-dev \
69 libsdl2-dev \
70 libssl-dev \
71 libudev-dev \
72 libusb-1.0-0-dev \
Alper Nebi Yasakf9abaa52021-06-21 21:51:54 +030073 linux-image-kvm \
Tom Rinia6432252021-03-15 13:19:01 -040074 lzma-alone \
75 lzop \
76 mount \
77 mtd-utils \
78 mtools \
79 openssl \
80 picocom \
81 parted \
82 pkg-config \
Tom Rinib1c21022021-06-10 10:57:36 -040083 python-is-python3 \
84 python2.7 \
85 python3 \
86 python3-dev \
Tom Rinia6432252021-03-15 13:19:01 -040087 python3-pip \
88 python3-sphinx \
Tom Rinib1c21022021-06-10 10:57:36 -040089 python3-virtualenv \
Tom Rinia6432252021-03-15 13:19:01 -040090 rpm2cpio \
91 sbsigntool \
92 sloccount \
93 sparse \
94 srecord \
95 sudo \
96 swig \
97 util-linux \
98 uuid-dev \
99 virtualenv \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400100 xxd \
Tom Rinia6432252021-03-15 13:19:01 -0400101 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 a new enough version of sbsigntools (must be v0.9.4 or later)
108RUN git clone https://git.kernel.org/pub/scm/linux/kernel/git/jejb/sbsigntools.git /tmp/sbsigntools && \
109 cd /tmp/sbsigntools && \
110 git checkout -b latest v0.9.4 && \
111 ./autogen.sh && \
112 ./configure && \
113 make && \
114 make install && \
115 rm -rf /tmp/sbsigntools
116
117# Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
118RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
119 cd /tmp/grub && \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400120 git checkout grub-2.06 && \
Tom Rinia6432252021-03-15 13:19:01 -0400121 ./bootstrap && \
122 mkdir -p /opt/grub && \
123 ./configure --target=aarch64 --with-platform=efi \
124 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400125 TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
126 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
127 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
128 TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
129 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400130 make && \
131 ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
132 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
133 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
134 search search_fs_file search_fs_uuid search_label serial sleep test \
135 true && \
136 make clean && \
137 ./configure --target=arm --with-platform=efi \
138 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400139 TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
140 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
141 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
142 TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
143 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400144 make && \
145 ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
146 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
147 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
148 search search_fs_file search_fs_uuid search_label serial sleep test \
149 true && \
150 make clean && \
151 ./configure --target=riscv64 --with-platform=efi \
152 CC=gcc \
Tom Rini7bb1cc32021-07-02 10:41:58 -0400153 TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
154 TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
155 TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
156 TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
157 TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
Tom Rinia6432252021-03-15 13:19:01 -0400158 make && \
159 ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
160 grub-core cat chain configfile echo efinet ext2 fat halt help linux \
161 lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
162 search search_fs_file search_fs_uuid search_label serial sleep test \
163 true && \
Tom Rinia6432252021-03-15 13:19:01 -0400164 rm -rf /tmp/grub
165
166RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
167 cd /tmp/qemu && \
168 git submodule update --init dtc && \
169 git checkout v4.2.0 && \
170 ./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" && \
171 make -j$(nproc) all install && \
172 rm -rf /tmp/qemu
173
174# Create our user/group
175RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
176RUN useradd -m -U uboot
177USER uboot:uboot
178
179# Create the buildman config file
180RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
Tom Rini7bb1cc32021-07-02 10:41:58 -0400181RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
182RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
183RUN /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 -0400184RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
185RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
186RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
187RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
188RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;