blob: 12e90fc3766d58adc5253d70d4b71ac1482a7f63 [file] [log] [blame]
Andrew Geisslerb3175012019-09-01 20:51:14 -05001#!/usr/bin/env bash
Matthew Barthb4aea672016-11-10 14:59:52 -06002#
3# Build the required docker image to run package unit tests
4#
Andrew Geisslerd79407e2018-11-12 15:26:57 -06005# Script Variables:
6# DOCKER_IMG_NAME: <optional, the name of the docker image to generate>
7# default is openbmc/ubuntu-unit-test
8# DISTRO: <optional, the distro to build a docker image against>
William A. Kennington III0232a252019-06-26 12:13:47 -07009# default is ubuntu:eoan
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060010# BRANCH: <optional, branch to build from each of the openbmc/
George Keishing11a6e9e2019-07-22 08:18:40 -050011# repositories>
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060012# default is master, which will be used if input branch not
13# provided or not found
Lei YU139929a2020-05-26 18:48:05 +080014# UBUNTU_MIRROR: <optional, the URL of a mirror of Ubuntu to override the
15# default ones in /etc/apt/sources.list>
16# default is empty, and no mirror is used.
Lei YUb8509772020-12-29 13:46:57 +080017# http_proxy The HTTP address of the proxy server to connect to.
18# Default: "", proxy is not setup if this is not set
Matthew Barthb4aea672016-11-10 14:59:52 -060019
Andrew Geisslerb3175012019-09-01 20:51:14 -050020set -xeuo pipefail
Matthew Barthb4aea672016-11-10 14:59:52 -060021
Andrew Geisslerd79407e2018-11-12 15:26:57 -060022DOCKER_IMG_NAME=${DOCKER_IMG_NAME:-"openbmc/ubuntu-unit-test"}
Andrew Geissler595739b2020-05-19 14:21:49 -050023DISTRO=${DISTRO:-"ubuntu:focal"}
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060024BRANCH=${BRANCH:-"master"}
Lei YU139929a2020-05-26 18:48:05 +080025UBUNTU_MIRROR=${UBUNTU_MIRROR:-""}
Lei YUb8509772020-12-29 13:46:57 +080026http_proxy=${http_proxy:-}
Matthew Barthb4aea672016-11-10 14:59:52 -060027
28# Determine the architecture
29ARCH=$(uname -m)
30case ${ARCH} in
31 "ppc64le")
32 DOCKER_BASE="ppc64le/"
33 ;;
34 "x86_64")
35 DOCKER_BASE=""
36 ;;
37 *)
38 echo "Unsupported system architecture(${ARCH}) found for docker image"
39 exit 1
40esac
41
William A. Kennington III32deed82018-09-17 20:48:23 -070042# Setup temporary files
43DEPCACHE_FILE=""
44cleanup() {
45 local status="$?"
Patrick Venture87445f22018-10-15 17:10:46 -070046 if [[ -n "$DEPCACHE_FILE" ]]; then
William A. Kennington III32deed82018-09-17 20:48:23 -070047 rm -f "$DEPCACHE_FILE"
48 fi
49 trap - EXIT ERR
50 exit "$status"
51}
52trap cleanup EXIT ERR INT TERM QUIT
53DEPCACHE_FILE="$(mktemp)"
54
William A. Kennington III4815f702018-10-03 19:27:42 -070055HEAD_PKGS=(
Andrew Jefferyb4296f52019-08-07 11:03:09 +093056 openbmc/phosphor-objmgr
57 openbmc/sdbusplus
58 openbmc/sdeventplus
59 openbmc/stdplus
60 openbmc/gpioplus
61 openbmc/phosphor-logging
62 openbmc/phosphor-dbus-interfaces
Andrew Jeffery8a273be2019-08-07 11:09:46 +093063 open-power/pdbg
Matt Spinlerbd1ff812019-11-14 10:00:04 -060064 openbmc/pldm
William A. Kennington IIIb4f730a2018-09-12 11:21:20 -070065)
William A. Kennington III32deed82018-09-17 20:48:23 -070066
67# Generate a list of depcache entries
68# We want to do this in parallel since the package list is growing
69# and the network lookup is low overhead but decently high latency.
70# This doesn't worry about producing a stable DEPCACHE_FILE, that is
71# done by readers who need a stable ordering.
72generate_depcache_entry() {
73 local package="$1"
74
75 local tip
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060076 # Need to continue if branch not found, hence || true at end
Andrew Jefferyb4296f52019-08-07 11:03:09 +093077 tip=$(git ls-remote --heads "https://github.com/${package}" |
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060078 grep "refs/heads/$BRANCH" | awk '{ print $1 }' || true)
79
80 # If specific branch is not found then try master
Patrick Williams384d7412020-11-06 16:15:41 -060081 if [[ -z "$tip" ]]; then
Andrew Jefferyb4296f52019-08-07 11:03:09 +093082 tip=$(git ls-remote --heads "https://github.com/${package}" |
Andrew Geisslera6b93bf2019-01-03 10:23:38 -060083 grep "refs/heads/master" | awk '{ print $1 }')
84 fi
William A. Kennington III32deed82018-09-17 20:48:23 -070085
86 # Lock the file to avoid interlaced writes
87 exec 3>> "$DEPCACHE_FILE"
Andrew Geisslerdda45132019-09-01 21:03:04 -050088 flock 3
William A. Kennington III32deed82018-09-17 20:48:23 -070089 echo "$package:$tip" >&3
90 exec 3>&-
91}
William A. Kennington III4815f702018-10-03 19:27:42 -070092for package in "${HEAD_PKGS[@]}"; do
William A. Kennington III32deed82018-09-17 20:48:23 -070093 generate_depcache_entry "$package" &
Andrew Jeffery221eeda2018-03-08 13:32:43 +103094done
William A. Kennington III32deed82018-09-17 20:48:23 -070095wait
Andrew Jeffery221eeda2018-03-08 13:32:43 +103096
William A. Kennington III4815f702018-10-03 19:27:42 -070097# A list of package versions we are building
William A. Kennington IIIc227fb72018-10-03 19:44:33 -070098# Start off by listing the stating versions of third-party sources
99declare -A PKG_REV=(
Wludzik, Jozef2ca47262020-11-17 11:30:26 +0100100 [boost]=1.74.0
Tom Josephd24ead82020-11-30 15:16:06 +0530101 [cereal]=v1.3.0
William A. Kennington III9afb7662020-06-03 19:04:19 -0700102 [catch2]=v2.12.2
William A. Kennington III78655e52020-02-25 14:07:30 -0800103 [CLI11]=v1.9.0
William A. Kennington III9afb7662020-06-03 19:04:19 -0700104 [fmt]=6.2.1
William A. Kennington III6135ba32020-02-25 14:10:11 -0800105 # Snapshot from 2020-01-03
106 [function2]=3a0746bf5f601dfed05330aefcb6854354fce07d
William A. Kennington III171151f2020-02-25 14:10:27 -0800107 # Snapshot from 2020-02-13
108 [googletest]=23b2a3b1cf803999fb38175f6e9e038a4495c8a5
Ed Tanous78b54ba2020-09-25 11:02:32 -0700109 # Release 2020-08-06
110 [json]=v3.9.1
William A. Kennington III0be795e2019-06-26 12:12:33 -0700111 # Snapshot from 2019-05-24
112 [lcov]=75fbae1cfc5027f818a0bb865bf6f96fab3202da
Patrick Venture19b811b2019-05-01 13:55:41 -0700113 # dev-5.0 2019-05-03
114 [linux-headers]=8bf6567e77f7aa68975b7c9c6d044bba690bf327
Jae Hyun Yood34cf322019-09-09 11:50:18 -0700115 # Snapshot from 2019-09-03
116 [libvncserver]=1354f7f1bb6962dab209eddb9d6aac1f03408110
William A. Kennington III9c900d02020-03-13 01:33:02 -0700117 [span-lite]=v0.7.0
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700118 # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb
119 [tinyxml2]=37bc3aca429f0164adf68c23444540b4a24b5778
Manojkiran Edae8fe0372020-10-12 12:32:57 +0530120 # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb
121 [boost-url]=a56ae0df6d3078319755fbaa67822b4fa7fd352b
Brad Bishop0204bec2019-11-07 16:13:54 -0500122 # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb
123 [valijson]=c2f22fddf599d04dc33fcd7ed257c698a05345d9
Matt Spinlerfd51e812020-01-14 13:31:22 -0600124 # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb
125 [fifo_map]=0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700126)
William A. Kennington III4815f702018-10-03 19:27:42 -0700127
128# Turn the depcache into a dictionary so we can reference the HEAD of each repo
Patrick Williams384d7412020-11-06 16:15:41 -0600129while IFS= read -r line; do
130 # shellcheck disable=SC2207 # Expecting to word-split tr results.
William A. Kennington III4815f702018-10-03 19:27:42 -0700131 linearr=($(echo "$line" | tr ':' ' '))
132 PKG_REV["${linearr[0]}"]="${linearr[1]}"
Patrick Williams384d7412020-11-06 16:15:41 -0600133done < "$DEPCACHE_FILE"
William A. Kennington III4815f702018-10-03 19:27:42 -0700134
William A. Kennington III3cf94fd2018-10-03 19:16:55 -0700135# Define common flags used for builds
136PREFIX="/usr/local"
137CONFIGURE_FLAGS=(
138 "--prefix=${PREFIX}"
139)
William A. Kennington III4a67c402018-10-03 15:53:56 -0700140CMAKE_FLAGS=(
141 "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
142 "-DBUILD_SHARED_LIBS=ON"
William A. Kennington III3cf94fd2018-10-03 19:16:55 -0700143 "-DCMAKE_INSTALL_PREFIX:PATH=${PREFIX}"
William A. Kennington III4a67c402018-10-03 15:53:56 -0700144)
William A. Kennington III248cdc62020-06-03 18:50:55 -0700145MESON_FLAGS=(
William A. Kennington III49400512020-06-03 18:51:42 -0700146 "--wrap-mode=nodownload"
William A. Kennington III248cdc62020-06-03 18:50:55 -0700147 "-Dprefix=${PREFIX}"
148)
William A. Kennington III4a67c402018-10-03 15:53:56 -0700149
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930150stagename()
151{
152 local cooked="$1"
153
154 if ! echo "$cooked" | grep -q '/'
155 then
156 cooked=openbmc-"$cooked"
157 fi
158 echo "$cooked" | tr '/' '-'
159}
160
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700161# Build the commands needed to compose our final image
162COPY_CMDS=""
163# We must sort the packages, otherwise we might produce an unstable
164# docker file and rebuild the image unnecessarily
165for pkg in $(echo "${!PKG_REV[@]}" | tr ' ' '\n' | LC_COLLATE=C sort -s); do
Patrick Williams384d7412020-11-06 16:15:41 -0600166 COPY_CMDS+="COPY --from=$(stagename "${pkg}") ${PREFIX} ${PREFIX}"$'\n'
William A. Kennington III36f26222018-11-01 13:40:18 -0700167 # Workaround for upstream docker bug and multiple COPY cmds
168 # https://github.com/moby/moby/issues/37965
169 COPY_CMDS+="RUN true"$'\n'
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700170done
171
Matthew Barthb4aea672016-11-10 14:59:52 -0600172################################# docker img # #################################
173# Create docker image that can run package unit tests
174if [[ "${DISTRO}" == "ubuntu"* ]]; then
Lei YU139929a2020-05-26 18:48:05 +0800175
176MIRROR=""
177if [[ -n "${UBUNTU_MIRROR}" ]]; then
178 MIRROR="RUN echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME) main restricted universe multiverse\" > /etc/apt/sources.list && \
179 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-updates main restricted universe multiverse\" >> /etc/apt/sources.list && \
180 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-security main restricted universe multiverse\" >> /etc/apt/sources.list && \
181 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-proposed main restricted universe multiverse\" >> /etc/apt/sources.list && \
182 echo \"deb ${UBUNTU_MIRROR} \$(. /etc/os-release && echo \$VERSION_CODENAME)-backports main restricted universe multiverse\" >> /etc/apt/sources.list"
183
184fi
185
Lei YUb8509772020-12-29 13:46:57 +0800186PROXY_CMD=""
187if [[ -n "${http_proxy}" ]]; then
188 PROXY_CMD="RUN echo \"[http]\" > \$HOME/.gitconfig && \
189 echo \"proxy = ${http_proxy}\" >> \$HOME/.gitconfig"
190fi
191
Matthew Barthb4aea672016-11-10 14:59:52 -0600192Dockerfile=$(cat << EOF
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700193FROM ${DOCKER_BASE}${DISTRO} as openbmc-base
Matthew Barthb4aea672016-11-10 14:59:52 -0600194
Lei YU139929a2020-05-26 18:48:05 +0800195${MIRROR}
196
Matthew Barthb4aea672016-11-10 14:59:52 -0600197ENV DEBIAN_FRONTEND noninteractive
198
Andrew Geissler595739b2020-05-19 14:21:49 -0500199ENV PYTHONPATH "/usr/local/lib/python3.8/site-packages/"
Andrew Geissler9e5b11f2020-04-01 12:14:29 -0500200
William A. Kennington IIIb1da1272018-06-20 13:28:05 -0700201# We need the keys to be imported for dbgsym repos
202# New releases have a package, older ones fall back to manual fetching
203# https://wiki.ubuntu.com/Debug%20Symbol%20Packages
204RUN apt-get update && ( apt-get install ubuntu-dbgsym-keyring || ( apt-get install -yy dirmngr && \
205 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622 ) )
206
207# Parse the current repo list into a debug repo list
208RUN sed -n '/^deb /s,^deb [^ ]* ,deb http://ddebs.ubuntu.com ,p' /etc/apt/sources.list >/etc/apt/sources.list.d/debug.list
209
210# Remove non-existent debug repos
211RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list
212
213RUN cat /etc/apt/sources.list.d/debug.list
214
William A. Kennington III8b9f4e82020-05-26 22:41:35 -0700215RUN apt-get update && apt-get dist-upgrade -yy && apt-get install -yy \
Andrew Geissler595739b2020-05-19 14:21:49 -0500216 gcc-10 \
217 g++-10 \
William A. Kennington IIIb1da1272018-06-20 13:28:05 -0700218 libc6-dbg \
Matthew Barthb4aea672016-11-10 14:59:52 -0600219 libc6-dev \
220 libtool \
William A. Kennington III2d3eda02019-02-12 20:42:09 -0800221 bison \
Brad Bishopeb1e9692020-11-11 14:32:37 -0500222 libdbus-1-dev \
William A. Kennington III2d3eda02019-02-12 20:42:09 -0800223 flex \
Matthew Barthb4aea672016-11-10 14:59:52 -0600224 cmake \
Saqib Khan362ca852017-03-21 10:48:46 -0500225 python3 \
226 python3-dev\
227 python3-yaml \
228 python3-mako \
Andrew Jefferyb7206972018-04-30 11:57:29 +0930229 python3-pip \
Saqib Khan362ca852017-03-21 10:48:46 -0500230 python3-setuptools \
Andrew Jefferybda43ce2020-03-13 12:19:49 +1030231 python3-git \
Andrew Geissler9e5b11f2020-04-01 12:14:29 -0500232 python3-socks \
Matthew Barthb4aea672016-11-10 14:59:52 -0600233 pkg-config \
234 autoconf \
William A. Kennington III7e46dd82018-06-20 01:17:03 -0700235 autoconf-archive \
Matthew Barthb4aea672016-11-10 14:59:52 -0600236 libsystemd-dev \
Brad Bishopa1ee2652019-03-29 16:42:06 -0400237 systemd \
Matthew Barth92f93872017-02-08 11:19:27 -0600238 libssl-dev \
Matthew Barth550bc0d2017-04-10 13:25:50 -0500239 libevdev-dev \
William A. Kennington IIIb1da1272018-06-20 13:28:05 -0700240 libevdev2-dbgsym \
Eddie James61c89bb2018-09-06 13:48:53 -0500241 libjpeg-dev \
William A. Kennington IIIbb71cc02018-10-03 19:19:23 -0700242 libpng-dev \
William A. Kennington IIIbaeb4f52018-12-06 14:57:13 -0800243 ninja-build \
Matthew Barthb4aea672016-11-10 14:59:52 -0600244 sudo \
William A. Kennington III22658b02018-06-29 15:55:17 -0700245 curl \
Leonel Gonzalez13ca3802017-03-07 14:08:44 -0600246 git \
Saqib Khan5158a322017-10-23 11:31:24 -0500247 dbus \
Andrew Geissler158b0a12018-01-10 10:46:48 -0800248 iputils-ping \
Patrick Williams80d07282020-05-20 10:56:22 -0500249 clang-10 \
250 clang-format-10 \
251 clang-tidy-10 \
252 clang-tools-10 \
Patrick Williams01ced282020-07-17 15:10:15 -0500253 shellcheck \
Gunnar Mills6b25a032019-07-11 12:16:35 -0500254 npm \
Ratan Gupta2f03fd72018-03-30 22:48:11 +0530255 iproute2 \
256 libnl-3-dev \
Patrick Venture643d8d02018-05-10 08:57:15 -0700257 libnl-genl-3-dev \
Ratan Guptaa0a1e332018-05-25 10:37:33 +0530258 libconfig++-dev \
William A. Kennington III9e2be202018-06-19 19:35:43 -0700259 libsnmp-dev \
260 valgrind \
William A. Kennington IIIb1da1272018-06-20 13:28:05 -0700261 valgrind-dbg \
James Feist878df5c2018-07-26 14:54:28 -0700262 libpam0g-dev \
Ratan Gupta48347e02018-08-08 17:43:10 +0530263 xxd \
James Feist182bbf32018-10-03 09:42:44 -0700264 libi2c-dev \
Andrew Geissler61a33972018-10-05 05:41:30 -0500265 wget \
Patrick Venturedef31a82018-12-10 13:24:46 -0800266 libldap2-dev \
267 libprotobuf-dev \
William A. Kennington III0be795e2019-06-26 12:12:33 -0700268 libperlio-gzip-perl \
269 libjson-perl \
James Feistcf8fddb2019-05-30 15:30:42 -0700270 protobuf-compiler \
Andrew Jeffery8a273be2019-08-07 11:09:46 +0930271 libgpiod-dev \
Andrew Geissler938d21e2019-09-01 21:09:33 -0500272 device-tree-compiler \
Benjamin Fair716780a2020-06-05 17:57:14 -0700273 cppcheck \
Asmitha Karunanithid0810812020-06-20 01:54:14 -0500274 libpciaccess-dev \
Zane Shelleyc688c322020-11-13 11:01:08 -0600275 libmimetic-dev \
276 libxml2-utils \
277 libxml-simple-perl
Matthew Barthb4aea672016-11-10 14:59:52 -0600278
Andrew Geissler595739b2020-05-19 14:21:49 -0500279RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 1000 \
280 --slave /usr/bin/g++ g++ /usr/bin/g++-10 \
281 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 \
282 --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
283 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
William A. Kennington III0232a252019-06-26 12:13:47 -0700284
Ed Tanousbc5c1c42020-10-01 17:49:20 -0700285
286RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \
287 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \
288 --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \
289 --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \
290 --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py
291
Patrick Williamsf7c2c5f2020-02-06 10:51:04 -0600292RUN pip3 install inflection
Andrew Geissler9e5b11f2020-04-01 12:14:29 -0500293RUN pip3 install pycodestyle
Shawn McCarneya49dbde2020-03-05 08:52:05 -0600294RUN pip3 install jsonschema
Patrick Williams2c880fe2020-06-15 13:00:45 -0500295RUN pip3 install meson==0.54.3
Nan Zhouf2d79672020-09-02 11:52:22 -0700296RUN pip3 install protobuf
Matthew Bartha2366d92017-01-31 09:46:20 -0600297
William A. Kennington III1a651822019-01-16 14:48:52 -0800298FROM openbmc-base as openbmc-lcov
299RUN curl -L https://github.com/linux-test-project/lcov/archive/${PKG_REV['lcov']}.tar.gz | tar -xz && \
300cd lcov-* && \
301make -j$(nproc) && \
302make install
303
William A. Kennington III8ff1e0f2019-03-27 03:19:51 -0700304FROM openbmc-base as openbmc-function2
William A. Kennington IIIf6884642019-03-29 15:19:20 -0700305RUN mkdir ${PREFIX}/include/function2 && \
306curl -L -o ${PREFIX}/include/function2/function2.hpp https://raw.githubusercontent.com/Naios/function2/${PKG_REV['function2']}/include/function2/function2.hpp
William A. Kennington III8ff1e0f2019-03-27 03:19:51 -0700307
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700308FROM openbmc-base as openbmc-googletest
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700309RUN curl -L https://github.com/google/googletest/archive/${PKG_REV['googletest']}.tar.gz | tar -xz && \
William A. Kennington III5b550082018-10-03 19:25:49 -0700310cd googletest-* && \
William A. Kennington IIIb47eea52018-10-03 17:11:29 -0700311mkdir build && \
312cd build && \
William A. Kennington IIIda224a52020-10-13 23:15:01 -0700313CXXFLAGS=-std=c++17 cmake ${CMAKE_FLAGS[@]} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \
William A. Kennington III048b5ee2018-10-03 19:37:56 -0700314make -j$(nproc) && \
315make install
Matthew Barthb4aea672016-11-10 14:59:52 -0600316
William A. Kennington III1e4d5332019-10-18 12:24:18 -0700317FROM openbmc-base as openbmc-catch2
318RUN curl -L https://github.com/catchorg/Catch2/archive/${PKG_REV['catch2']}.tar.gz | tar -xz && \
319cd Catch2-* && \
320mkdir build && \
321cd build && \
William A. Kennington III84a19a62020-02-25 14:06:57 -0800322cmake ${CMAKE_FLAGS[@]} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \
William A. Kennington III1e4d5332019-10-18 12:24:18 -0700323make -j$(nproc) && \
324make install
325
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700326FROM openbmc-base as openbmc-cereal
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700327RUN curl -L https://github.com/USCiLab/cereal/archive/${PKG_REV['cereal']}.tar.gz | tar -xz && \
328cp -a cereal-*/include/cereal/ ${PREFIX}/include/
Deepak Kodihallide7767c2017-06-21 02:19:14 -0500329
William A. Kennington III1962d572018-09-12 22:38:15 -0700330FROM openbmc-base as openbmc-CLI11
331RUN curl -L https://github.com/CLIUtils/CLI11/archive/${PKG_REV['CLI11']}.tar.gz | tar -xz && \
332cd CLI11-* && \
333mkdir build && \
334cd build && \
William A. Kennington III78655e52020-02-25 14:07:30 -0800335cmake ${CMAKE_FLAGS[@]} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \
William A. Kennington III1962d572018-09-12 22:38:15 -0700336make -j$(nproc) && \
337make install
338
William A. Kennington III6b50d702019-07-09 16:44:05 -0700339FROM openbmc-base as openbmc-fmt
340RUN curl -L https://github.com/fmtlib/fmt/archive/${PKG_REV['fmt']}.tar.gz | tar -xz && \
341cd fmt-* && \
342mkdir build && \
343cd build && \
344cmake ${CMAKE_FLAGS[@]} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \
345make -j$(nproc) && \
346make install
347
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700348FROM openbmc-base as openbmc-json
William A. Kennington IIIc8e8b202018-10-03 19:35:59 -0700349RUN mkdir ${PREFIX}/include/nlohmann/ && \
Ed Tanous78b54ba2020-09-25 11:02:32 -0700350curl -L -o ${PREFIX}/include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/${PKG_REV['json']}/json.hpp && \
Brad Bishop23c81f42019-11-07 14:41:17 -0500351ln -s nlohmann/json.hpp ${PREFIX}/include/json.hpp
David Cobbleye99c07a2017-12-22 11:39:01 -0800352
Matt Spinlerfd51e812020-01-14 13:31:22 -0600353FROM openbmc-base as openbmc-fifo_map
354RUN curl -L https://github.com/nlohmann/fifo_map/archive/${PKG_REV['fifo_map']}.tar.gz | tar -xz && \
355cd fifo_map-*/src && cp fifo_map.hpp ${PREFIX}/include/
356
William A. Kennington IIIe1d68692019-10-18 12:26:12 -0700357FROM openbmc-base as openbmc-span-lite
358RUN curl -L https://github.com/martinmoene/span-lite/archive/${PKG_REV['span-lite']}.tar.gz | tar -xz && \
359cd span-lite-* && \
360mkdir build && \
361cd build && \
362cmake ${CMAKE_FLAGS[@]} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \
363make -j$(nproc) && \
364make install
365
William A. Kennington III2d3eda02019-02-12 20:42:09 -0800366FROM openbmc-base as openbmc-linux-headers
367RUN curl -L https://github.com/openbmc/linux/archive/${PKG_REV['linux-headers']}.tar.gz | tar -xz && \
368cd linux-* && \
369make -j$(nproc) defconfig && \
370make INSTALL_HDR_PATH=/usr/local headers_install
371
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700372FROM openbmc-base as openbmc-boost
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700373RUN curl -L https://dl.bintray.com/boostorg/release/${PKG_REV['boost']}/source/boost_$(echo "${PKG_REV['boost']}" | tr '.' '_').tar.bz2 | tar -xj && \
Vernon Mauery2b168a82018-10-29 14:57:16 -0700374cd boost_*/ && \
375./bootstrap.sh --prefix=${PREFIX} --with-libraries=context,coroutine && \
376./b2 && ./b2 install --prefix=${PREFIX}
James Feist878df5c2018-07-26 14:54:28 -0700377
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700378FROM openbmc-base as openbmc-tinyxml2
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700379RUN curl -L https://github.com/leethomason/tinyxml2/archive/${PKG_REV['tinyxml2']}.tar.gz | tar -xz && \
William A. Kennington III5b550082018-10-03 19:25:49 -0700380cd tinyxml2-* && \
William A. Kennington III581c4d42018-10-03 15:48:20 -0700381mkdir build && \
382cd build && \
William A. Kennington III4a67c402018-10-03 15:53:56 -0700383cmake ${CMAKE_FLAGS[@]} .. && \
William A. Kennington III581c4d42018-10-03 15:48:20 -0700384make -j$(nproc) && \
385make install
386
Manojkiran Edae8fe0372020-10-12 12:32:57 +0530387FROM openbmc-base as openbmc-boost-url
388RUN curl -L https://github.com/CPPAlliance/url/archive/${PKG_REV['boost-url']}.tar.gz | tar -xz && \
389cd url-* && \
390mkdir buildir && \
391cd buildir && \
392cmake ${CMAKE_FLAGS[@]} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \
393make -j$(nproc) && \
394make install
395
Brad Bishop0204bec2019-11-07 16:13:54 -0500396FROM openbmc-base as openbmc-valijson
397RUN curl -L https://github.com/tristanpenman/valijson/archive/${PKG_REV['valijson']}.tar.gz | tar -xz && \
398cd valijson-* && \
399mkdir build && \
400cd build && \
401cmake ${CMAKE_FLAGS[@]} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \
402make -j$(nproc) && \
403make install
404
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700405FROM openbmc-base as openbmc-libvncserver
William A. Kennington IIIc227fb72018-10-03 19:44:33 -0700406RUN curl -L https://github.com/LibVNC/libvncserver/archive/${PKG_REV['libvncserver']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700407cd libvncserver-* && \
William A. Kennington III581c4d42018-10-03 15:48:20 -0700408mkdir build && \
409cd build && \
William A. Kennington IIIbb71cc02018-10-03 19:19:23 -0700410cmake ${CMAKE_FLAGS[@]} .. && \
William A. Kennington III581c4d42018-10-03 15:48:20 -0700411make -j$(nproc) && \
412make install
413
William A. Kennington III1b873212019-03-21 19:02:42 -0700414FROM openbmc-base as openbmc-stdplus
William A. Kennington III05e7b5f2020-06-03 18:45:50 -0700415COPY --from=openbmc-fmt ${PREFIX} ${PREFIX}
416COPY --from=openbmc-span-lite ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930417RUN curl -L https://github.com/openbmc/stdplus/archive/${PKG_REV['openbmc/stdplus']}.tar.gz | tar -xz && \
William A. Kennington III1b873212019-03-21 19:02:42 -0700418cd stdplus-* && \
William A. Kennington III248cdc62020-06-03 18:50:55 -0700419meson build ${MESON_FLAGS[@]} -Dtests=disabled -Dexamples=false && \
William A. Kennington III1b873212019-03-21 19:02:42 -0700420ninja -C build && \
421ninja -C build install
422
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700423FROM openbmc-base as openbmc-sdbusplus
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930424RUN curl -L https://github.com/openbmc/sdbusplus/archive/${PKG_REV['openbmc/sdbusplus']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700425cd sdbusplus-* && \
William A. Kennington IIIde834b62020-06-03 18:55:33 -0700426cd tools && ./setup.py install --root=/ --prefix=${PREFIX} && \
William A. Kennington III75602172020-06-04 13:45:33 -0700427cd .. && meson build ${MESON_FLAGS[@]} -Dtests=disabled -Dexamples=disabled && \
Patrick Williams9e32de22020-06-01 07:31:17 -0500428ninja -C build && \
William A. Kennington IIIde834b62020-06-03 18:55:33 -0700429ninja -C build install
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030430
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700431FROM openbmc-base as openbmc-sdeventplus
William A. Kennington III4ca0e7b2019-03-27 03:33:18 -0700432COPY --from=openbmc-function2 ${PREFIX} ${PREFIX}
William A. Kennington IIIa472fda2019-03-21 21:06:38 -0700433COPY --from=openbmc-stdplus ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930434RUN curl -L https://github.com/openbmc/sdeventplus/archive/${PKG_REV['openbmc/sdeventplus']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700435cd sdeventplus-* && \
William A. Kennington III248cdc62020-06-03 18:50:55 -0700436meson build ${MESON_FLAGS[@]} -Dtests=disabled -Dexamples=false && \
William A. Kennington III2b639f32019-03-21 19:00:38 -0700437ninja -C build && \
438ninja -C build install
William A. Kennington IIIb4f730a2018-09-12 11:21:20 -0700439
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700440FROM openbmc-base as openbmc-gpioplus
William A. Kennington III1aed1252019-01-15 18:18:03 -0800441COPY --from=openbmc-stdplus ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930442RUN curl -L https://github.com/openbmc/gpioplus/archive/${PKG_REV['openbmc/gpioplus']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700443cd gpioplus-* && \
William A. Kennington III248cdc62020-06-03 18:50:55 -0700444meson build ${MESON_FLAGS[@]} -Dtests=disabled -Dexamples=false && \
William A. Kennington III83648312019-03-27 19:53:18 -0700445ninja -C build && \
446ninja -C build install
Patrick Venture22329962018-09-14 10:23:04 -0700447
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700448FROM openbmc-base as openbmc-phosphor-dbus-interfaces
449COPY --from=openbmc-sdbusplus ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930450RUN curl -L https://github.com/openbmc/phosphor-dbus-interfaces/archive/${PKG_REV['openbmc/phosphor-dbus-interfaces']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700451cd phosphor-dbus-interfaces-* && \
Patrick Williams317157d2020-09-16 15:52:59 -0500452meson build ${MESON_FLAGS[@]} -Ddata_org_open_power=true -Ddata_com_ibm=true && \
453ninja -C build && \
454ninja -C build install
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030455
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700456FROM openbmc-base as openbmc-phosphor-logging
457COPY --from=openbmc-cereal ${PREFIX} ${PREFIX}
458COPY --from=openbmc-sdbusplus ${PREFIX} ${PREFIX}
William A. Kennington III4f47a5c2019-07-16 14:57:57 -0700459COPY --from=openbmc-sdeventplus ${PREFIX} ${PREFIX}
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700460COPY --from=openbmc-phosphor-dbus-interfaces ${PREFIX} ${PREFIX}
Matt Spinlerfd51e812020-01-14 13:31:22 -0600461COPY --from=openbmc-fifo_map ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930462RUN curl -L https://github.com/openbmc/phosphor-logging/archive/${PKG_REV['openbmc/phosphor-logging']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700463cd phosphor-logging-* && \
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030464./bootstrap.sh && \
William A. Kennington IIIc8e8b202018-10-03 19:35:59 -0700465./configure ${CONFIGURE_FLAGS[@]} --enable-metadata-processing YAML_DIR=${PREFIX}/share/phosphor-dbus-yaml/yaml && \
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030466make -j$(nproc) && \
467make install
468
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700469FROM openbmc-base as openbmc-phosphor-objmgr
470COPY --from=openbmc-boost ${PREFIX} ${PREFIX}
471COPY --from=openbmc-sdbusplus ${PREFIX} ${PREFIX}
472COPY --from=openbmc-tinyxml2 ${PREFIX} ${PREFIX}
473COPY --from=openbmc-phosphor-logging ${PREFIX} ${PREFIX}
Andrew Jefferyb4296f52019-08-07 11:03:09 +0930474RUN curl -L https://github.com/openbmc/phosphor-objmgr/archive/${PKG_REV['openbmc/phosphor-objmgr']}.tar.gz | tar -xz && \
William A. Kennington III4815f702018-10-03 19:27:42 -0700475cd phosphor-objmgr-* && \
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030476./bootstrap.sh && \
Matt Spinlerf3e08ee2019-04-10 11:13:33 -0500477./configure ${CONFIGURE_FLAGS[@]} && \
Andrew Jeffery221eeda2018-03-08 13:32:43 +1030478make -j$(nproc) && \
479make install
480
Andrew Jeffery8a273be2019-08-07 11:09:46 +0930481FROM openbmc-base as open-power-pdbg
482RUN curl -L https://github.com/open-power/pdbg/archive/${PKG_REV['open-power/pdbg']}.tar.gz | tar -xz && \
483cd pdbg-* && \
484./bootstrap.sh && \
485./configure ${CONFIGURE_FLAGS[@]} && \
486make -j$(nproc) && \
487make install
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700488
Matt Spinlerbd1ff812019-11-14 10:00:04 -0600489FROM openbmc-base as openbmc-pldm
490COPY --from=openbmc-sdbusplus ${PREFIX} ${PREFIX}
491COPY --from=openbmc-sdeventplus ${PREFIX} ${PREFIX}
492COPY --from=openbmc-boost ${PREFIX} ${PREFIX}
493COPY --from=openbmc-phosphor-dbus-interfaces ${PREFIX} ${PREFIX}
494COPY --from=openbmc-phosphor-logging ${PREFIX} ${PREFIX}
495COPY --from=openbmc-json ${PREFIX} ${PREFIX}
496COPY --from=openbmc-CLI11 ${PREFIX} ${PREFIX}
497RUN curl -L https://github.com/openbmc/pldm/archive/${PKG_REV['openbmc/pldm']}.tar.gz | tar -xz && \
498cd pldm-* && \
William A. Kennington III248cdc62020-06-03 18:50:55 -0700499meson build ${MESON_FLAGS[@]} -Dtests=disabled && \
Matt Spinlerbd1ff812019-11-14 10:00:04 -0600500ninja -C build && \
501ninja -C build install
502
William A. Kennington IIIda70d702018-10-03 19:57:35 -0700503# Build the final output image
504FROM openbmc-base
505${COPY_CMDS}
506
William A. Kennington III212cfcb2018-10-03 19:48:26 -0700507# Some of our infrastructure still relies on the presence of this file
508# even though it is no longer needed to rebuild the docker environment
509# NOTE: The file is sorted to ensure the ordering is stable.
William A. Kennington IIIbe6aab22018-12-06 15:01:54 -0800510RUN echo '$(LC_COLLATE=C sort -s "$DEPCACHE_FILE" | tr '\n' ',')' > /tmp/depcache
William A. Kennington III212cfcb2018-10-03 19:48:26 -0700511
512# Final configuration for the workspace
Patrick Williams384d7412020-11-06 16:15:41 -0600513RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
William A. Kennington IIIc1e93cb2019-07-16 15:40:25 -0700514RUN mkdir -p "$(dirname "${HOME}")"
Patrick Williams384d7412020-11-06 16:15:41 -0600515RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
William A. Kennington III3bba8fb2018-12-13 15:07:49 -0800516RUN sed -i '1iDefaults umask=000' /etc/sudoers
William A. Kennington IIIbe6aab22018-12-06 15:01:54 -0800517RUN echo "${USER} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
William A. Kennington III212cfcb2018-10-03 19:48:26 -0700518
Lei YUb8509772020-12-29 13:46:57 +0800519${PROXY_CMD}
520
Matthew Barthb4aea672016-11-10 14:59:52 -0600521RUN /bin/bash
522EOF
523)
524fi
525################################# docker img # #################################
526
Lei YU139929a2020-05-26 18:48:05 +0800527proxy_args=""
528if [[ -n "${http_proxy}" ]]; then
529 proxy_args="--build-arg http_proxy=${http_proxy} --build-arg https_proxy=${http_proxy}"
530fi
531
Matthew Barthb4aea672016-11-10 14:59:52 -0600532# Build above image
Patrick Williams384d7412020-11-06 16:15:41 -0600533# shellcheck disable=SC2086 # proxy_args requires word splitting.
534docker build ${proxy_args} --network=host -t "${DOCKER_IMG_NAME}" - <<< "${Dockerfile}"