blob: f8053d375dd0daacbaab629a259f7bc0e2000cdc [file] [log] [blame]
Patrick Williams02871c92021-02-01 20:57:19 -06001#!/usr/bin/env python3
2#
3# Build the required docker image to run package unit tests
4#
5# 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>
9# default is ubuntu:eoan
10# BRANCH: <optional, branch to build from each of the openbmc/
11# repositories>
12# default is master, which will be used if input branch not
13# provided or not found
14# 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.
17# http_proxy The HTTP address of the proxy server to connect to.
18# Default: "", proxy is not setup if this is not set
19
20import os
21import sys
22from sh import docker, git, nproc, uname
23
24# Read a bunch of environment variables.
25docker_image_name = os.environ.get("DOCKER_IMAGE_NAME", "openbmc/ubuntu-unit-test")
26distro = os.environ.get("DISTRO", "ubuntu:focal")
27branch = os.environ.get("BRANCH", "master")
28ubuntu_mirror = os.environ.get("UBUNTU_MIRROR")
29http_proxy = os.environ.get("http_proxy")
30
31# Set up some common variables.
32proc_count = nproc().strip()
33username = os.environ.get("USER")
34homedir = os.environ.get("HOME")
35gid = os.getgid()
36uid = os.getuid()
37
38# Determine the architecture for Docker.
39arch = uname("-m").strip()
40if arch == "ppc64le":
41 docker_base = "ppc64le/"
42elif arch == "x86_64":
43 docker_base = ""
44else:
45 print(f"Unsupported system architecture({arch}) found for docker image")
46 sys.exit(1)
47
Patrick Williams72043242021-02-02 10:31:45 -060048# Packages to include in image.
49packages = {
Patrick Williams2abc4a42021-02-03 06:11:40 -060050 "boost": {
51 "rev": "1.74.0",
52 "url": (
53 lambda pkg, rev: f"https://dl.bintray.com/boostorg/release/{rev}/source/{pkg}_{rev.replace('.', '_')}.tar.bz2"
54 ),
55 },
56 "USCiLab/cereal": {"rev": "v1.3.0"},
57 "catchorg/Catch2": {"rev": "v2.12.2"},
58 "CLIUtils/CLI11": {"rev": "v1.9.0"},
59 "fmtlib/fmt": {"rev": "6.2.1"},
Patrick Williams02871c92021-02-01 20:57:19 -060060 # Snapshot from 2020-01-03
Patrick Williams2abc4a42021-02-03 06:11:40 -060061 "Naios/function2": {"rev": "3a0746bf5f601dfed05330aefcb6854354fce07d"},
Patrick Williams02871c92021-02-01 20:57:19 -060062 # Snapshot from 2020-02-13
Patrick Williams2abc4a42021-02-03 06:11:40 -060063 "google/googletest": {"rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5"},
Patrick Williams02871c92021-02-01 20:57:19 -060064 # Release 2020-08-06
Patrick Williams2abc4a42021-02-03 06:11:40 -060065 "nlohmann/json": {"rev": "v3.9.1"},
Patrick Williams02871c92021-02-01 20:57:19 -060066 # Snapshot from 2019-05-24
Patrick Williams2abc4a42021-02-03 06:11:40 -060067 "linux-test-project/lcov": {"rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da"},
Patrick Williams02871c92021-02-01 20:57:19 -060068 # dev-5.0 2019-05-03
Patrick Williams2abc4a42021-02-03 06:11:40 -060069 "openbmc/linux": {"rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327"},
Patrick Williams02871c92021-02-01 20:57:19 -060070 # Snapshot from 2019-09-03
Patrick Williams2abc4a42021-02-03 06:11:40 -060071 "LibVNC/libvncserver": {"rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110"},
72 "martinmoene/span-lite": {"rev": "v0.7.0"},
Patrick Williams02871c92021-02-01 20:57:19 -060073 # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb
Patrick Williams2abc4a42021-02-03 06:11:40 -060074 "leethomason/tinyxml2": {"rev": "37bc3aca429f0164adf68c23444540b4a24b5778"},
Patrick Williams02871c92021-02-01 20:57:19 -060075 # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb
Patrick Williams2abc4a42021-02-03 06:11:40 -060076 "CPPAlliance/url": {"rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b"},
Patrick Williams02871c92021-02-01 20:57:19 -060077 # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb
Patrick Williams2abc4a42021-02-03 06:11:40 -060078 "tristanpenman/valijson": {"rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9"},
Patrick Williams02871c92021-02-01 20:57:19 -060079 # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb
Patrick Williams2abc4a42021-02-03 06:11:40 -060080 "nlohmann/fifo_map": {"rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9"},
Patrick Williams72043242021-02-02 10:31:45 -060081 "open-power/pdbg": {},
Patrick Williams83394612021-02-03 07:12:50 -060082 "openbmc/gpioplus": {"depends": ["openbmc/stdplus"]},
83 "openbmc/phosphor-dbus-interfaces": {"depends": ["openbmc/sdbusplus"]},
84 "openbmc/phosphor-logging": {
85 "depends": [
86 "USCiLab/cereal",
87 "nlohmann/fifo_map",
88 "openbmc/phosphor-dbus-interfaces",
89 "openbmc/sdbusplus",
90 "openbmc/sdeventplus",
91 ]
92 },
93 "openbmc/phosphor-objmgr": {
94 "depends": [
95 "boost",
96 "leethomason/tinyxml2",
97 "openbmc/phosphor-logging",
98 "openbmc/sdbusplus",
99 ]
100 },
101 "openbmc/pldm": {
102 "depends": [
103 "CLIUtils/CLI11",
104 "boost",
105 "nlohmann/json",
106 "openbmc/phosphor-dbus-interfaces",
107 "openbmc/phosphor-logging",
108 "openbmc/sdbusplus",
109 "openbmc/sdeventplus",
110 ]
111 },
Patrick Williams72043242021-02-02 10:31:45 -0600112 "openbmc/sdbusplus": {},
Patrick Williams83394612021-02-03 07:12:50 -0600113 "openbmc/sdeventplus": {"depends": ["Naios/function2", "openbmc/stdplus"]},
114 "openbmc/stdplus": {"depends": ["fmtlib/fmt", "martinmoene/span-lite"]},
Patrick Williams02871c92021-02-01 20:57:19 -0600115}
116
Patrick Williams2abc4a42021-02-03 06:11:40 -0600117
Patrick Williams72043242021-02-02 10:31:45 -0600118def pkg_rev(pkg):
119 return packages[pkg]["rev"]
120
Patrick Williams2abc4a42021-02-03 06:11:40 -0600121
Patrick Williamse1398742021-02-02 12:20:20 -0600122def pkg_stagename(pkg):
123 if not pkg.startswith("openbmc/"):
124 pkg = "openbmc/" + pkg
125 return pkg.replace("/", "-")
Patrick Williams72043242021-02-02 10:31:45 -0600126
Patrick Williams2abc4a42021-02-03 06:11:40 -0600127
128def pkg_url(pkg):
129 if "url" in packages[pkg]:
130 return packages[pkg]["url"](pkg, pkg_rev(pkg))
131 return f"https://github.com/{pkg}/archive/{pkg_rev(pkg)}.tar.gz"
132
133
Patrick Williams83394612021-02-03 07:12:50 -0600134def pkg_copycmds(pkg=None):
135 pkgs = []
136 if pkg:
137 if "depends" not in packages[pkg]:
138 return ""
139 pkgs = sorted(packages[pkg]["depends"])
140 else:
141 pkgs = sorted(packages.keys())
142
143 copy_cmds = ""
144 for p in pkgs:
145 copy_cmds += f"COPY --from={pkg_stagename(p)} {prefix} {prefix}\n"
146 # Workaround for upstream docker bug and multiple COPY cmds
147 # https://github.com/moby/moby/issues/37965
148 copy_cmds += "RUN true\n"
149 return copy_cmds
150
151
Patrick Williams72043242021-02-02 10:31:45 -0600152# Look up the HEAD for missing a static rev.
Patrick Williams02871c92021-02-01 20:57:19 -0600153pkg_lookups = {}
Patrick Williams72043242021-02-02 10:31:45 -0600154for pkg in packages.keys():
155 if "rev" in packages[pkg]:
156 continue
Patrick Williams02871c92021-02-01 20:57:19 -0600157 pkg_lookups[pkg] = git(
158 "ls-remote", "--heads", f"https://github.com/{pkg}", _bg=True
159 )
160for pkg, result in pkg_lookups.items():
161 for line in result.stdout.decode().split("\n"):
162 if f"refs/heads/{branch}" in line:
Patrick Williams72043242021-02-02 10:31:45 -0600163 packages[pkg]["rev"] = line.strip().split()[0]
164 elif "refs/heads/master" in line and p not in packages:
165 packages[pkg]["rev"] = line.strip().split()[0]
Patrick Williams02871c92021-02-01 20:57:19 -0600166
167# Create the contents of the '/tmp/depcache'.
168# This needs to be sorted for consistency.
169depcache = ""
Patrick Williams72043242021-02-02 10:31:45 -0600170for pkg in sorted(packages.keys()):
171 depcache += "%s:%s," % (pkg, pkg_rev(pkg))
Patrick Williams02871c92021-02-01 20:57:19 -0600172
173# Define common flags used for builds
174prefix = "/usr/local"
175configure_flags = " ".join(
176 [
177 f"--prefix={prefix}",
178 ]
179)
180cmake_flags = " ".join(
181 [
182 "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
183 "-DBUILD_SHARED_LIBS=ON",
184 f"-DCMAKE_INSTALL_PREFIX:PATH={prefix}",
185 ]
186)
187meson_flags = " ".join(
188 [
189 "--wrap-mode=nodownload",
190 f"-Dprefix={prefix}",
191 ]
192)
193
Patrick Williams02871c92021-02-01 20:57:19 -0600194# Build the commands needed to compose our final image
195# We must sort the packages, otherwise we might produce an unstable
196# docker file and rebuild the image unnecessarily
Patrick Williams83394612021-02-03 07:12:50 -0600197copy_cmds = pkg_copycmds()
Patrick Williams02871c92021-02-01 20:57:19 -0600198
199# Special flags if setting up a deb mirror.
200mirror = ""
201if "ubuntu" in distro and ubuntu_mirror:
202 mirror = f"""
203RUN echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME) main restricted universe multiverse" > /etc/apt/sources.list && \\
204 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-updates main restricted universe multiverse" >> /etc/apt/sources.list && \\
205 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-security main restricted universe multiverse" >> /etc/apt/sources.list && \\
206 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-proposed main restricted universe multiverse" >> /etc/apt/sources.list && \\
207 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-backports main restricted universe multiverse" >> /etc/apt/sources.list
208"""
209
210# Special flags for proxying.
211proxy_cmd = ""
212proxy_args = []
213if http_proxy:
214 proxy_cmd = f"""
215RUN echo "[http]" >> {homedir}/.gitconfig && \
216 echo "proxy = {http_proxy}" >> {homedir}/.gitconfig
217"""
218 proxy_args.extend(
219 [
220 "--build-arg",
221 f"http_proxy={http_proxy}",
222 "--build-arg",
223 "https_proxy={https_proxy}",
224 ]
225 )
226
227# Create docker image that can run package unit tests
228dockerfile = f"""
229FROM {docker_base}{distro} as openbmc-base
230
231{mirror}
232
233ENV DEBIAN_FRONTEND noninteractive
234
235ENV PYTHONPATH "/usr/local/lib/python3.8/site-packages/"
236
237# We need the keys to be imported for dbgsym repos
238# New releases have a package, older ones fall back to manual fetching
239# https://wiki.ubuntu.com/Debug%20Symbol%20Packages
240RUN apt-get update && ( apt-get install ubuntu-dbgsym-keyring || ( apt-get install -yy dirmngr && \
241 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622 ) )
242
243# Parse the current repo list into a debug repo list
244RUN sed -n '/^deb /s,^deb [^ ]* ,deb http://ddebs.ubuntu.com ,p' /etc/apt/sources.list >/etc/apt/sources.list.d/debug.list
245
246# Remove non-existent debug repos
247RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list
248
249RUN cat /etc/apt/sources.list.d/debug.list
250
251RUN apt-get update && apt-get dist-upgrade -yy && apt-get install -yy \
252 gcc-10 \
253 g++-10 \
254 libc6-dbg \
255 libc6-dev \
256 libtool \
257 bison \
258 libdbus-1-dev \
259 flex \
260 cmake \
261 python3 \
262 python3-dev\
263 python3-yaml \
264 python3-mako \
265 python3-pip \
266 python3-setuptools \
267 python3-git \
268 python3-socks \
269 pkg-config \
270 autoconf \
271 autoconf-archive \
272 libsystemd-dev \
273 systemd \
274 libssl-dev \
275 libevdev-dev \
276 libevdev2-dbgsym \
277 libjpeg-dev \
278 libpng-dev \
279 ninja-build \
280 sudo \
281 curl \
282 git \
283 dbus \
284 iputils-ping \
285 clang-10 \
286 clang-format-10 \
287 clang-tidy-10 \
288 clang-tools-10 \
289 shellcheck \
290 npm \
291 iproute2 \
292 libnl-3-dev \
293 libnl-genl-3-dev \
294 libconfig++-dev \
295 libsnmp-dev \
296 valgrind \
297 valgrind-dbg \
298 libpam0g-dev \
299 xxd \
300 libi2c-dev \
301 wget \
302 libldap2-dev \
303 libprotobuf-dev \
304 libperlio-gzip-perl \
305 libjson-perl \
306 protobuf-compiler \
307 libgpiod-dev \
308 device-tree-compiler \
309 cppcheck \
310 libpciaccess-dev \
311 libmimetic-dev \
312 libxml2-utils \
313 libxml-simple-perl
314
315RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 1000 \
316 --slave /usr/bin/g++ g++ /usr/bin/g++-10 \
317 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 \
318 --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
319 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
320
321
322RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \
323 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \
324 --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \
325 --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \
326 --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py
327
328RUN pip3 install inflection
329RUN pip3 install pycodestyle
330RUN pip3 install jsonschema
331RUN pip3 install meson==0.54.3
332RUN pip3 install protobuf
333
Patrick Williams2abc4a42021-02-03 06:11:40 -0600334FROM openbmc-base as {pkg_stagename('linux-test-project/lcov')}
Patrick Williams83394612021-02-03 07:12:50 -0600335{pkg_copycmds('linux-test-project/lcov')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600336RUN curl -L {pkg_url('linux-test-project/lcov')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600337cd lcov-* && \
338make -j{proc_count} && \
339make install
340
Patrick Williams2abc4a42021-02-03 06:11:40 -0600341FROM openbmc-base as {pkg_stagename('Naios/function2')}
Patrick Williams83394612021-02-03 07:12:50 -0600342{pkg_copycmds('Naios/function2')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600343RUN curl -L {pkg_url('Naios/function2')} | tar -xz && \
344cd function2-* && \
345mkdir {prefix}/include/function2 && \
346cp include/function2/function2.hpp {prefix}/include/function2/
Patrick Williams02871c92021-02-01 20:57:19 -0600347
Patrick Williams2abc4a42021-02-03 06:11:40 -0600348FROM openbmc-base as {pkg_stagename('google/googletest')}
Patrick Williams83394612021-02-03 07:12:50 -0600349{pkg_copycmds('google/googletest')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600350RUN curl -L {pkg_url('google/googletest')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600351cd googletest-* && \
352mkdir build && \
353cd build && \
354CXXFLAGS=-std=c++17 cmake {cmake_flags} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \
355make -j{proc_count} && \
356make install
357
Patrick Williams2abc4a42021-02-03 06:11:40 -0600358FROM openbmc-base as {pkg_stagename('catchorg/Catch2')}
Patrick Williams83394612021-02-03 07:12:50 -0600359{pkg_copycmds('catchorg/Catch2')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600360RUN curl -L {pkg_url('catchorg/Catch2')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600361cd Catch2-* && \
362mkdir build && \
363cd build && \
364cmake {cmake_flags} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \
365make -j{proc_count} && \
366make install
367
Patrick Williams2abc4a42021-02-03 06:11:40 -0600368FROM openbmc-base as {pkg_stagename('USCiLab/cereal')}
Patrick Williams83394612021-02-03 07:12:50 -0600369{pkg_copycmds('USCiLab/cereal')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600370RUN curl -L {pkg_url('USCiLab/cereal')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600371cp -a cereal-*/include/cereal/ {prefix}/include/
372
Patrick Williams2abc4a42021-02-03 06:11:40 -0600373FROM openbmc-base as {pkg_stagename('CLIUtils/CLI11')}
Patrick Williams83394612021-02-03 07:12:50 -0600374{pkg_copycmds('CLIUtils/CLI11')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600375RUN curl -L {pkg_url('CLIUtils/CLI11')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600376cd CLI11-* && \
377mkdir build && \
378cd build && \
379cmake {cmake_flags} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \
380make -j{proc_count} && \
381make install
382
Patrick Williams2abc4a42021-02-03 06:11:40 -0600383FROM openbmc-base as {pkg_stagename('fmtlib/fmt')}
Patrick Williams83394612021-02-03 07:12:50 -0600384{pkg_copycmds('fmtlib/fmt')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600385RUN curl -L {pkg_url('fmtlib/fmt')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600386cd fmt-* && \
387mkdir build && \
388cd build && \
389cmake {cmake_flags} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \
390make -j{proc_count} && \
391make install
392
Patrick Williams2abc4a42021-02-03 06:11:40 -0600393FROM openbmc-base as {pkg_stagename('nlohmann/json')}
Patrick Williams83394612021-02-03 07:12:50 -0600394{pkg_copycmds('nlohmann/json')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600395RUN curl -L {pkg_url('nlohmann/json')} | tar -xz && \
396cd json-* && \
397mkdir {prefix}/include/nlohmann && \
398cp include/nlohmann/json.hpp {prefix}/include/nlohmann && \
399ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp
Patrick Williams02871c92021-02-01 20:57:19 -0600400
Patrick Williams2abc4a42021-02-03 06:11:40 -0600401FROM openbmc-base as {pkg_stagename('nlohmann/fifo_map')}
Patrick Williams83394612021-02-03 07:12:50 -0600402{pkg_copycmds('nlohmann/fifo_map')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600403RUN curl -L {pkg_url('nlohmann/fifo_map')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600404cd fifo_map-*/src && cp fifo_map.hpp {prefix}/include/
405
Patrick Williams2abc4a42021-02-03 06:11:40 -0600406FROM openbmc-base as {pkg_stagename('martinmoene/span-lite')}
Patrick Williams83394612021-02-03 07:12:50 -0600407{pkg_copycmds('martinmoene/span-lite')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600408RUN curl -L {pkg_url('martinmoene/span-lite')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600409cd span-lite-* && \
410mkdir build && \
411cd build && \
412cmake {cmake_flags} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \
413make -j{proc_count} && \
414make install
415
Patrick Williams2abc4a42021-02-03 06:11:40 -0600416FROM openbmc-base as {pkg_stagename('openbmc/linux')}
Patrick Williams83394612021-02-03 07:12:50 -0600417{pkg_copycmds('openbmc/linux')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600418RUN curl -L {pkg_url('openbmc/linux')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600419cd linux-* && \
420make -j{proc_count} defconfig && \
421make INSTALL_HDR_PATH=/usr/local headers_install
422
Patrick Williamse1398742021-02-02 12:20:20 -0600423FROM openbmc-base as {pkg_stagename('boost')}
Patrick Williams83394612021-02-03 07:12:50 -0600424{pkg_copycmds('boost')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600425RUN curl -L {pkg_url('boost')} | tar -xj && \
Patrick Williams02871c92021-02-01 20:57:19 -0600426cd boost_*/ && \
427./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine && \
428./b2 && ./b2 install --prefix={prefix}
429
Patrick Williams2abc4a42021-02-03 06:11:40 -0600430FROM openbmc-base as {pkg_stagename('leethomason/tinyxml2')}
Patrick Williams83394612021-02-03 07:12:50 -0600431{pkg_copycmds('leethomason/tinyxml2')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600432RUN curl -L {pkg_url('leethomason/tinyxml2')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600433cd tinyxml2-* && \
434mkdir build && \
435cd build && \
436cmake {cmake_flags} .. && \
437make -j{proc_count} && \
438make install
439
Patrick Williams2abc4a42021-02-03 06:11:40 -0600440FROM openbmc-base as {pkg_stagename('CPPAlliance/url')}
Patrick Williams83394612021-02-03 07:12:50 -0600441{pkg_copycmds('CPPAlliance/url')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600442RUN curl -L {pkg_url('CPPAlliance/url')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600443cd url-* && \
444mkdir buildir && \
445cd buildir && \
446cmake {cmake_flags} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \
447make -j{proc_count} && \
448make install
449
Patrick Williams2abc4a42021-02-03 06:11:40 -0600450FROM openbmc-base as {pkg_stagename('tristanpenman/valijson')}
Patrick Williams83394612021-02-03 07:12:50 -0600451{pkg_copycmds('tristanpenman/valijson')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600452RUN curl -L {pkg_url('tristanpenman/valijson')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600453cd valijson-* && \
454mkdir build && \
455cd build && \
456cmake {cmake_flags} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \
457make -j{proc_count} && \
458make install
459
Patrick Williams2abc4a42021-02-03 06:11:40 -0600460FROM openbmc-base as {pkg_stagename('LibVNC/libvncserver')}
Patrick Williams83394612021-02-03 07:12:50 -0600461{pkg_copycmds('LibVNC/libvncserver')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600462RUN curl -L {pkg_url('LibVNC/libvncserver')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600463cd libvncserver-* && \
464mkdir build && \
465cd build && \
466cmake {cmake_flags} .. && \
467make -j{proc_count} && \
468make install
469
Patrick Williamse1398742021-02-02 12:20:20 -0600470FROM openbmc-base as {pkg_stagename('openbmc/stdplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600471{pkg_copycmds('openbmc/stdplus')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600472RUN curl -L {pkg_url('openbmc/stdplus')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600473cd stdplus-* && \
474meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
475ninja -C build && \
476ninja -C build install
477
Patrick Williamse1398742021-02-02 12:20:20 -0600478FROM openbmc-base as {pkg_stagename('openbmc/sdbusplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600479{pkg_copycmds('openbmc/sdbusplus')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600480RUN curl -L {pkg_url('openbmc/sdbusplus')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600481cd sdbusplus-* && \
482cd tools && ./setup.py install --root=/ --prefix={prefix} && \
483cd .. && meson build {meson_flags} -Dtests=disabled -Dexamples=disabled && \
484ninja -C build && \
485ninja -C build install
486
Patrick Williamse1398742021-02-02 12:20:20 -0600487FROM openbmc-base as {pkg_stagename('openbmc/sdeventplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600488{pkg_copycmds('openbmc/sdeventplus')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600489RUN curl -L {pkg_url('openbmc/sdeventplus')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600490cd sdeventplus-* && \
491meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
492ninja -C build && \
493ninja -C build install
494
Patrick Williamse1398742021-02-02 12:20:20 -0600495FROM openbmc-base as {pkg_stagename('openbmc/gpioplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600496{pkg_copycmds('openbmc/gpioplus')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600497RUN curl -L {pkg_url('openbmc/gpioplus')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600498cd gpioplus-* && \
499meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
500ninja -C build && \
501ninja -C build install
502
Patrick Williamse1398742021-02-02 12:20:20 -0600503FROM openbmc-base as {pkg_stagename('openbmc/phosphor-dbus-interfaces')}
Patrick Williams83394612021-02-03 07:12:50 -0600504{pkg_copycmds('openbmc/phosphor-dbus-interfaces')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600505RUN curl -L {pkg_url('openbmc/phosphor-dbus-interfaces')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600506cd phosphor-dbus-interfaces-* && \
507meson build {meson_flags} -Ddata_org_open_power=true -Ddata_com_ibm=true && \
508ninja -C build && \
509ninja -C build install
510
Patrick Williamse1398742021-02-02 12:20:20 -0600511FROM openbmc-base as {pkg_stagename('openbmc/phosphor-logging')}
Patrick Williams83394612021-02-03 07:12:50 -0600512{pkg_copycmds('openbmc/phosphor-logging')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600513RUN curl -L {pkg_url('openbmc/phosphor-logging')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600514cd phosphor-logging-* && \
515./bootstrap.sh && \
516./configure {configure_flags} --enable-metadata-processing YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml && \
517make -j{proc_count} && \
518make install
519
Patrick Williamse1398742021-02-02 12:20:20 -0600520FROM openbmc-base as {pkg_stagename('openbmc/phosphor-objmgr')}
Patrick Williams83394612021-02-03 07:12:50 -0600521{pkg_copycmds('openbmc/phosphor-objmgr')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600522RUN curl -L {pkg_url('openbmc/phosphor-objmgr')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600523cd phosphor-objmgr-* && \
524./bootstrap.sh && \
525./configure {configure_flags} && \
526make -j{proc_count} && \
527make install
528
Patrick Williamse1398742021-02-02 12:20:20 -0600529FROM openbmc-base as {pkg_stagename('open-power/pdbg')}
Patrick Williams83394612021-02-03 07:12:50 -0600530{pkg_copycmds('open-power/pdbg')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600531RUN curl -L {pkg_url('open-power/pdbg')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600532cd pdbg-* && \
533./bootstrap.sh && \
534./configure {configure_flags} && \
535make -j{proc_count} && \
536make install
537
Patrick Williamse1398742021-02-02 12:20:20 -0600538FROM openbmc-base as {pkg_stagename('openbmc/pldm')}
Patrick Williams83394612021-02-03 07:12:50 -0600539{pkg_copycmds('openbmc/pldm')}
Patrick Williams2abc4a42021-02-03 06:11:40 -0600540RUN curl -L {pkg_url('openbmc/pldm')} | tar -xz && \
Patrick Williams02871c92021-02-01 20:57:19 -0600541cd pldm-* && \
542meson build {meson_flags} -Dlibpldm-only=enabled -Doem-ibm=enabled -Dtests=disabled && \
543ninja -C build && \
544ninja -C build install
545
546# Build the final output image
547FROM openbmc-base
548{copy_cmds}
549
550# Some of our infrastructure still relies on the presence of this file
551# even though it is no longer needed to rebuild the docker environment
552# NOTE: The file is sorted to ensure the ordering is stable.
553RUN echo '{depcache}' > /tmp/depcache
554
555# Final configuration for the workspace
556RUN grep -q {gid} /etc/group || groupadd -g {gid} {username}
557RUN mkdir -p "{os.path.dirname(homedir)}"
558RUN grep -q {uid} /etc/passwd || useradd -d {homedir} -m -u {uid} -g {gid} {username}
559RUN sed -i '1iDefaults umask=000' /etc/sudoers
560RUN echo "{username} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
561
562{proxy_cmd}
563
564RUN /bin/bash
565"""
566
567# Do the docker build.
568for line in docker.build(
569 proxy_args,
570 "--network=host",
571 "-t",
572 docker_image_name,
573 "-",
574 _in=dockerfile,
575 _iter=True,
576):
577 print(line, end="", flush=True)