1#
2# Arm SCP/MCP Software
3# Copyright (c) 2021-2023, Arm Limited and Contributors. All rights reserved.
4#
5# SPDX-License-Identifier: BSD-3-Clause
6#
7
8FROM ubuntu:20.04@sha256:9fa30fcef427e5e88c76bc41ad37b7cc573e1d79cecb23035e413c4be6e476ab as ci
9
10ARG ARM_GNU_RM_URL="https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2"
11ARG DOXYGEN_URL="https://sourceforge.net/projects/doxygen/files/rel-1.8.20/doxygen-1.8.20.linux.bin.tar.gz"
12ARG CMAKE_URL="https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.tar.gz"
13ARG AARCH64_GCC_URL="https://developer.arm.com/-/media/Files/downloads/gnu-a/10.2-2020.11/binrel/gcc-arm-10.2-2020.11-x86_64-aarch64-none-elf.tar.xz"
14ARG CPPCHECK_SRC_URL="https://github.com/danmar/cppcheck.git"
15ARG CPPCHECK_CHECKOUT_TAG="1.90"
16ARG IWYU_SRC_URL="https://github.com/include-what-you-use/include-what-you-use.git"
17
18ENV ARMLMD_LICENSE_FILE=
19
20ENV DEBIAN_FRONTEND=noninteractive
21
22RUN apt-get update && \
23    apt-get dist-upgrade -y && \
24    apt-get update && \
25    apt-get install -y --no-install-recommends \
26        bundler gcc g++ gpg-agent git gosu lsb-release make ninja-build \
27        xz-utils python3 python3-pip software-properties-common wget lcov && \
28    apt-get update && \
29    python3 -m pip install --upgrade pip && \
30    gem install bundler
31
32ENV DEBIAN_FRONTEND=
33
34RUN mkdir "/opt/arm-gnu-rm" && \
35    wget -nv -O - -c "${ARM_GNU_RM_URL}" | \
36    tar -jxf - -C "/opt/arm-gnu-rm" --strip-components=1 && \
37    echo 'export PATH=/opt/arm-gnu-rm/bin:${PATH}' >> \
38        "/etc/profile.d/50-scp-firmware-env.sh"
39
40ENV PATH="/opt/arm-gnu-rm/bin:${PATH}"
41
42VOLUME "/opt/arm-compiler-6"
43ENV PATH="/opt/arm-compiler-6/bin:${PATH}"
44
45RUN mkdir "/opt/doxygen" && \
46    apt-get update && \
47    apt-get install -y --no-install-recommends \
48        libclang1-9 libclang-9-dev libclang-cpp9 && \
49    wget -nv -O - -c "${DOXYGEN_URL}" | \
50    tar -zxf - -C "/opt/doxygen" --strip-components=1 && \
51    echo 'export PATH=/opt/doxygen/bin:${PATH}' >> \
52        "/etc/profile.d/50-scp-firmware-env.sh"
53
54ENV PATH="/opt/doxygen/bin:${PATH}"
55
56RUN mkdir "/opt/cmake" && \
57    wget -nv -O - -c "${CMAKE_URL}" | \
58    tar -zxf - -C "/opt/cmake" --strip-components=1 && \
59    echo 'export PATH=/opt/cmake/bin:${PATH}' >> \
60        "/etc/profile.d/50-scp-firmware-env.sh"
61
62ENV PATH="/opt/cmake/bin:${PATH}"
63
64RUN apt-get update && \
65    wget --no-check-certificate -O - \
66        https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
67    add-apt-repository \
68        'deb http://apt.llvm.org/focal/   llvm-toolchain-focal-13  main' && \
69    apt-get update && \
70    apt-get install -y --no-install-recommends \
71        clang-tidy-13 clang-13 llvm-13 libclang-13-dev llvm-13-dev
72
73COPY rootfs/usr/local/bin/prepare_llvm /usr/local/bin/prepare_llvm
74RUN  chmod 755 "/usr/local/bin/prepare_llvm"
75RUN  prepare_llvm
76
77RUN mkdir "/opt/aarch64-gcc" && \
78    wget -nv -O - -c "${AARCH64_GCC_URL}" | \
79    tar -Jxf - -C "/opt/aarch64-gcc" --strip-components=1 && \
80    echo 'export PATH=/opt/aarch64-gcc/bin:${PATH}' >> \
81        "/etc/profile.d/50-scp-firmware-env.sh"
82
83ENV PATH="/opt/aarch64-gcc/bin:${PATH}"
84
85RUN cwd=$PWD && mkdir "/opt/cppcheck" && cd "/opt/cppcheck" && \
86    git clone --depth 1 --branch "${CPPCHECK_CHECKOUT_TAG}" \
87    "${CPPCHECK_SRC_URL}" source && \
88    cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=/opt/cppcheck \
89        -DFILESDIR=/opt/cppcheck ./source && \
90    cmake --build . -- install && cd $cwd && \
91    echo 'export PATH=/opt/cppcheck/bin:${PATH}' >> \
92        "/etc/profile.d/50-scp-firmware-env.sh"
93
94ENV PATH="/opt/cppcheck/bin:${PATH}"
95
96RUN cwd=$PWD && mkdir "/opt/iwyu" && cd "/opt/iwyu" && \
97    git clone "${IWYU_SRC_URL}" -b clang_13 --single-branch iwyu-13 && \
98    cmake -G "Ninja" -DCMAKE_PREFIX_PATH=/usr/lib/llvm-13g \
99    ./iwyu-13 && cmake --build . && \
100    cd bin && ln -s include-what-you-use iwyu && cd $cwd && \
101    echo 'export PATH=/opt/iwyu/bin:${PATH}' >> \
102        "/etc/profile.d/50-scp-firmware-env.sh"
103
104ENV PATH="/opt/iwyu/bin:${PATH}"
105
106COPY rootfs/usr/local/bin/init /usr/local/bin/init
107RUN  chmod 755 "/usr/local/bin/init"
108
109COPY rootfs/usr/local/bin/dependencies /usr/local/bin/dependencies
110RUN  chmod 755 "/usr/local/bin/dependencies"
111
112ENTRYPOINT [ "sh", "/usr/local/bin/dependencies", "/usr/local/bin/init" ]
113
114FROM ci as jenkins
115
116ARG JENKINS_UID=1000
117ARG JENKINS_GID=1000
118
119RUN addgroup --gid "${JENKINS_GID}" jenkins && \
120    adduser --uid "${JENKINS_UID}" --gid "${JENKINS_GID}" --disabled-password \
121        --gecos "" jenkins
122
123ENTRYPOINT [ "sh", "-c" ]
124
125FROM ci as dev
126
127VOLUME /scp-firmware
128WORKDIR /scp-firmware
129
130ENV DEBIAN_FRONTEND=noninteractive
131
132RUN apt-get update && \
133    apt-get dist-upgrade -y && \
134    apt-get install -y --no-install-recommends nano sudo
135
136ENV DEBIAN_FRONTEND=
137
138RUN adduser --disabled-password --gecos "" user && \
139    usermod -aG sudo user && \
140    passwd -d user
141
142ENV NOTVISIBLE="in users profile"
143RUN echo "export VISIBLE=now" >> "/etc/profile"
144
145RUN echo "\nexport USER=user" >> "/home/user/.bashrc"
146RUN echo "\n/usr/local/bin/dependencies" >> "/home/user/.bashrc"
147ENV PATH="/home/user/.local/bin:${PATH}"
148
149ENTRYPOINT [ "sh", "/usr/local/bin/init" ]
150
151FROM dev as vagrant
152
153VOLUME /vagrant
154WORKDIR /vagrant
155
156ENV DEBIAN_FRONTEND=noninteractive
157
158RUN apt-get update && \
159    apt-get dist-upgrade -y && \
160    apt-get install -y --no-install-recommends openssh-server && \
161    mkdir "/run/sshd"
162
163ENV DEBIAN_FRONTEND=
164
165RUN adduser --disabled-password --gecos "" vagrant && \
166    usermod -aG sudo vagrant && \
167    passwd -d vagrant
168
169ENV NOTVISIBLE="in users profile"
170RUN echo "export VISIBLE=now" >> "/etc/profile"
171
172RUN printf "\nAcceptEnv ARMLMD_LICENSE_FILE" >> /etc/ssh/sshd_config
173
174RUN mkdir -p "/home/vagrant/.ssh" && \
175    chmod 755 "/home/vagrant/.ssh"
176
177COPY rootfs/home/vagrant/.ssh/authorized_keys /home/vagrant/.ssh/authorized_keys
178RUN  chmod 644 "/home/vagrant/.ssh/authorized_keys"
179
180RUN printf "\ncd /vagrant" >> "/home/vagrant/.bashrc"
181
182RUN echo "\nexport USER=vagrant" >> "/home/user/.bashrc"
183RUN echo "\n/usr/local/bin/dependencies" >> "/home/vagrant/.bashrc"
184ENV PATH="/home/vagrant/.local/bin:${PATH}"
185
186EXPOSE 22
187