Dockerfile 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. # 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. FROM ubuntu:focal-20211006
  5. MAINTAINER Tom Rini <trini@konsulko.com>
  6. LABEL Description=" This image is for building U-Boot inside a container"
  7. # Make sure apt is happy
  8. ENV DEBIAN_FRONTEND=noninteractive
  9. # Add LLVM repository
  10. RUN apt-get update && apt-get install -y gnupg2 wget xz-utils && rm -rf /var/lib/apt/lists/*
  11. RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
  12. RUN echo deb http://apt.llvm.org/focal/ llvm-toolchain-focal-13 main | tee /etc/apt/sources.list.d/llvm.list
  13. # Manually install the kernel.org "Crosstool" based toolchains for gcc-11.1.0
  14. RUN 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
  15. RUN 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
  16. RUN 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
  17. RUN 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
  18. RUN 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
  19. RUN 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
  20. RUN 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
  21. RUN 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
  22. RUN 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
  23. RUN 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
  24. # Manually install other toolchains
  25. RUN 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
  26. RUN 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
  27. RUN wget -O - https://github.com/vincentzwc/prebuilt-nds32-toolchain/releases/download/20180521/nds32le-linux-glibc-v3-upstream.tar.gz | tar -C /opt -xz
  28. # Update and install things from apt now
  29. RUN apt-get update && apt-get install -y \
  30. automake \
  31. autopoint \
  32. bc \
  33. binutils-dev \
  34. bison \
  35. build-essential \
  36. clang-13 \
  37. coreutils \
  38. cpio \
  39. cppcheck \
  40. curl \
  41. device-tree-compiler \
  42. dosfstools \
  43. e2fsprogs \
  44. efitools \
  45. expect \
  46. fakeroot \
  47. flex \
  48. gawk \
  49. gdisk \
  50. git \
  51. gnu-efi \
  52. gnutls-dev \
  53. graphviz \
  54. grub-efi-amd64-bin \
  55. grub-efi-ia32-bin \
  56. help2man \
  57. iasl \
  58. imagemagick \
  59. iputils-ping \
  60. libconfuse-dev \
  61. libgit2-dev \
  62. libjson-glib-dev \
  63. libguestfs-tools \
  64. liblz4-tool \
  65. libpixman-1-dev \
  66. libpython3-dev \
  67. libsdl1.2-dev \
  68. libsdl2-dev \
  69. libseccomp-dev \
  70. libssl-dev \
  71. libtool \
  72. libudev-dev \
  73. libusb-1.0-0-dev \
  74. linux-image-kvm \
  75. lzma-alone \
  76. lzop \
  77. mount \
  78. mtd-utils \
  79. mtools \
  80. net-tools \
  81. ninja-build \
  82. openssl \
  83. picocom \
  84. parted \
  85. pkg-config \
  86. python-is-python3 \
  87. python2.7 \
  88. python3 \
  89. python3-dev \
  90. python3-pip \
  91. python3-sphinx \
  92. python3-virtualenv \
  93. rpm2cpio \
  94. sbsigntool \
  95. sloccount \
  96. socat \
  97. softhsm2 \
  98. sparse \
  99. srecord \
  100. sudo \
  101. swig \
  102. util-linux \
  103. uuid-dev \
  104. virtualenv \
  105. xxd \
  106. zip \
  107. && rm -rf /var/lib/apt/lists/*
  108. # Make kernels readable for libguestfs tools to work correctly
  109. RUN chmod +r /boot/vmlinu*
  110. # Manually install a new enough version of sbsigntools (must be v0.9.4 or later)
  111. RUN 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. # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
  120. RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
  121. cd /tmp/grub && \
  122. git checkout grub-2.06 && \
  123. ./bootstrap && \
  124. mkdir -p /opt/grub && \
  125. ./configure --target=aarch64 --with-platform=efi \
  126. CC=gcc \
  127. TARGET_CC=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
  128. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
  129. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
  130. TARGET_NM=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
  131. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
  132. make && \
  133. ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
  134. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  135. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  136. search search_fs_file search_fs_uuid search_label serial sleep test \
  137. true && \
  138. make clean && \
  139. ./configure --target=arm --with-platform=efi \
  140. CC=gcc \
  141. TARGET_CC=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
  142. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
  143. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
  144. TARGET_NM=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
  145. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
  146. make && \
  147. ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
  148. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  149. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  150. search search_fs_file search_fs_uuid search_label serial sleep test \
  151. true && \
  152. make clean && \
  153. ./configure --target=riscv64 --with-platform=efi \
  154. CC=gcc \
  155. TARGET_CC=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
  156. TARGET_OBJCOPY=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
  157. TARGET_STRIP=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
  158. TARGET_NM=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
  159. TARGET_RANLIB=/opt/gcc-11.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
  160. make && \
  161. ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
  162. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  163. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  164. search search_fs_file search_fs_uuid search_label serial sleep test \
  165. true && \
  166. rm -rf /tmp/grub
  167. RUN git clone git://git.qemu.org/qemu.git /tmp/qemu && \
  168. cd /tmp/qemu && \
  169. git submodule update --init dtc && \
  170. git checkout v6.1.0 && \
  171. # config user.name and user.email to make 'git am' happy
  172. git config user.name u-boot && \
  173. git config user.email u-boot@denx.de && \
  174. # manually apply the bug fix for QEMU 6.1.0 Xilinx Zynq UART emulation codes
  175. wget -O - http://patchwork.ozlabs.org/project/qemu-devel/patch/20210823020813.25192-2-bmeng.cn@gmail.com/mbox/ | git am && \
  176. ./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" && \
  177. make -j$(nproc) all install && \
  178. rm -rf /tmp/qemu
  179. # Build genimage (required by some targets to generate disk images)
  180. RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
  181. cd /tmp/genimage-14 && \
  182. ./configure && \
  183. make -j$(nproc) && \
  184. make install && \
  185. rm -rf /tmp/genimage-14
  186. # Build libtpms
  187. RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
  188. cd /tmp/libtpms && \
  189. ./autogen.sh && \
  190. ./configure && \
  191. make -j$(nproc) && \
  192. make install && \
  193. ldconfig && \
  194. rm -rf /tmp/libtpms
  195. # Build swtpm
  196. RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
  197. cd /tmp/swtpm && \
  198. ./autogen.sh && \
  199. ./configure && \
  200. make -j$(nproc) && \
  201. make install && \
  202. rm -rf /tmp/swtpm
  203. # Create our user/group
  204. RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
  205. RUN useradd -m -U uboot
  206. USER uboot:uboot
  207. # Create the buildman config file
  208. RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
  209. RUN /bin/echo -e "kernelorg = /opt/gcc-11.1.0-nolibc/*" >> ~/.buildman
  210. RUN /bin/echo -e "arc = /opt/arc_gnu_2021.03_prebuilt_uclibc_le_archs_linux_install" >> ~/.buildman
  211. RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
  212. RUN /bin/echo -e "\nnds32 = /opt/nds32le-linux-glibc-v3-upstream/bin/nds32le-linux-" >> ~/.buildman;
  213. RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
  214. RUN /bin/echo -e "\nriscv = riscv64" >> ~/.buildman
  215. RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
  216. RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;