Dockerfile 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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:jammy-20230624
  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/jammy/ llvm-toolchain-jammy-16 main | tee /etc/apt/sources.list.d/llvm.list
  13. # Manually install the kernel.org "Crosstool" based toolchains for gcc-13.1.0
  14. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.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/13.1.0/x86_64-gcc-13.1.0-nolibc-arc-linux.tar.xz | tar -C /opt -xJ
  16. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-arm-linux-gnueabi.tar.xz | tar -C /opt -xJ
  17. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-i386-linux.tar.xz | tar -C /opt -xJ
  18. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-m68k-linux.tar.xz | tar -C /opt -xJ
  19. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-mips-linux.tar.xz | tar -C /opt -xJ
  20. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-microblaze-linux.tar.xz | tar -C /opt -xJ
  21. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-nios2-linux.tar.xz | tar -C /opt -xJ
  22. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-powerpc-linux.tar.xz | tar -C /opt -xJ
  23. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-riscv64-linux.tar.xz | tar -C /opt -xJ
  24. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-riscv32-linux.tar.xz | tar -C /opt -xJ
  25. RUN wget -O - https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/13.1.0/x86_64-gcc-13.1.0-nolibc-sh2-linux.tar.xz | tar -C /opt -xJ
  26. # Manually install other toolchains
  27. 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
  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-16 \
  37. coreutils \
  38. cpio \
  39. cppcheck \
  40. curl \
  41. device-tree-compiler \
  42. dosfstools \
  43. e2fsprogs \
  44. efitools \
  45. erofs-utils \
  46. expect \
  47. fakeroot \
  48. flex \
  49. gawk \
  50. gdisk \
  51. git \
  52. gnu-efi \
  53. gnutls-dev \
  54. graphviz \
  55. grub-efi-amd64-bin \
  56. grub-efi-ia32-bin \
  57. help2man \
  58. iasl \
  59. imagemagick \
  60. iputils-ping \
  61. libc6-i386 \
  62. libconfuse-dev \
  63. libgit2-dev \
  64. libjson-glib-dev \
  65. libguestfs-tools \
  66. libgnutls28-dev \
  67. libgnutls30 \
  68. liblz4-tool \
  69. libpixman-1-dev \
  70. libpython3-dev \
  71. libsdl1.2-dev \
  72. libsdl2-dev \
  73. libseccomp-dev \
  74. libslirp-dev \
  75. libssl-dev \
  76. libtool \
  77. libudev-dev \
  78. libusb-1.0-0-dev \
  79. linux-image-kvm \
  80. lzma-alone \
  81. lzop \
  82. mount \
  83. mtd-utils \
  84. mtools \
  85. net-tools \
  86. ninja-build \
  87. openssl \
  88. picocom \
  89. parted \
  90. pkg-config \
  91. python-is-python3 \
  92. python2.7 \
  93. python3 \
  94. python3-dev \
  95. python3-pip \
  96. python3-pyelftools \
  97. python3-sphinx \
  98. python3-virtualenv \
  99. rpm2cpio \
  100. sbsigntool \
  101. sloccount \
  102. socat \
  103. softhsm2 \
  104. sparse \
  105. srecord \
  106. sudo \
  107. swig \
  108. texinfo \
  109. util-linux \
  110. uuid-dev \
  111. virtualenv \
  112. xxd \
  113. zip \
  114. && rm -rf /var/lib/apt/lists/*
  115. # Make kernels readable for libguestfs tools to work correctly
  116. RUN chmod +r /boot/vmlinu*
  117. # Build GRUB UEFI targets for ARM & RISC-V, 32-bit and 64-bit
  118. RUN git clone git://git.savannah.gnu.org/grub.git /tmp/grub && \
  119. cd /tmp/grub && \
  120. git checkout grub-2.06 && \
  121. git config --global user.name "GitLab CI Runner" && \
  122. git config --global user.email trini@konsulko.com && \
  123. git cherry-pick 049efdd72eb7baa7b2bf8884391ee7fe650da5a0 && \
  124. git cherry-pick 403d6540cd608b2706cfa0cb4713f7e4b490ff45 && \
  125. ./bootstrap && \
  126. mkdir -p /opt/grub && \
  127. ./configure --target=aarch64 --with-platform=efi \
  128. CC=gcc \
  129. TARGET_CC=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-gcc \
  130. TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-objcopy \
  131. TARGET_STRIP=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-strip \
  132. TARGET_NM=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-nm \
  133. TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/aarch64-linux/bin/aarch64-linux-ranlib && \
  134. make && \
  135. ./grub-mkimage -O arm64-efi -o /opt/grub/grubaa64.efi --prefix= -d \
  136. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  137. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  138. search search_fs_file search_fs_uuid search_label serial sleep test \
  139. true && \
  140. make clean && \
  141. ./configure --target=arm --with-platform=efi \
  142. CC=gcc \
  143. TARGET_CC=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
  144. TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-objcopy \
  145. TARGET_STRIP=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-strip \
  146. TARGET_NM=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-nm \
  147. TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib && \
  148. make && \
  149. ./grub-mkimage -O arm-efi -o /opt/grub/grubarm.efi --prefix= -d \
  150. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  151. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  152. search search_fs_file search_fs_uuid search_label serial sleep test \
  153. true && \
  154. make clean && \
  155. ./configure --target=riscv64 --with-platform=efi \
  156. CC=gcc \
  157. TARGET_CC=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-gcc \
  158. TARGET_OBJCOPY=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-objcopy \
  159. TARGET_STRIP=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-strip \
  160. TARGET_NM=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-nm \
  161. TARGET_RANLIB=/opt/gcc-13.1.0-nolibc/riscv64-linux/bin/riscv64-linux-ranlib && \
  162. make && \
  163. ./grub-mkimage -O riscv64-efi -o /opt/grub/grubriscv64.efi --prefix= -d \
  164. grub-core cat chain configfile echo efinet ext2 fat halt help linux \
  165. lsefisystab loadenv lvm minicmd normal part_msdos part_gpt reboot \
  166. search search_fs_file search_fs_uuid search_label serial sleep test \
  167. true && \
  168. rm -rf /tmp/grub
  169. RUN git clone https://gitlab.com/qemu-project/qemu.git /tmp/qemu && \
  170. cd /tmp/qemu && \
  171. git checkout v8.0.3 && \
  172. # config user.name and user.email to make 'git am' happy
  173. git config user.name u-boot && \
  174. git config user.email u-boot@denx.de && \
  175. ./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" && \
  176. make -j$(nproc) all install && \
  177. rm -rf /tmp/qemu
  178. # Build genimage (required by some targets to generate disk images)
  179. RUN wget -O - https://github.com/pengutronix/genimage/releases/download/v14/genimage-14.tar.xz | tar -C /tmp -xJ && \
  180. cd /tmp/genimage-14 && \
  181. ./configure && \
  182. make -j$(nproc) && \
  183. make install && \
  184. rm -rf /tmp/genimage-14
  185. # Build libtpms
  186. RUN git clone https://github.com/stefanberger/libtpms /tmp/libtpms && \
  187. cd /tmp/libtpms && \
  188. ./autogen.sh && \
  189. ./configure && \
  190. make -j$(nproc) && \
  191. make install && \
  192. ldconfig && \
  193. rm -rf /tmp/libtpms
  194. # Build swtpm
  195. RUN git clone https://github.com/stefanberger/swtpm /tmp/swtpm && \
  196. cd /tmp/swtpm && \
  197. ./autogen.sh && \
  198. ./configure && \
  199. make -j$(nproc) && \
  200. make install && \
  201. rm -rf /tmp/swtpm
  202. # Build trace-cmd
  203. RUN mkdir /tmp/trace && \
  204. git clone https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git /tmp/trace/libtraceevent && \
  205. cd /tmp/trace/libtraceevent && \
  206. make -j$(nproc) && \
  207. sudo make install && \
  208. git clone https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git /tmp/trace/libtracefs && \
  209. cd /tmp/trace/libtracefs && \
  210. make -j$(nproc) && \
  211. sudo make install && \
  212. git clone https://github.com/rostedt/trace-cmd.git /tmp/trace/trace-cmd && \
  213. cd /tmp/trace/trace-cmd && \
  214. make -j$(nproc) && \
  215. sudo make install && \
  216. rm -rf /tmp/trace
  217. # Create our user/group
  218. RUN echo uboot ALL=NOPASSWD: ALL > /etc/sudoers.d/uboot
  219. RUN useradd -m -U uboot
  220. USER uboot:uboot
  221. # Populate the cache for pip to use. Get these via wget as the
  222. # COPY / ADD directives don't work as we need them to.
  223. RUN wget -O /tmp/pytest-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/test/py/requirements.txt
  224. RUN wget -O /tmp/sphinx-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/doc/sphinx/requirements.txt
  225. RUN virtualenv -p /usr/bin/python3 /tmp/venv && \
  226. . /tmp/venv/bin/activate && \
  227. pip install -r /tmp/pytest-requirements.txt \
  228. -r /tmp/sphinx-requirements.txt && \
  229. deactivate && \
  230. rm -rf /tmp/venv /tmp/pytest-requirements.txt /tmp/sphinx-requirements.txt
  231. # Create the buildman config file
  232. RUN /bin/echo -e "[toolchain]\nroot = /usr" > ~/.buildman
  233. RUN /bin/echo -e "kernelorg = /opt/gcc-13.1.0-nolibc/*" >> ~/.buildman
  234. RUN /bin/echo -e "\n[toolchain-prefix]\nxtensa = /opt/2020.07/xtensa-dc233c-elf/bin/xtensa-dc233c-elf-" >> ~/.buildman;
  235. RUN /bin/echo -e "\n[toolchain-alias]\nsh = sh2" >> ~/.buildman
  236. RUN /bin/echo -e "\nsandbox = x86_64" >> ~/.buildman
  237. RUN /bin/echo -e "\nx86 = i386" >> ~/.buildman;
  238. # Add mkbootimg tool
  239. RUN git clone https://android.googlesource.com/platform/system/tools/mkbootimg /home/uboot/mkbootimg
  240. ENV PYTHONPATH "${PYTHONPATH}:/home/uboot/mkbootimg"