blob: 8784d840852b0f6edaced20cda61492d4c8c4c16 [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")
Patrick Williamsaae36d12021-02-04 16:30:04 -060030prefix = "/usr/local"
Patrick Williams02871c92021-02-01 20:57:19 -060031
32# Set up some common variables.
33proc_count = nproc().strip()
34username = os.environ.get("USER")
35homedir = os.environ.get("HOME")
36gid = os.getgid()
37uid = os.getuid()
38
39# Determine the architecture for Docker.
40arch = uname("-m").strip()
41if arch == "ppc64le":
42 docker_base = "ppc64le/"
43elif arch == "x86_64":
44 docker_base = ""
45else:
46 print(f"Unsupported system architecture({arch}) found for docker image")
47 sys.exit(1)
48
Patrick Williams72043242021-02-02 10:31:45 -060049# Packages to include in image.
50packages = {
Patrick Williams2abc4a42021-02-03 06:11:40 -060051 "boost": {
52 "rev": "1.74.0",
53 "url": (
54 lambda pkg, rev: f"https://dl.bintray.com/boostorg/release/{rev}/source/{pkg}_{rev.replace('.', '_')}.tar.bz2"
55 ),
Patrick Williamsaae36d12021-02-04 16:30:04 -060056 "build_type": "custom",
57 "build_steps": [
58 f"./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine",
59 "./b2",
60 f"./b2 install --prefix={prefix}",
61 ],
Patrick Williams2abc4a42021-02-03 06:11:40 -060062 },
Patrick Williamsaae36d12021-02-04 16:30:04 -060063 "USCiLab/cereal": {
64 "rev": "v1.3.0",
65 "build_type": "custom",
66 "build_steps": [f"cp -a include/cereal/ {prefix}/include/"],
67 },
68 "catchorg/Catch2": {
69 "rev": "v2.12.2",
70 "build_type": "cmake",
71 "config_flags": ["-DBUILD_TESTING=OFF", "-DCATCH_INSTALL_DOCS=OFF"],
72 },
73 "CLIUtils/CLI11": {
74 "rev": "v1.9.0",
75 "build_type": "cmake",
76 "config_flags": [
77 "-DBUILD_TESTING=OFF",
78 "-DCLI11_BUILD_DOCS=OFF",
79 "-DCLI11_BUILD_EXAMPLES=OFF",
80 ],
81 },
82 "fmtlib/fmt": {
83 "rev": "6.2.1",
84 "build_type": "cmake",
85 "config_flags": [
86 "-DFMT_DOC=OFF",
87 "-DFMT_TEST=OFF",
88 ],
89 },
Patrick Williams02871c92021-02-01 20:57:19 -060090 # Snapshot from 2020-01-03
Patrick Williamsaae36d12021-02-04 16:30:04 -060091 "Naios/function2": {
92 "rev": "3a0746bf5f601dfed05330aefcb6854354fce07d",
93 "build_type": "custom",
94 "build_steps": [
95 f"mkdir {prefix}/include/function2",
96 f"cp include/function2/function2.hpp {prefix}/include/function2/",
97 ],
98 },
Patrick Williams02871c92021-02-01 20:57:19 -060099 # Snapshot from 2020-02-13
Patrick Williamsaae36d12021-02-04 16:30:04 -0600100 "google/googletest": {
101 "rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5",
102 "build_type": "cmake",
103 "config_env": ["CXXFLAGS=-std=c++17"],
104 "config_flags": ["-DTHREADS_PREFER_PTHREAD_FLAG=ON"],
105 },
Patrick Williams02871c92021-02-01 20:57:19 -0600106 # Release 2020-08-06
Patrick Williamsaae36d12021-02-04 16:30:04 -0600107 "nlohmann/json": {
108 "rev": "v3.9.1",
109 "build_type": "custom",
110 "build_steps": [
111 f"mkdir {prefix}/include/nlohmann",
112 f"cp include/nlohmann/json.hpp {prefix}/include/nlohmann",
113 f"ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp",
114 ],
115 },
Patrick Williams02871c92021-02-01 20:57:19 -0600116 # Snapshot from 2019-05-24
Patrick Williamsaae36d12021-02-04 16:30:04 -0600117 "linux-test-project/lcov": {
118 "rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da",
119 "build_type": "make",
120 },
Patrick Williams02871c92021-02-01 20:57:19 -0600121 # dev-5.0 2019-05-03
Patrick Williamsaae36d12021-02-04 16:30:04 -0600122 "openbmc/linux": {
123 "rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327",
124 "build_type": "custom",
125 "build_steps": [
126 f"make -j{proc_count} defconfig",
127 f"make INSTALL_HDR_PATH={prefix} headers_install",
128 ],
129 },
Patrick Williams02871c92021-02-01 20:57:19 -0600130 # Snapshot from 2019-09-03
Patrick Williamsaae36d12021-02-04 16:30:04 -0600131 "LibVNC/libvncserver": {
132 "rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110",
133 "build_type": "cmake",
134 },
135 "martinmoene/span-lite": {
136 "rev": "v0.7.0",
137 "build_type": "cmake",
138 "config_flags": [
139 "-DSPAN_LITE_OPT_BUILD_TESTS=OFF",
140 ],
141 },
Patrick Williams02871c92021-02-01 20:57:19 -0600142 # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb
Patrick Williamsaae36d12021-02-04 16:30:04 -0600143 "leethomason/tinyxml2": {
144 "rev": "37bc3aca429f0164adf68c23444540b4a24b5778",
145 "build_type": "cmake",
146 },
Patrick Williams02871c92021-02-01 20:57:19 -0600147 # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb
Patrick Williamsaae36d12021-02-04 16:30:04 -0600148 "CPPAlliance/url": {
149 "rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b",
150 "build_type": "cmake",
151 "config_flags": [
152 "-DBOOST_URL_BUILD_EXAMPLES=OFF",
153 "-DBOOST_URL_BUILD_TESTS=OFF",
154 "-DBOOST_URL_STANDALONE=ON",
155 ],
156 },
Patrick Williams02871c92021-02-01 20:57:19 -0600157 # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb
Patrick Williamsaae36d12021-02-04 16:30:04 -0600158 "tristanpenman/valijson": {
159 "rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9",
160 "build_type": "cmake",
161 "config_flags": [
162 "-DBUILD_TESTS=0",
163 "-DINSTALL_HEADERS=1",
164 ],
165 },
Patrick Williams02871c92021-02-01 20:57:19 -0600166 # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb
Patrick Williamsaae36d12021-02-04 16:30:04 -0600167 "nlohmann/fifo_map": {
168 "rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9",
169 "build_type": "custom",
170 "build_steps": [f"cp src/fifo_map.hpp {prefix}/include/"],
171 },
172 "open-power/pdbg": {"build_type": "autoconf"},
173 "openbmc/gpioplus": {
174 "depends": ["openbmc/stdplus"],
175 "build_type": "meson",
176 "config_flags": [
177 "-Dexamples=false",
178 "-Dtests=disabled",
179 ],
180 },
181 "openbmc/phosphor-dbus-interfaces": {
182 "depends": ["openbmc/sdbusplus"],
183 "build_type": "meson",
184 "config_flags": [
185 "-Ddata_com_ibm=true",
186 "-Ddata_org_open_power=true",
187 ],
188 },
Patrick Williams83394612021-02-03 07:12:50 -0600189 "openbmc/phosphor-logging": {
190 "depends": [
191 "USCiLab/cereal",
192 "nlohmann/fifo_map",
193 "openbmc/phosphor-dbus-interfaces",
194 "openbmc/sdbusplus",
195 "openbmc/sdeventplus",
Patrick Williamsaae36d12021-02-04 16:30:04 -0600196 ],
197 "build_type": "autoconf",
198 "config_flags": [
199 "--enable-metadata-processing",
200 f"YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml",
201 ],
Patrick Williams83394612021-02-03 07:12:50 -0600202 },
203 "openbmc/phosphor-objmgr": {
204 "depends": [
205 "boost",
206 "leethomason/tinyxml2",
207 "openbmc/phosphor-logging",
208 "openbmc/sdbusplus",
Patrick Williamsaae36d12021-02-04 16:30:04 -0600209 ],
210 "build_type": "autoconf",
Patrick Williams83394612021-02-03 07:12:50 -0600211 },
212 "openbmc/pldm": {
213 "depends": [
214 "CLIUtils/CLI11",
215 "boost",
216 "nlohmann/json",
217 "openbmc/phosphor-dbus-interfaces",
218 "openbmc/phosphor-logging",
219 "openbmc/sdbusplus",
220 "openbmc/sdeventplus",
Patrick Williamsaae36d12021-02-04 16:30:04 -0600221 ],
222 "build_type": "meson",
223 "config_flags": [
224 "-Dlibpldm-only=enabled",
225 "-Doem-ibm=enabled",
226 "-Dtests=disabled",
227 ],
Patrick Williams83394612021-02-03 07:12:50 -0600228 },
Patrick Williamsaae36d12021-02-04 16:30:04 -0600229 "openbmc/sdbusplus": {
230 "build_type": "meson",
231 "custom_post_dl": [
232 "cd tools",
233 f"./setup.py install --root=/ --prefix={prefix}",
234 "cd ..",
235 ],
236 "config_flags": [
237 "-Dexamples=disabled",
238 "-Dtests=disabled",
239 ],
240 },
241 "openbmc/sdeventplus": {
242 "depends": ["Naios/function2", "openbmc/stdplus"],
243 "build_type": "meson",
244 "config_flags": [
245 "-Dexamples=false",
246 "-Dtests=disabled",
247 ],
248 },
249 "openbmc/stdplus": {
250 "depends": ["fmtlib/fmt", "martinmoene/span-lite"],
251 "build_type": "meson",
252 "config_flags": [
253 "-Dexamples=false",
254 "-Dtests=disabled",
255 ],
256 },
Patrick Williams02871c92021-02-01 20:57:19 -0600257}
258
Patrick Williams2abc4a42021-02-03 06:11:40 -0600259
Patrick Williams72043242021-02-02 10:31:45 -0600260def pkg_rev(pkg):
261 return packages[pkg]["rev"]
262
Patrick Williams2abc4a42021-02-03 06:11:40 -0600263
Patrick Williamse1398742021-02-02 12:20:20 -0600264def pkg_stagename(pkg):
265 if not pkg.startswith("openbmc/"):
266 pkg = "openbmc/" + pkg
267 return pkg.replace("/", "-")
Patrick Williams72043242021-02-02 10:31:45 -0600268
Patrick Williams2abc4a42021-02-03 06:11:40 -0600269
270def pkg_url(pkg):
271 if "url" in packages[pkg]:
272 return packages[pkg]["url"](pkg, pkg_rev(pkg))
273 return f"https://github.com/{pkg}/archive/{pkg_rev(pkg)}.tar.gz"
274
275
Patrick Williamsaae36d12021-02-04 16:30:04 -0600276def pkg_download(pkg):
277 url = pkg_url(pkg)
278 if ".tar." not in url:
279 raise NotImplementedError(f"Unhandled download type for {pkg}: {url}")
280 cmd = f"curl -L {url} | tar -x"
281 if url.endswith(".bz2"):
282 cmd += "j"
283 if url.endswith(".gz"):
284 cmd += "z"
285 return cmd
286
287
Patrick Williams83394612021-02-03 07:12:50 -0600288def pkg_copycmds(pkg=None):
289 pkgs = []
290 if pkg:
291 if "depends" not in packages[pkg]:
292 return ""
293 pkgs = sorted(packages[pkg]["depends"])
294 else:
295 pkgs = sorted(packages.keys())
296
297 copy_cmds = ""
298 for p in pkgs:
299 copy_cmds += f"COPY --from={pkg_stagename(p)} {prefix} {prefix}\n"
300 # Workaround for upstream docker bug and multiple COPY cmds
301 # https://github.com/moby/moby/issues/37965
302 copy_cmds += "RUN true\n"
303 return copy_cmds
304
305
Patrick Williamsaae36d12021-02-04 16:30:04 -0600306def pkg_cd_srcdir(pkg):
307 return f"cd {pkg.split('/')[-1]}* && "
308
309
310def pkg_build(pkg):
311 result = f"RUN {pkg_download(pkg)} && "
312 result += pkg_cd_srcdir(pkg)
313
314 if "custom_post_dl" in packages[pkg]:
315 result += " && ".join(packages[pkg]["custom_post_dl"]) + " && "
316
317 build_type = packages[pkg]["build_type"]
318 if build_type == "autoconf":
319 result += pkg_build_autoconf(pkg)
320 elif build_type == "cmake":
321 result += pkg_build_cmake(pkg)
322 elif build_type == "custom":
323 result += pkg_build_custom(pkg)
324 elif build_type == "make":
325 result += pkg_build_make(pkg)
326 elif build_type == "meson":
327 result += pkg_build_meson(pkg)
328 else:
329 raise NotImplementedError(
330 f"Unhandled build type for {pkg}: {packages[pkg]['build_type']}"
331 )
332
333 return result
334
335
336def pkg_build_autoconf(pkg):
337 options = " ".join(packages[pkg].get("config_flags", []))
338 env = " ".join(packages[pkg].get("config_env", []))
339 result = "./bootstrap.sh && "
340 result += f"{env} ./configure {configure_flags} {options} && "
341 result += f"make -j{proc_count} && "
342 result += "make install "
343 return result
344
345
346def pkg_build_cmake(pkg):
347 options = " ".join(packages[pkg].get("config_flags", []))
348 env = " ".join(packages[pkg].get("config_env", []))
349 result = "mkdir builddir && cd builddir && "
350 result += f"{env} cmake {cmake_flags} {options} .. && "
351 result += f"make -j{proc_count} && "
352 result += f"make install &&"
353 result += "cd .. "
354 return result
355
356
357def pkg_build_custom(pkg):
358 return " && ".join(packages[pkg].get("build_steps", []))
359
360
361def pkg_build_make(pkg):
362 result = f"make -j{proc_count} && "
363 result += "make install "
364 return result
365
366
367def pkg_build_meson(pkg):
368 options = " ".join(packages[pkg].get("config_flags", []))
369 env = " ".join(packages[pkg].get("config_env", []))
370 result = f"{env} meson builddir {meson_flags} {options} && "
371 result += "ninja -C builddir && ninja -C builddir install "
372 return result
373
374
Patrick Williams72043242021-02-02 10:31:45 -0600375# Look up the HEAD for missing a static rev.
Patrick Williams02871c92021-02-01 20:57:19 -0600376pkg_lookups = {}
Patrick Williams72043242021-02-02 10:31:45 -0600377for pkg in packages.keys():
378 if "rev" in packages[pkg]:
379 continue
Patrick Williams02871c92021-02-01 20:57:19 -0600380 pkg_lookups[pkg] = git(
381 "ls-remote", "--heads", f"https://github.com/{pkg}", _bg=True
382 )
383for pkg, result in pkg_lookups.items():
384 for line in result.stdout.decode().split("\n"):
385 if f"refs/heads/{branch}" in line:
Patrick Williams72043242021-02-02 10:31:45 -0600386 packages[pkg]["rev"] = line.strip().split()[0]
387 elif "refs/heads/master" in line and p not in packages:
388 packages[pkg]["rev"] = line.strip().split()[0]
Patrick Williams02871c92021-02-01 20:57:19 -0600389
390# Create the contents of the '/tmp/depcache'.
391# This needs to be sorted for consistency.
392depcache = ""
Patrick Williams72043242021-02-02 10:31:45 -0600393for pkg in sorted(packages.keys()):
394 depcache += "%s:%s," % (pkg, pkg_rev(pkg))
Patrick Williams02871c92021-02-01 20:57:19 -0600395
396# Define common flags used for builds
Patrick Williams02871c92021-02-01 20:57:19 -0600397configure_flags = " ".join(
398 [
399 f"--prefix={prefix}",
400 ]
401)
402cmake_flags = " ".join(
403 [
404 "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
405 "-DBUILD_SHARED_LIBS=ON",
406 f"-DCMAKE_INSTALL_PREFIX:PATH={prefix}",
407 ]
408)
409meson_flags = " ".join(
410 [
411 "--wrap-mode=nodownload",
412 f"-Dprefix={prefix}",
413 ]
414)
415
Patrick Williams02871c92021-02-01 20:57:19 -0600416# Build the commands needed to compose our final image
417# We must sort the packages, otherwise we might produce an unstable
418# docker file and rebuild the image unnecessarily
Patrick Williams83394612021-02-03 07:12:50 -0600419copy_cmds = pkg_copycmds()
Patrick Williams02871c92021-02-01 20:57:19 -0600420
421# Special flags if setting up a deb mirror.
422mirror = ""
423if "ubuntu" in distro and ubuntu_mirror:
424 mirror = f"""
425RUN echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME) main restricted universe multiverse" > /etc/apt/sources.list && \\
426 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-updates main restricted universe multiverse" >> /etc/apt/sources.list && \\
427 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-security main restricted universe multiverse" >> /etc/apt/sources.list && \\
428 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-proposed main restricted universe multiverse" >> /etc/apt/sources.list && \\
429 echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-backports main restricted universe multiverse" >> /etc/apt/sources.list
430"""
431
432# Special flags for proxying.
433proxy_cmd = ""
434proxy_args = []
435if http_proxy:
436 proxy_cmd = f"""
437RUN echo "[http]" >> {homedir}/.gitconfig && \
438 echo "proxy = {http_proxy}" >> {homedir}/.gitconfig
439"""
440 proxy_args.extend(
441 [
442 "--build-arg",
443 f"http_proxy={http_proxy}",
444 "--build-arg",
445 "https_proxy={https_proxy}",
446 ]
447 )
448
449# Create docker image that can run package unit tests
450dockerfile = f"""
451FROM {docker_base}{distro} as openbmc-base
452
453{mirror}
454
455ENV DEBIAN_FRONTEND noninteractive
456
457ENV PYTHONPATH "/usr/local/lib/python3.8/site-packages/"
458
459# We need the keys to be imported for dbgsym repos
460# New releases have a package, older ones fall back to manual fetching
461# https://wiki.ubuntu.com/Debug%20Symbol%20Packages
462RUN apt-get update && ( apt-get install ubuntu-dbgsym-keyring || ( apt-get install -yy dirmngr && \
463 apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622 ) )
464
465# Parse the current repo list into a debug repo list
466RUN sed -n '/^deb /s,^deb [^ ]* ,deb http://ddebs.ubuntu.com ,p' /etc/apt/sources.list >/etc/apt/sources.list.d/debug.list
467
468# Remove non-existent debug repos
469RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list
470
471RUN cat /etc/apt/sources.list.d/debug.list
472
473RUN apt-get update && apt-get dist-upgrade -yy && apt-get install -yy \
474 gcc-10 \
475 g++-10 \
476 libc6-dbg \
477 libc6-dev \
478 libtool \
479 bison \
480 libdbus-1-dev \
481 flex \
482 cmake \
483 python3 \
484 python3-dev\
485 python3-yaml \
486 python3-mako \
487 python3-pip \
488 python3-setuptools \
489 python3-git \
490 python3-socks \
491 pkg-config \
492 autoconf \
493 autoconf-archive \
494 libsystemd-dev \
495 systemd \
496 libssl-dev \
497 libevdev-dev \
498 libevdev2-dbgsym \
499 libjpeg-dev \
500 libpng-dev \
501 ninja-build \
502 sudo \
503 curl \
504 git \
505 dbus \
506 iputils-ping \
507 clang-10 \
508 clang-format-10 \
509 clang-tidy-10 \
510 clang-tools-10 \
511 shellcheck \
512 npm \
513 iproute2 \
514 libnl-3-dev \
515 libnl-genl-3-dev \
516 libconfig++-dev \
517 libsnmp-dev \
518 valgrind \
519 valgrind-dbg \
520 libpam0g-dev \
521 xxd \
522 libi2c-dev \
523 wget \
524 libldap2-dev \
525 libprotobuf-dev \
526 libperlio-gzip-perl \
527 libjson-perl \
528 protobuf-compiler \
529 libgpiod-dev \
530 device-tree-compiler \
531 cppcheck \
532 libpciaccess-dev \
533 libmimetic-dev \
534 libxml2-utils \
535 libxml-simple-perl
536
537RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 1000 \
538 --slave /usr/bin/g++ g++ /usr/bin/g++-10 \
539 --slave /usr/bin/gcov gcov /usr/bin/gcov-10 \
540 --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \
541 --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10
542
543
544RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \
545 --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \
546 --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \
547 --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \
548 --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py
549
550RUN pip3 install inflection
551RUN pip3 install pycodestyle
552RUN pip3 install jsonschema
553RUN pip3 install meson==0.54.3
554RUN pip3 install protobuf
555
Patrick Williams2abc4a42021-02-03 06:11:40 -0600556FROM openbmc-base as {pkg_stagename('linux-test-project/lcov')}
Patrick Williams83394612021-02-03 07:12:50 -0600557{pkg_copycmds('linux-test-project/lcov')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600558{pkg_build('linux-test-project/lcov')}
Patrick Williams02871c92021-02-01 20:57:19 -0600559
Patrick Williams2abc4a42021-02-03 06:11:40 -0600560FROM openbmc-base as {pkg_stagename('Naios/function2')}
Patrick Williams83394612021-02-03 07:12:50 -0600561{pkg_copycmds('Naios/function2')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600562{pkg_build('Naios/function2')}
Patrick Williams02871c92021-02-01 20:57:19 -0600563
Patrick Williams2abc4a42021-02-03 06:11:40 -0600564FROM openbmc-base as {pkg_stagename('google/googletest')}
Patrick Williams83394612021-02-03 07:12:50 -0600565{pkg_copycmds('google/googletest')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600566{pkg_build('google/googletest')}
Patrick Williams02871c92021-02-01 20:57:19 -0600567
Patrick Williams2abc4a42021-02-03 06:11:40 -0600568FROM openbmc-base as {pkg_stagename('catchorg/Catch2')}
Patrick Williams83394612021-02-03 07:12:50 -0600569{pkg_copycmds('catchorg/Catch2')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600570{pkg_build('catchorg/Catch2')}
Patrick Williams02871c92021-02-01 20:57:19 -0600571
Patrick Williams2abc4a42021-02-03 06:11:40 -0600572FROM openbmc-base as {pkg_stagename('USCiLab/cereal')}
Patrick Williams83394612021-02-03 07:12:50 -0600573{pkg_copycmds('USCiLab/cereal')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600574{pkg_build('USCiLab/cereal')}
Patrick Williams02871c92021-02-01 20:57:19 -0600575
Patrick Williams2abc4a42021-02-03 06:11:40 -0600576FROM openbmc-base as {pkg_stagename('CLIUtils/CLI11')}
Patrick Williams83394612021-02-03 07:12:50 -0600577{pkg_copycmds('CLIUtils/CLI11')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600578{pkg_build('CLIUtils/CLI11')}
Patrick Williams02871c92021-02-01 20:57:19 -0600579
Patrick Williams2abc4a42021-02-03 06:11:40 -0600580FROM openbmc-base as {pkg_stagename('fmtlib/fmt')}
Patrick Williams83394612021-02-03 07:12:50 -0600581{pkg_copycmds('fmtlib/fmt')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600582{pkg_build('fmtlib/fmt')}
Patrick Williams02871c92021-02-01 20:57:19 -0600583
Patrick Williams2abc4a42021-02-03 06:11:40 -0600584FROM openbmc-base as {pkg_stagename('nlohmann/json')}
Patrick Williams83394612021-02-03 07:12:50 -0600585{pkg_copycmds('nlohmann/json')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600586{pkg_build('nlohmann/json')}
Patrick Williams02871c92021-02-01 20:57:19 -0600587
Patrick Williams2abc4a42021-02-03 06:11:40 -0600588FROM openbmc-base as {pkg_stagename('nlohmann/fifo_map')}
Patrick Williams83394612021-02-03 07:12:50 -0600589{pkg_copycmds('nlohmann/fifo_map')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600590{pkg_build('nlohmann/fifo_map')}
Patrick Williams02871c92021-02-01 20:57:19 -0600591
Patrick Williams2abc4a42021-02-03 06:11:40 -0600592FROM openbmc-base as {pkg_stagename('martinmoene/span-lite')}
Patrick Williams83394612021-02-03 07:12:50 -0600593{pkg_copycmds('martinmoene/span-lite')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600594{pkg_build('martinmoene/span-lite')}
Patrick Williams02871c92021-02-01 20:57:19 -0600595
Patrick Williams2abc4a42021-02-03 06:11:40 -0600596FROM openbmc-base as {pkg_stagename('openbmc/linux')}
Patrick Williams83394612021-02-03 07:12:50 -0600597{pkg_copycmds('openbmc/linux')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600598{pkg_build('openbmc/linux')}
Patrick Williams02871c92021-02-01 20:57:19 -0600599
Patrick Williamse1398742021-02-02 12:20:20 -0600600FROM openbmc-base as {pkg_stagename('boost')}
Patrick Williams83394612021-02-03 07:12:50 -0600601{pkg_copycmds('boost')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600602{pkg_build('boost')}
Patrick Williams02871c92021-02-01 20:57:19 -0600603
Patrick Williams2abc4a42021-02-03 06:11:40 -0600604FROM openbmc-base as {pkg_stagename('leethomason/tinyxml2')}
Patrick Williams83394612021-02-03 07:12:50 -0600605{pkg_copycmds('leethomason/tinyxml2')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600606{pkg_build('leethomason/tinyxml2')}
Patrick Williams02871c92021-02-01 20:57:19 -0600607
Patrick Williams2abc4a42021-02-03 06:11:40 -0600608FROM openbmc-base as {pkg_stagename('CPPAlliance/url')}
Patrick Williams83394612021-02-03 07:12:50 -0600609{pkg_copycmds('CPPAlliance/url')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600610{pkg_build('CPPAlliance/url')}
Patrick Williams02871c92021-02-01 20:57:19 -0600611
Patrick Williams2abc4a42021-02-03 06:11:40 -0600612FROM openbmc-base as {pkg_stagename('tristanpenman/valijson')}
Patrick Williams83394612021-02-03 07:12:50 -0600613{pkg_copycmds('tristanpenman/valijson')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600614{pkg_build('tristanpenman/valijson')}
Patrick Williams02871c92021-02-01 20:57:19 -0600615
Patrick Williams2abc4a42021-02-03 06:11:40 -0600616FROM openbmc-base as {pkg_stagename('LibVNC/libvncserver')}
Patrick Williams83394612021-02-03 07:12:50 -0600617{pkg_copycmds('LibVNC/libvncserver')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600618{pkg_build('LibVNC/libvncserver')}
Patrick Williams02871c92021-02-01 20:57:19 -0600619
Patrick Williamse1398742021-02-02 12:20:20 -0600620FROM openbmc-base as {pkg_stagename('openbmc/stdplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600621{pkg_copycmds('openbmc/stdplus')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600622{pkg_build('openbmc/stdplus')}
Patrick Williams02871c92021-02-01 20:57:19 -0600623
Patrick Williamse1398742021-02-02 12:20:20 -0600624FROM openbmc-base as {pkg_stagename('openbmc/sdbusplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600625{pkg_copycmds('openbmc/sdbusplus')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600626{pkg_build('openbmc/sdbusplus')}
Patrick Williams02871c92021-02-01 20:57:19 -0600627
Patrick Williamse1398742021-02-02 12:20:20 -0600628FROM openbmc-base as {pkg_stagename('openbmc/sdeventplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600629{pkg_copycmds('openbmc/sdeventplus')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600630{pkg_build('openbmc/sdeventplus')}
Patrick Williams02871c92021-02-01 20:57:19 -0600631
Patrick Williamse1398742021-02-02 12:20:20 -0600632FROM openbmc-base as {pkg_stagename('openbmc/gpioplus')}
Patrick Williams83394612021-02-03 07:12:50 -0600633{pkg_copycmds('openbmc/gpioplus')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600634{pkg_build('openbmc/gpioplus')}
Patrick Williams02871c92021-02-01 20:57:19 -0600635
Patrick Williamse1398742021-02-02 12:20:20 -0600636FROM openbmc-base as {pkg_stagename('openbmc/phosphor-dbus-interfaces')}
Patrick Williams83394612021-02-03 07:12:50 -0600637{pkg_copycmds('openbmc/phosphor-dbus-interfaces')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600638{pkg_build('openbmc/phosphor-dbus-interfaces')}
Patrick Williams02871c92021-02-01 20:57:19 -0600639
Patrick Williamse1398742021-02-02 12:20:20 -0600640FROM openbmc-base as {pkg_stagename('openbmc/phosphor-logging')}
Patrick Williams83394612021-02-03 07:12:50 -0600641{pkg_copycmds('openbmc/phosphor-logging')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600642{pkg_build('openbmc/phosphor-logging')}
Patrick Williams02871c92021-02-01 20:57:19 -0600643
Patrick Williamse1398742021-02-02 12:20:20 -0600644FROM openbmc-base as {pkg_stagename('openbmc/phosphor-objmgr')}
Patrick Williams83394612021-02-03 07:12:50 -0600645{pkg_copycmds('openbmc/phosphor-objmgr')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600646{pkg_build('openbmc/phosphor-objmgr')}
Patrick Williams02871c92021-02-01 20:57:19 -0600647
Patrick Williamse1398742021-02-02 12:20:20 -0600648FROM openbmc-base as {pkg_stagename('open-power/pdbg')}
Patrick Williams83394612021-02-03 07:12:50 -0600649{pkg_copycmds('open-power/pdbg')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600650{pkg_build('open-power/pdbg')}
Patrick Williams02871c92021-02-01 20:57:19 -0600651
Patrick Williamse1398742021-02-02 12:20:20 -0600652FROM openbmc-base as {pkg_stagename('openbmc/pldm')}
Patrick Williams83394612021-02-03 07:12:50 -0600653{pkg_copycmds('openbmc/pldm')}
Patrick Williamsaae36d12021-02-04 16:30:04 -0600654{pkg_build('openbmc/pldm')}
Patrick Williams02871c92021-02-01 20:57:19 -0600655
656# Build the final output image
657FROM openbmc-base
658{copy_cmds}
659
660# Some of our infrastructure still relies on the presence of this file
661# even though it is no longer needed to rebuild the docker environment
662# NOTE: The file is sorted to ensure the ordering is stable.
663RUN echo '{depcache}' > /tmp/depcache
664
665# Final configuration for the workspace
666RUN grep -q {gid} /etc/group || groupadd -g {gid} {username}
667RUN mkdir -p "{os.path.dirname(homedir)}"
668RUN grep -q {uid} /etc/passwd || useradd -d {homedir} -m -u {uid} -g {gid} {username}
669RUN sed -i '1iDefaults umask=000' /etc/sudoers
670RUN echo "{username} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
671
672{proxy_cmd}
673
674RUN /bin/bash
675"""
676
677# Do the docker build.
678for line in docker.build(
679 proxy_args,
680 "--network=host",
681 "-t",
682 docker_image_name,
683 "-",
684 _in=dockerfile,
685 _iter=True,
686):
687 print(line, end="", flush=True)