13
13
# See the License for the specific language governing permissions and
14
14
# limitations under the License.
15
15
16
- # Latest Ubuntu LTS
16
+ # If you are building for a foreign target and you get segfaults, try the latest version of qemu
17
+ # $ docker pull tonistiigi/binfmt:latest
18
+ # $ docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-*
19
+ # $ docker run --privileged --rm tonistiigi/binfmt --install arm64
20
+
17
21
FROM ubuntu:22.04
18
22
ENV DEBIAN_FRONTEND noninteractive
19
23
20
- RUN apt-get update && apt-get upgrade -y && apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2
24
+ # These are automatically provided by docker (no need for --build-arg)
25
+ ARG TARGETPLATFORM
26
+ ARG TARGETARCH
27
+
28
+ RUN apt-get update && apt-get upgrade -y && apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2 xz-utils
21
29
22
30
# for clang-*-15, see https://apt.llvm.org/
23
31
RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
24
32
echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \
25
33
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
26
34
27
35
# Install gcc8-arm-none-eabi
28
- RUN mkdir ~/Downloads &&\
29
- cd ~/Downloads &&\
30
- wget -O gcc.tar.bz2 https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2?revision=d830f9dd-cd4f-406d-8672-cca9210dd220?product=GNU%20Arm%20Embedded%20Toolchain,64-bit,,Linux,8-2018-q4-major &&\
31
- echo "fb31fbdfe08406ece43eef5df623c0b2deb8b53e405e2c878300f7a1f303ee52 gcc.tar.bz2" | sha256sum -c &&\
32
- cd ~/Downloads &&\
33
- tar -xjvf gcc.tar.bz2 &&\
34
- rm -f gcc.tar.bz2 &&\
35
- cd ~/Downloads && rsync -a gcc-arm-none-eabi-8-2018-q4-major/ /usr/local/
36
+ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
37
+ GNU_TOOLCHAIN=https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-aarch64-arm-none-eabi.tar.xz \
38
+ GNU_TOOLCHAIN_HASH=c8824bffd057afce2259f7618254e840715f33523a3d4e4294f471208f976764 \
39
+ GNU_TOOLCHAIN_FORMAT=xz; \
40
+ else \
41
+ GNU_TOOLCHAIN=https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2 \
42
+ GNU_TOOLCHAIN_HASH=fb31fbdfe08406ece43eef5df623c0b2deb8b53e405e2c878300f7a1f303ee52 \
43
+ GNU_TOOLCHAIN_FORMAT=bz2; \
44
+ fi; \
45
+ wget -O gcc.tar.${GNU_TOOLCHAIN_FORMAT} ${GNU_TOOLCHAIN} &&\
46
+ echo "$GNU_TOOLCHAIN_HASH gcc.tar.${GNU_TOOLCHAIN_FORMAT}" | sha256sum -c &&\
47
+ tar -xvf gcc.tar.${GNU_TOOLCHAIN_FORMAT} -C /usr/local --strip-components=1 &&\
48
+ rm -f gcc.tar.${GNU_TOOLCHAIN_FORMAT}
36
49
37
50
# Tools for building
38
51
RUN apt-get update && apt-get install -y \
39
- build-essential \
52
+ make \
40
53
llvm-18 \
41
54
gcc-10 \
42
55
binutils \
@@ -49,9 +62,6 @@ RUN apt-get update && apt-get install -y \
49
62
libtool \
50
63
pkg-config \
51
64
libcmocka-dev \
52
- libc6-i386 \
53
- lib32stdc++6 \
54
- lib32z1 \
55
65
libusb-1.0-0-dev \
56
66
libudev-dev \
57
67
libhidapi-dev
@@ -96,9 +106,15 @@ RUN python3 -m pip install --upgrade \
96
106
twine==1.15.0
97
107
98
108
# Install protoc from release, because the version available on the repo is too old
99
- RUN mkdir -p /opt/protoc && \
100
- curl -L0 https://github.com/protocolbuffers/protobuf/releases/download/v21.2/protoc-21.2-linux-x86_64.zip -o /tmp/protoc-21.2-linux-x86_64.zip && \
101
- unzip /tmp/protoc-21.2-linux-x86_64.zip -d /opt/protoc
109
+ RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
110
+ PROTOC_URL=https://github.com/protocolbuffers/protobuf/releases/download/v21.2/protoc-21.2-linux-aarch_64.zip; \
111
+ else \
112
+ PROTOC_URL=https://github.com/protocolbuffers/protobuf/releases/download/v21.2/protoc-21.2-linux-x86_64.zip; \
113
+ fi; \
114
+ mkdir -p /opt/protoc && \
115
+ curl -L0 ${PROTOC_URL} -o /tmp/protoc-21.2.zip && \
116
+ unzip /tmp/protoc-21.2.zip -d /opt/protoc && \
117
+ rm /tmp/protoc-21.2.zip
102
118
ENV PATH /opt/protoc/bin:$PATH
103
119
104
120
# Make Python3 the default
@@ -115,7 +131,7 @@ ENV GOPATH /opt/go
115
131
ENV GOROOT /opt/go_dist/go
116
132
ENV PATH $GOROOT/bin:$GOPATH/bin:$PATH
117
133
RUN mkdir -p /opt/go_dist && \
118
- curl https://dl.google.com/go/go1.19.3.linux-amd64 .tar.gz | tar -xz -C /opt/go_dist
134
+ curl https://dl.google.com/go/go1.19.3.linux-${TARGETARCH} .tar.gz | tar -xz -C /opt/go_dist
119
135
120
136
# Install lcov from release (the one from the repos is too old).
121
137
RUN cd /opt && wget https://github.com/linux-test-project/lcov/releases/download/v1.14/lcov-1.14.tar.gz && tar -xf lcov-1.14.tar.gz
0 commit comments