golang.org/x/build@v0.0.0-20240506185731-218518f32b70/env/linux-arm-qemu/Dockerfile (about) 1 # Copyright 2014 The Go Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style 3 # license that can be found in the LICENSE file. 4 5 # Base builder image: gobuilders/linux-arm-qemu 6 7 # Using sid for the cross toolchain. 8 FROM gobuilders/linux-x86-sid 9 MAINTAINER golang-dev <golang-dev@googlegroups.com> 10 11 ENV DEBIAN_FRONTEND noninteractive 12 13 RUN dpkg --add-architecture armhf 14 RUN apt-get update 15 RUN apt-get install -y --no-install-recommends qemu 16 # To build the ARM root. 17 RUN apt-get install -y --no-install-recommends debootstrap 18 # To build 5g & buildlet. 19 RUN apt-get install -y --no-install-recommends gcc git libc6-dev 20 # To build e2fsimage. 21 RUN apt-get install -y --no-install-recommends e2fslibs-dev 22 RUN apt-get install -y linux-source-3.16 xz-utils 23 RUN apt-get install -y gcc-arm-linux-gnueabihf 24 25 RUN mkdir /arm 26 27 # The list of packages in include are copied from linux-x86-std 28 RUN debootstrap --arch=armhf --foreign --include=curl,ca-certificates,strace,gcc,libc6-dev,gdb,lsof,psmisc sid /arm/root 29 30 # Script to finish off the debootstrap installation. 31 ADD stage2 /arm/root/stage2 32 RUN chmod +x /arm/root/stage2 33 34 # Setup networking. 35 RUN (echo "auto lo"; echo "iface lo inet loopback"; echo "auto eth0"; echo "iface eth0 inet dhcp") > /arm/root/etc/network/interfaces 36 37 # Run buildlet at boot. 38 ADD buildlet.service /arm/root/etc/systemd/system/buildlet.service 39 RUN (echo "[Journal]"; echo "ForwardToConsole=yes") > /arm/root/etc/systemd/journald.conf 40 41 # Fetch go1.4 and cross compile buildlet's stage0. 42 RUN mkdir /gopath 43 ENV GOPATH /gopath 44 ENV GOROOT /go1.4 45 ENV PATH $GOROOT/bin:$PATH 46 RUN cd $GOROOT/src && GOARCH=arm GOOS=linux ./make.bash 47 RUN GOARCH=arm GOOS=linux go get golang.org/x/build/cmd/buildlet/stage0 48 RUN mkdir -p /arm/root/usr/local/bin && cp $GOPATH/bin/linux_arm/stage0 /arm/root/usr/local/bin 49 RUN rm -rf /go1.4 /gopath 50 51 # Fetch go1.4.2 for arm 52 RUN curl -O http://dave.cheney.net/paste/go1.4.2.linux-arm~multiarch-armv7-1.tar.gz 53 RUN echo '607573c55dc89d135c3c9c84bba6ba6095a37a1e go1.4.2.linux-arm~multiarch-armv7-1.tar.gz' | sha1sum -c 54 RUN tar xfv go1.4.2.linux-arm~multiarch-armv7-1.tar.gz -C /arm/root/ 55 RUN rm go1.4.2.linux-arm~multiarch-armv7-1.tar.gz 56 RUN mv /arm/root/go /arm/root/go1.4 57 RUN rm -rf /arm/root/go1.4/api /arm/root/go1.4/blog /arm/root/go1.4/doc /arm/root/go1.4/misc /arm/root/go1.4/test 58 RUN find /arm/root/go1.4 -type d -name testdata | xargs rm -rf 59 60 # Install e2fsimage to prepare a root disk without running any 61 # "privileged" docker operations (i.e. mount). 62 # Building from source because there aren't any Debian packages. 63 ENV IMG_SIZE 1000000 # in KB 64 RUN curl -L -O http://sourceforge.net/projects/e2fsimage/files/e2fsimage/0.2.2/e2fsimage-0.2.2.tar.gz 65 RUN echo '8ab6089c6a91043b251afc5c4331d1d740be1469 e2fsimage-0.2.2.tar.gz' | sha1sum -c 66 RUN tar xfv e2fsimage-0.2.2.tar.gz 67 # The configure script is broken. This is all we need anyway. 68 RUN cd e2fsimage-0.2.2/src && \ 69 gcc -o e2fsimage -DVER=\"0.2.2\" main.c copy.c symlink.c util.c mkdir.c dirent.c mke2fs.c inodb.c sfile.c uiddb.c uids.c malloc.c passwd.c group.c -lext2fs -lcom_err 70 RUN /e2fsimage-0.2.2/src/e2fsimage -f /arm/root.img -d /arm/root -s $IMG_SIZE -p 71 RUN rm -rf e2fsimage-0.2.2 e2fsimage-0.2.2.tar.gz 72 RUN rm -rf /arm/root 73 74 # Build a kernel. We're buildng here because we need a recent version for 75 # systemd to boot, and the binary ones in debian's repositories have a lot 76 # of needed components as modules (filesystem/sata drivers). It's just 77 # simpler to build a kernel than it is cross generate an initrd with 78 # the right bits in. 79 RUN tar xfv /usr/src/linux-source-3.16.tar.xz -C /usr/src/ 80 COPY kernel_config /usr/src/linux-source-3.16/.config 81 RUN (cd /usr/src/linux-source-3.16 && \ 82 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make) 83 RUN cp /usr/src/linux-source-3.16/arch/arm/boot/zImage /arm/vmlinuz 84 RUN rm -rf /usr/src/linux-source-3.16 85 86 RUN qemu-system-arm -M vexpress-a9 -cpu cortex-a9 -nographic -no-reboot -sd /arm/root.img -kernel /arm/vmlinuz -append "root=/dev/mmcblk0 console=ttyAMA0 rw rootwait init=/stage2" 87 88 ADD buildlet-qemu /usr/local/bin/buildlet-qemu 89 RUN chmod +x /usr/local/bin/buildlet-qemu 90 ADD qemu.service /etc/systemd/system/qemu.service 91 RUN systemctl enable /etc/systemd/system/qemu.service 92 RUN systemctl disable /etc/systemd/system/buildlet.service 93 94 RUN rm /usr/local/bin/stage0 95 RUN apt-get purge -y gcc git libc6-dev xz-utils gcc-arm-linux-gnueabihf linux-source-3.16 e2fslibs-dev debootstrap strace gdb libc6-dev perl 96 RUN apt-get autoremove -y --purge 97 RUN apt-get clean 98 RUN rm -rf /var/lib/apt/lists /usr/share/doc 99 RUN (cd /usr/share/locale/ && ls -1 | grep -v en | xargs rm -rf) 100 RUN rm -rf /var/cache/debconf/* 101 RUN rm -rf /usr/share/man 102 RUN (cd /usr/bin && ls -1 | grep qemu | grep -v qemu-system-arm | xargs rm)