Leonardo Sandoval | 8022380 | 2021-12-07 13:18:06 -0600 | [diff] [blame] | 1 | # ubuntu-16.04/Dockerfile |
| 2 | # |
| 3 | # Copyright (c) 2018-2021, ARM Limited, All Rights Reserved |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # |
| 18 | # This file is part of Mbed TLS (https://www.trustedfirmware.org/projects/mbed-tls/) |
| 19 | |
| 20 | # Purpose |
| 21 | # ------- |
| 22 | # |
| 23 | # This docker file is for creating the ubuntu-16.04 image that is used in the |
| 24 | # CI. It can also be used for reproducing and testing CI failures. |
| 25 | |
| 26 | FROM ubuntu:16.04 |
| 27 | |
| 28 | ARG DEBIAN_FRONTEND=noninteractive |
| 29 | WORKDIR /opt/src |
| 30 | |
| 31 | # Support for i386: |
| 32 | # - for 32-bit builds+tests of Mbed TLS |
| 33 | # - required to install Arm Compiler 5.06 (armcc) |
| 34 | RUN dpkg --add-architecture i386 |
| 35 | |
| 36 | # Main apt-get call with all packages except those that have conflicts, |
| 37 | # handled below. One big alphabetised list, in order to avoid duplicates, with |
| 38 | # comments explaining why each package is needed. |
| 39 | RUN apt-get update -q && apt-get install -yq \ |
| 40 | # installed from source, but this installs the dependencies |
| 41 | abi-dumper \ |
| 42 | # to build Mbed TLS: gcc, binutils, make, etc. |
| 43 | build-essential \ |
| 44 | # to build Mbed TLS |
| 45 | clang \ |
| 46 | # to build Mbed TLS |
| 47 | cmake \ |
| 48 | # to build Mbed TLS's documentation |
| 49 | doxygen \ |
| 50 | # to cross-build Mbed TLS |
| 51 | gcc-mingw-w64-i686 \ |
| 52 | # to check out Mbed TLS and others |
| 53 | git \ |
| 54 | # to build Mbed TLS's documentation |
| 55 | graphviz \ |
| 56 | # to measure code coverage of Mbed TLS |
| 57 | lcov \ |
| 58 | # for 32-bit Mbed TLS testing and armcc |
| 59 | libc6-i386 \ |
| 60 | # for 32-bit Mbed TLS testing and armcc |
| 61 | libc6:i386 \ |
| 62 | # to build GnuTLS (nettle with public key support aka hogweed) |
| 63 | libgmp-dev \ |
| 64 | # to build GnuTLS >= 3.6 (could also use --with-included-unistring) |
| 65 | libunistring-dev \ |
| 66 | # for armcc |
| 67 | libstdc++6:i386 \ |
| 68 | # to build GnuTLS (except 3.6 which uses --with-included-libtasn1) |
| 69 | libtasn1-6-dev \ |
| 70 | # needed for armcc (see locale-gen below) |
| 71 | locales \ |
Leonardo Sandoval | 71701d4 | 2021-12-17 18:25:34 -0600 | [diff] [blame] | 72 | # needed for basic-build-test.sh |
| 73 | lsb \ |
Leonardo Sandoval | 8022380 | 2021-12-07 13:18:06 -0600 | [diff] [blame] | 74 | # used by compat.sh and ssl-opt.sh |
| 75 | lsof \ |
| 76 | # to build GnuTLS (nettle) |
| 77 | m4 \ |
| 78 | # to build Mbed TLS and others |
| 79 | make \ |
| 80 | # to build GnuTLS with locally-compiled nettle |
| 81 | pkg-config \ |
| 82 | # to install the preferred version of pylint |
| 83 | python3-pip \ |
| 84 | # for Mbed TLS tests |
| 85 | valgrind \ |
| 86 | # to download things installed from other places |
| 87 | wget \ |
| 88 | # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0) |
| 89 | zlib1g \ |
| 90 | # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0) |
| 91 | zlib1g-dev \ |
| 92 | && rm -rf /var/lib/apt/lists/ |
| 93 | |
| 94 | # Install all the parts of gcc-multilib, which is necessary for 32-bit builds. |
| 95 | # gcc-multilib conflicts with cross-compiler packages that we'll install later, |
| 96 | # so don't keep it around. Just let it install its dependencies |
| 97 | # (gcc-<VERSION>-multilib and libc support), then remove it. Manually create |
| 98 | # one crucial symlink that's otherwise provided by the gcc-multilib package |
| 99 | # (without that symlink, 32-bit builds won't find system headers). Note that |
| 100 | # just installing the dependencies of gcc-multilib also brings in gcc-multilib |
| 101 | # as a Recommends dependency. |
| 102 | RUN apt-get update -q && apt-get install -yq \ |
| 103 | gcc-multilib \ |
| 104 | && rm -rf /var/lib/apt/lists/ && \ |
| 105 | dpkg -r gcc-multilib && \ |
| 106 | ln -s x86_64-linux-gnu/asm /usr/include/asm |
| 107 | |
| 108 | # Install arm-linux-gnueabi-gcc - to cross-build Mbed TLS |
| 109 | RUN apt-get update -q && apt-get install -yq \ |
| 110 | gcc-arm-linux-gnueabi \ |
| 111 | libc6-dev-armel-cross \ |
| 112 | && rm -rf /var/lib/apt/lists/ |
| 113 | |
| 114 | # Install ARM Compiler 5.06 |
| 115 | RUN wget -q https://developer.arm.com/-/media/Files/downloads/compiler/DS500-PA-00003-r5p0-22rel0.tgz && \ |
| 116 | tar -zxf DS500-PA-00003-r5p0-22rel0.tgz && \ |
| 117 | ./Installer/setup.sh --i-agree-to-the-contained-eula --no-interactive -d /usr/local/ARM_Compiler_5.06u3 --quiet && \ |
| 118 | rm -rf DS500-PA-00003-r5p0-22rel0.tgz releasenotes.html Installer/ |
| 119 | |
| 120 | ENV ARMC5_BIN_DIR=/usr/local/ARM_Compiler_5.06u3/bin/ |
| 121 | ENV PATH=$PATH:/usr/local/ARM_Compiler_5.06u3/bin |
| 122 | ENV ARMLMD_LICENSE_FILE=27000@flexnet.trustedfirmware.org |
| 123 | |
| 124 | # Install ARM Compiler 6.6 |
| 125 | RUN mkdir temp && cd temp && \ |
| 126 | wget -q --no-check-certificate https://developer.arm.com/-/media/Files/downloads/compiler/DS500-BN-00026-r5p0-07rel0.tgz?revision=8f0d9fb0-9616-458c-b2f5-d0dac83ea93c?product=Downloads,64-bit,,Linux,6.6 -O arm6.tgz && \ |
| 127 | tar -zxf arm6.tgz && ls -ltr && \ |
| 128 | ./install_x86_64.sh --i-agree-to-the-contained-eula --no-interactive -d /usr/local/ARM_Compiler_6.6 --quiet && \ |
| 129 | cd .. && rm -rf temp/ |
| 130 | |
| 131 | ENV ARMC6_BIN_DIR=/usr/local/ARM_Compiler_6.6/bin/ |
| 132 | |
| 133 | # Install arm-none-eabi-gcc |
| 134 | RUN wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 -O gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 && \ |
| 135 | tar -xjf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 -C /opt && \ |
| 136 | rm gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 |
| 137 | |
| 138 | ENV PATH=/opt/gcc-arm-none-eabi-5_4-2016q3/bin:$PATH |
| 139 | |
| 140 | # Install exact upstream versions of OpenSSL and GnuTLS |
| 141 | # |
| 142 | # Distro packages tend to include patches that disrupt our testing scripts, |
| 143 | # and such patches may be added at any time. Avoid surprises by using fixed |
| 144 | # versions. |
| 145 | # |
| 146 | # GnuTLS has a number of (optional) dependencies: |
| 147 | # - nettle (crypto library): quite tighly coupled, so build one for each |
| 148 | # version of GnuTLS that we want. |
| 149 | # - libtasn1: can use the Ubuntu version, except for GnuTLS 3.7 which needs |
| 150 | # libtasn1 4.9 (Ubuntu 16.04 has 4.6); an config option |
| 151 | # --with-included-libtasn1 is available, so use it for GnuTLS 3.7. |
| 152 | # - p11-kit: optional, for smart-card support - configure it out |
| 153 | # - libunistring: since 3.6 - the Ubuntu package works; if it didn't a config |
| 154 | # option --with-included-libunistring is available. |
| 155 | |
| 156 | # Install openssl 1.0.2g - main version, in the PATH |
| 157 | RUN wget -q https://www.openssl.org/source/old/1.0.2/openssl-1.0.2g.tar.gz && \ |
| 158 | tar -zxf openssl-1.0.2g.tar.gz && cd openssl-1.0.2g && \ |
| 159 | ./config --openssldir=/usr/local/openssl-1.0.2g enable-ssl-trace && \ |
| 160 | make clean && make && make install && cd .. && \ |
| 161 | rm -rf openssl-1.0.2g* |
| 162 | |
| 163 | ENV OPENSSL=/usr/local/openssl-1.0.2g/bin/openssl |
| 164 | ENV PATH=/usr/local/openssl-1.0.2g/bin:$PATH |
| 165 | |
| 166 | # Install openssl 1.0.1j - "legacy" version |
| 167 | RUN wget -q https://www.openssl.org/source/old/1.0.1/openssl-1.0.1j.tar.gz && \ |
| 168 | tar -zxf openssl-1.0.1j.tar.gz && cd openssl-1.0.1j && \ |
| 169 | ./config --openssldir=/usr/local/openssl-1.0.1j && \ |
| 170 | make clean && make && make install && cd .. && \ |
| 171 | rm -rf openssl-1.0.1j* |
| 172 | |
| 173 | ENV OPENSSL_LEGACY=/usr/local/openssl-1.0.1j/bin/openssl |
| 174 | |
| 175 | # Install openssl 1.1.1a - "next" version |
| 176 | RUN wget -q https://www.openssl.org/source/openssl-1.1.1a.tar.gz && \ |
| 177 | tar -zxf openssl-1.1.1a.tar.gz && cd openssl-1.1.1a && \ |
| 178 | ./config --prefix=/usr/local/openssl-1.1.1a -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' enable-ssl-trace && \ |
| 179 | make clean && make && make install && cd .. && \ |
| 180 | rm -rf openssl-1.1.1a* |
| 181 | |
| 182 | ENV OPENSSL_NEXT=/usr/local/openssl-1.1.1a/bin/openssl |
| 183 | |
| 184 | # Install Gnu TLS 3.4.10 (nettle 3.1) - main version, in the PATH |
| 185 | RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-3.1.tar.gz && \ |
| 186 | tar -zxf nettle-3.1.tar.gz && cd nettle-3.1 && \ |
| 187 | ./configure --prefix=/usr/local/libnettle-3.1 --exec_prefix=/usr/local/libnettle-3.1 --disable-shared --disable-openssl && \ |
| 188 | make && make install && cd .. && rm -rf nettle-3.1* && \ |
| 189 | export PKG_CONFIG_PATH=/usr/local/libnettle-3.1/lib/pkgconfig:/usr/local/libnettle-3.1/lib64/pkgconfig:/usr/local/lib/pkgconfig && \ |
| 190 | wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.4/gnutls-3.4.10.tar.xz && \ |
| 191 | tar -xJf gnutls-3.4.10.tar.xz && cd gnutls-3.4.10 && \ |
| 192 | ./configure --prefix=/usr/local/gnutls-3.4.10 --exec_prefix=/usr/local/gnutls-3.4.10 --disable-shared --without-p11-kit && \ |
| 193 | make && make install && cat config.log && cd .. && \ |
| 194 | rm -rf gnutls-3.4.10* |
| 195 | |
| 196 | ENV GNUTLS_CLI=/usr/local/gnutls-3.4.10/bin/gnutls-cli |
| 197 | ENV GNUTLS_SERV=/usr/local/gnutls-3.4.10/bin/gnutls-serv |
| 198 | ENV PATH=/usr/local/gnutls-3.4.10/bin:$PATH |
| 199 | |
| 200 | # Install Gnu TLS 3.3.8 (nettle 2.7) - "legacy" version |
| 201 | RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz && \ |
| 202 | tar -zxf nettle-2.7.1.tar.gz && cd nettle-2.7.1 && \ |
| 203 | ./configure --prefix=/usr/local/libnettle-2.7.1 --exec_prefix=/usr/local/libnettle-2.7.1 --disable-shared --disable-openssl && \ |
| 204 | make && make install && cd .. && rm -rf nettle-2.7.1* && \ |
| 205 | export PKG_CONFIG_PATH=/usr/local/libnettle-2.7.1/lib/pkgconfig:/usr/local/libnettle-2.7.1/lib64/pkgconfig:/usr/local/lib/pkgconfig && \ |
| 206 | wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.3/gnutls-3.3.8.tar.xz && \ |
| 207 | tar -xJf gnutls-3.3.8.tar.xz && cd gnutls-3.3.8 && \ |
| 208 | ./configure --prefix=/usr/local/gnutls-3.3.8 --exec_prefix=/usr/local/gnutls-3.3.8 --disable-shared --without-p11-kit && \ |
| 209 | make && make install && cat config.log && cd .. && \ |
| 210 | rm -rf gnutls-3.3.8* |
| 211 | |
| 212 | ENV GNUTLS_LEGACY_CLI=/usr/local/gnutls-3.3.8/bin/gnutls-cli |
| 213 | ENV GNUTLS_LEGACY_SERV=/usr/local/gnutls-3.3.8/bin/gnutls-serv |
| 214 | |
| 215 | # Instal GNU TLS 3.7.2 (nettle 3.7) - "next" version |
| 216 | RUN wget -q https://ftp.gnu.org/gnu/nettle/nettle-3.7.3.tar.gz && \ |
| 217 | tar -zxf nettle-3.7.3.tar.gz && cd nettle-3.7.3 && \ |
| 218 | ./configure --prefix=/usr/local/libnettle-3.7.3 --exec_prefix=/usr/local/libnettle-3.7.3 --disable-shared --disable-openssl && \ |
| 219 | make && make install && cd .. && rm -rf nettle-3.7.3* && \ |
| 220 | export PKG_CONFIG_PATH=/usr/local/libnettle-3.7.3/lib/pkgconfig:/usr/local/libnettle-3.7.3/lib64/pkgconfig:/usr/local/lib/pkgconfig && \ |
| 221 | wget -q https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/gnutls-3.7.2.tar.xz && \ |
| 222 | tar -xJf gnutls-3.7.2.tar.xz && cd gnutls-3.7.2 && \ |
| 223 | ./configure --prefix=/usr/local/gnutls-3.7.2 --exec_prefix=/usr/local/gnutls-3.7.2 --disable-shared --with-included-libtasn1 --without-p11-kit && \ |
| 224 | make && make install && cat config.log && cd .. && \ |
| 225 | rm -rf gnutls-3.7.2* |
| 226 | |
| 227 | ENV GNUTLS_NEXT_CLI=/usr/local/gnutls-3.7.2/bin/gnutls-cli |
| 228 | ENV GNUTLS_NEXT_SERV=/usr/local/gnutls-3.7.2/bin/gnutls-serv |
| 229 | |
| 230 | # Install abi-compliance-checker |
| 231 | # The version in Ubuntu 16.04 is too old, we want at least the version below |
| 232 | RUN wget -q https://github.com/lvc/abi-compliance-checker/archive/2.3.tar.gz && \ |
| 233 | tar -zxf 2.3.tar.gz && cd abi-compliance-checker-2.3 && \ |
| 234 | make clean && make && make install prefix=/usr && cd .. && \ |
| 235 | rm -rf abi-compliance-checker* && rm 2.3.tar.gz |
| 236 | |
| 237 | # Install abi-dumper |
| 238 | # The version in Ubuntu 16.04 is too old, we want at least the version below |
| 239 | RUN git clone --branch 1.1 https://github.com/lvc/abi-dumper.git && \ |
| 240 | cd abi-dumper && make install prefix=/usr && cd .. && rm -rf abi-dumper |
| 241 | |
| 242 | # Install Python pip packages |
| 243 | # |
| 244 | # The pip wrapper scripts can get out of sync with pip due to upgrading it |
| 245 | # outside the package manager, so invoke the module directly. |
| 246 | # |
| 247 | # Ubuntu 16.04's pip (8.1) doesn't understand the Requires-Python |
| 248 | # directive (introduced in pip 9.0), and tries to install the wrong versions |
| 249 | # of pip and setuptools. Version 21 of pip drops support for Python 3.5 (the |
| 250 | # latest in 16.04), so pick an earlier version. |
| 251 | # |
| 252 | # Piping to cat suppresses the progress bar, but means that a failure |
| 253 | # won't be caught (`stuff | cat` succeeds if cat succeeds, even if `stuff` |
| 254 | # fails). The subsequent use of "pip config" (which requires pip >=10) |
| 255 | # will however fail if the installation of a more recent pip failed. |
| 256 | RUN python3 -m pip install 'pip<21' --upgrade | cat && \ |
| 257 | python3 -m pip config set global.progress_bar off && \ |
| 258 | python3 -m pip install setuptools --upgrade && \ |
| 259 | # For pylint we want a known version, as later versions may add checks at |
| 260 | # any time, making CI results unpredictable. |
| 261 | python3 -m pip install pylint==2.4.4 && \ |
| 262 | # For mypy, use the earliest version that works with our code base. |
| 263 | # See https://github.com/ARMmbed/mbedtls/pull/3953 . |
| 264 | python3 -m pip install mypy==0.780 && \ |
| 265 | # For jinja2, use the version that's in Ubuntu 20.04. |
| 266 | # See https://github.com/ARMmbed/mbedtls/pull/5067#discussion_r738794607 . |
| 267 | # Note that Jinja2 3.0 drops support for Python 3.5, so we need 2.x. |
| 268 | python3 -m pip install Jinja2==2.10.1 types-Jinja2 && \ |
| 269 | true |
| 270 | |
| 271 | # Set locale for ARMCC to work |
| 272 | RUN locale && \ |
| 273 | locale-gen "en_US.UTF-8" && \ |
| 274 | dpkg-reconfigure locales |
| 275 | |
| 276 | # Add user |
| 277 | RUN useradd -m user |
| 278 | |
| 279 | # Create workspace |
| 280 | ARG AGENT_WORKDIR=/var/lib/builds |
| 281 | RUN mkdir -p ${AGENT_WORKDIR} && chown user:user ${AGENT_WORKDIR} |
| 282 | USER user |
| 283 | ENV AGENT_WORKDIR=${AGENT_WORKDIR} |
| 284 | |
| 285 | WORKDIR ${AGENT_WORKDIR} |
| 286 | |
| 287 | ENTRYPOINT ["bash"] |