Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame^] | 1 | #!/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 | |
| 20 | import os |
| 21 | import sys |
| 22 | from sh import docker, git, nproc, uname |
| 23 | |
| 24 | # Read a bunch of environment variables. |
| 25 | docker_image_name = os.environ.get("DOCKER_IMAGE_NAME", "openbmc/ubuntu-unit-test") |
| 26 | distro = os.environ.get("DISTRO", "ubuntu:focal") |
| 27 | branch = os.environ.get("BRANCH", "master") |
| 28 | ubuntu_mirror = os.environ.get("UBUNTU_MIRROR") |
| 29 | http_proxy = os.environ.get("http_proxy") |
| 30 | |
| 31 | # Set up some common variables. |
| 32 | proc_count = nproc().strip() |
| 33 | username = os.environ.get("USER") |
| 34 | homedir = os.environ.get("HOME") |
| 35 | gid = os.getgid() |
| 36 | uid = os.getuid() |
| 37 | |
| 38 | # Determine the architecture for Docker. |
| 39 | arch = uname("-m").strip() |
| 40 | if arch == "ppc64le": |
| 41 | docker_base = "ppc64le/" |
| 42 | elif arch == "x86_64": |
| 43 | docker_base = "" |
| 44 | else: |
| 45 | print(f"Unsupported system architecture({arch}) found for docker image") |
| 46 | sys.exit(1) |
| 47 | |
| 48 | # These packages we use 'HEAD' for. |
| 49 | head_pkgs = [ |
| 50 | "openbmc/phosphor-objmgr", |
| 51 | "openbmc/sdbusplus", |
| 52 | "openbmc/sdeventplus", |
| 53 | "openbmc/stdplus", |
| 54 | "openbmc/gpioplus", |
| 55 | "openbmc/phosphor-logging", |
| 56 | "openbmc/phosphor-dbus-interfaces", |
| 57 | "open-power/pdbg", |
| 58 | "openbmc/pldm", |
| 59 | ] |
| 60 | |
| 61 | # Packages with fixed revisions. |
| 62 | pkg_rev = { |
| 63 | "boost": "1.74.0", |
| 64 | "cereal": "v1.3.0", |
| 65 | "catch2": "v2.12.2", |
| 66 | "CLI11": "v1.9.0", |
| 67 | "fmt": "6.2.1", |
| 68 | # Snapshot from 2020-01-03 |
| 69 | "function2": "3a0746bf5f601dfed05330aefcb6854354fce07d", |
| 70 | # Snapshot from 2020-02-13 |
| 71 | "googletest": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5", |
| 72 | # Release 2020-08-06 |
| 73 | "json": "v3.9.1", |
| 74 | # Snapshot from 2019-05-24 |
| 75 | "lcov": "75fbae1cfc5027f818a0bb865bf6f96fab3202da", |
| 76 | # dev-5.0 2019-05-03 |
| 77 | "linux-headers": "8bf6567e77f7aa68975b7c9c6d044bba690bf327", |
| 78 | # Snapshot from 2019-09-03 |
| 79 | "libvncserver": "1354f7f1bb6962dab209eddb9d6aac1f03408110", |
| 80 | "span-lite": "v0.7.0", |
| 81 | # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb |
| 82 | "tinyxml2": "37bc3aca429f0164adf68c23444540b4a24b5778", |
| 83 | # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb |
| 84 | "boost-url": "a56ae0df6d3078319755fbaa67822b4fa7fd352b", |
| 85 | # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb |
| 86 | "valijson": "c2f22fddf599d04dc33fcd7ed257c698a05345d9", |
| 87 | # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb |
| 88 | "fifo_map": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9", |
| 89 | } |
| 90 | |
| 91 | # Look up the HEAD for 'head_pkgs' and insert them into 'pkg_rev'. |
| 92 | pkg_lookups = {} |
| 93 | for pkg in head_pkgs: |
| 94 | pkg_lookups[pkg] = git( |
| 95 | "ls-remote", "--heads", f"https://github.com/{pkg}", _bg=True |
| 96 | ) |
| 97 | for pkg, result in pkg_lookups.items(): |
| 98 | for line in result.stdout.decode().split("\n"): |
| 99 | if f"refs/heads/{branch}" in line: |
| 100 | pkg_rev[pkg] = line.strip().split()[0] |
| 101 | elif "refs/heads/master" in line and p not in pkg_rev: |
| 102 | pkg_rev[pkg] = line.strip().split()[0] |
| 103 | |
| 104 | # Create the contents of the '/tmp/depcache'. |
| 105 | # This needs to be sorted for consistency. |
| 106 | depcache = "" |
| 107 | for pkg in sorted(head_pkgs): |
| 108 | if pkg in pkg_rev: |
| 109 | depcache += "%s:%s," % (pkg, pkg_rev[pkg]) |
| 110 | |
| 111 | # Define common flags used for builds |
| 112 | prefix = "/usr/local" |
| 113 | configure_flags = " ".join( |
| 114 | [ |
| 115 | f"--prefix={prefix}", |
| 116 | ] |
| 117 | ) |
| 118 | cmake_flags = " ".join( |
| 119 | [ |
| 120 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo", |
| 121 | "-DBUILD_SHARED_LIBS=ON", |
| 122 | f"-DCMAKE_INSTALL_PREFIX:PATH={prefix}", |
| 123 | ] |
| 124 | ) |
| 125 | meson_flags = " ".join( |
| 126 | [ |
| 127 | "--wrap-mode=nodownload", |
| 128 | f"-Dprefix={prefix}", |
| 129 | ] |
| 130 | ) |
| 131 | |
| 132 | |
| 133 | def stagename(name): |
| 134 | if not name.startswith("openbmc/"): |
| 135 | name = "openbmc/" + name |
| 136 | return name.replace("/", "-") |
| 137 | |
| 138 | |
| 139 | # Build the commands needed to compose our final image |
| 140 | # We must sort the packages, otherwise we might produce an unstable |
| 141 | # docker file and rebuild the image unnecessarily |
| 142 | copy_cmds = "" |
| 143 | for pkg in sorted(pkg_rev.keys()): |
| 144 | copy_cmds += f"COPY --from={stagename(pkg)} {prefix} {prefix}\n" |
| 145 | # Workaround for upstream docker bug and multiple COPY cmds |
| 146 | # https://github.com/moby/moby/issues/37965 |
| 147 | copy_cmds += "RUN true\n" |
| 148 | |
| 149 | # Special flags if setting up a deb mirror. |
| 150 | mirror = "" |
| 151 | if "ubuntu" in distro and ubuntu_mirror: |
| 152 | mirror = f""" |
| 153 | RUN echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME) main restricted universe multiverse" > /etc/apt/sources.list && \\ |
| 154 | echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-updates main restricted universe multiverse" >> /etc/apt/sources.list && \\ |
| 155 | echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-security main restricted universe multiverse" >> /etc/apt/sources.list && \\ |
| 156 | echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-proposed main restricted universe multiverse" >> /etc/apt/sources.list && \\ |
| 157 | echo "deb {ubuntu_mirror} $(. /etc/os-release && echo $VERSION_CODENAME)-backports main restricted universe multiverse" >> /etc/apt/sources.list |
| 158 | """ |
| 159 | |
| 160 | # Special flags for proxying. |
| 161 | proxy_cmd = "" |
| 162 | proxy_args = [] |
| 163 | if http_proxy: |
| 164 | proxy_cmd = f""" |
| 165 | RUN echo "[http]" >> {homedir}/.gitconfig && \ |
| 166 | echo "proxy = {http_proxy}" >> {homedir}/.gitconfig |
| 167 | """ |
| 168 | proxy_args.extend( |
| 169 | [ |
| 170 | "--build-arg", |
| 171 | f"http_proxy={http_proxy}", |
| 172 | "--build-arg", |
| 173 | "https_proxy={https_proxy}", |
| 174 | ] |
| 175 | ) |
| 176 | |
| 177 | # Create docker image that can run package unit tests |
| 178 | dockerfile = f""" |
| 179 | FROM {docker_base}{distro} as openbmc-base |
| 180 | |
| 181 | {mirror} |
| 182 | |
| 183 | ENV DEBIAN_FRONTEND noninteractive |
| 184 | |
| 185 | ENV PYTHONPATH "/usr/local/lib/python3.8/site-packages/" |
| 186 | |
| 187 | # We need the keys to be imported for dbgsym repos |
| 188 | # New releases have a package, older ones fall back to manual fetching |
| 189 | # https://wiki.ubuntu.com/Debug%20Symbol%20Packages |
| 190 | RUN apt-get update && ( apt-get install ubuntu-dbgsym-keyring || ( apt-get install -yy dirmngr && \ |
| 191 | apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F2EDC64DC5AEE1F6B9C621F0C8CAB6595FDFF622 ) ) |
| 192 | |
| 193 | # Parse the current repo list into a debug repo list |
| 194 | RUN sed -n '/^deb /s,^deb [^ ]* ,deb http://ddebs.ubuntu.com ,p' /etc/apt/sources.list >/etc/apt/sources.list.d/debug.list |
| 195 | |
| 196 | # Remove non-existent debug repos |
| 197 | RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list |
| 198 | |
| 199 | RUN cat /etc/apt/sources.list.d/debug.list |
| 200 | |
| 201 | RUN apt-get update && apt-get dist-upgrade -yy && apt-get install -yy \ |
| 202 | gcc-10 \ |
| 203 | g++-10 \ |
| 204 | libc6-dbg \ |
| 205 | libc6-dev \ |
| 206 | libtool \ |
| 207 | bison \ |
| 208 | libdbus-1-dev \ |
| 209 | flex \ |
| 210 | cmake \ |
| 211 | python3 \ |
| 212 | python3-dev\ |
| 213 | python3-yaml \ |
| 214 | python3-mako \ |
| 215 | python3-pip \ |
| 216 | python3-setuptools \ |
| 217 | python3-git \ |
| 218 | python3-socks \ |
| 219 | pkg-config \ |
| 220 | autoconf \ |
| 221 | autoconf-archive \ |
| 222 | libsystemd-dev \ |
| 223 | systemd \ |
| 224 | libssl-dev \ |
| 225 | libevdev-dev \ |
| 226 | libevdev2-dbgsym \ |
| 227 | libjpeg-dev \ |
| 228 | libpng-dev \ |
| 229 | ninja-build \ |
| 230 | sudo \ |
| 231 | curl \ |
| 232 | git \ |
| 233 | dbus \ |
| 234 | iputils-ping \ |
| 235 | clang-10 \ |
| 236 | clang-format-10 \ |
| 237 | clang-tidy-10 \ |
| 238 | clang-tools-10 \ |
| 239 | shellcheck \ |
| 240 | npm \ |
| 241 | iproute2 \ |
| 242 | libnl-3-dev \ |
| 243 | libnl-genl-3-dev \ |
| 244 | libconfig++-dev \ |
| 245 | libsnmp-dev \ |
| 246 | valgrind \ |
| 247 | valgrind-dbg \ |
| 248 | libpam0g-dev \ |
| 249 | xxd \ |
| 250 | libi2c-dev \ |
| 251 | wget \ |
| 252 | libldap2-dev \ |
| 253 | libprotobuf-dev \ |
| 254 | libperlio-gzip-perl \ |
| 255 | libjson-perl \ |
| 256 | protobuf-compiler \ |
| 257 | libgpiod-dev \ |
| 258 | device-tree-compiler \ |
| 259 | cppcheck \ |
| 260 | libpciaccess-dev \ |
| 261 | libmimetic-dev \ |
| 262 | libxml2-utils \ |
| 263 | libxml-simple-perl |
| 264 | |
| 265 | RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 1000 \ |
| 266 | --slave /usr/bin/g++ g++ /usr/bin/g++-10 \ |
| 267 | --slave /usr/bin/gcov gcov /usr/bin/gcov-10 \ |
| 268 | --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-dump-10 \ |
| 269 | --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-tool-10 |
| 270 | |
| 271 | |
| 272 | RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-10 1000 \ |
| 273 | --slave /usr/bin/clang++ clang++ /usr/bin/clang++-10 \ |
| 274 | --slave /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-10 \ |
| 275 | --slave /usr/bin/clang-format clang-format /usr/bin/clang-format-10 \ |
| 276 | --slave /usr/bin/run-clang-tidy.py run-clang-tidy.py /usr/bin/run-clang-tidy-10.py |
| 277 | |
| 278 | RUN pip3 install inflection |
| 279 | RUN pip3 install pycodestyle |
| 280 | RUN pip3 install jsonschema |
| 281 | RUN pip3 install meson==0.54.3 |
| 282 | RUN pip3 install protobuf |
| 283 | |
| 284 | FROM openbmc-base as openbmc-lcov |
| 285 | RUN curl -L https://github.com/linux-test-project/lcov/archive/{pkg_rev['lcov']}.tar.gz | tar -xz && \ |
| 286 | cd lcov-* && \ |
| 287 | make -j{proc_count} && \ |
| 288 | make install |
| 289 | |
| 290 | FROM openbmc-base as openbmc-function2 |
| 291 | RUN mkdir {prefix}/include/function2 && \ |
| 292 | curl -L -o {prefix}/include/function2/function2.hpp https://raw.githubusercontent.com/Naios/function2/{pkg_rev['function2']}/include/function2/function2.hpp |
| 293 | |
| 294 | FROM openbmc-base as openbmc-googletest |
| 295 | RUN curl -L https://github.com/google/googletest/archive/{pkg_rev['googletest']}.tar.gz | tar -xz && \ |
| 296 | cd googletest-* && \ |
| 297 | mkdir build && \ |
| 298 | cd build && \ |
| 299 | CXXFLAGS=-std=c++17 cmake {cmake_flags} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \ |
| 300 | make -j{proc_count} && \ |
| 301 | make install |
| 302 | |
| 303 | FROM openbmc-base as openbmc-catch2 |
| 304 | RUN curl -L https://github.com/catchorg/Catch2/archive/{pkg_rev['catch2']}.tar.gz | tar -xz && \ |
| 305 | cd Catch2-* && \ |
| 306 | mkdir build && \ |
| 307 | cd build && \ |
| 308 | cmake {cmake_flags} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \ |
| 309 | make -j{proc_count} && \ |
| 310 | make install |
| 311 | |
| 312 | FROM openbmc-base as openbmc-cereal |
| 313 | RUN curl -L https://github.com/USCiLab/cereal/archive/{pkg_rev['cereal']}.tar.gz | tar -xz && \ |
| 314 | cp -a cereal-*/include/cereal/ {prefix}/include/ |
| 315 | |
| 316 | FROM openbmc-base as openbmc-CLI11 |
| 317 | RUN curl -L https://github.com/CLIUtils/CLI11/archive/{pkg_rev['CLI11']}.tar.gz | tar -xz && \ |
| 318 | cd CLI11-* && \ |
| 319 | mkdir build && \ |
| 320 | cd build && \ |
| 321 | cmake {cmake_flags} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \ |
| 322 | make -j{proc_count} && \ |
| 323 | make install |
| 324 | |
| 325 | FROM openbmc-base as openbmc-fmt |
| 326 | RUN curl -L https://github.com/fmtlib/fmt/archive/{pkg_rev['fmt']}.tar.gz | tar -xz && \ |
| 327 | cd fmt-* && \ |
| 328 | mkdir build && \ |
| 329 | cd build && \ |
| 330 | cmake {cmake_flags} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \ |
| 331 | make -j{proc_count} && \ |
| 332 | make install |
| 333 | |
| 334 | FROM openbmc-base as openbmc-json |
| 335 | RUN mkdir {prefix}/include/nlohmann/ && \ |
| 336 | curl -L -o {prefix}/include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/{pkg_rev['json']}/json.hpp && \ |
| 337 | ln -s nlohmann/json.hpp {prefix}/include/json.hpp |
| 338 | |
| 339 | FROM openbmc-base as openbmc-fifo_map |
| 340 | RUN curl -L https://github.com/nlohmann/fifo_map/archive/{pkg_rev['fifo_map']}.tar.gz | tar -xz && \ |
| 341 | cd fifo_map-*/src && cp fifo_map.hpp {prefix}/include/ |
| 342 | |
| 343 | FROM openbmc-base as openbmc-span-lite |
| 344 | RUN curl -L https://github.com/martinmoene/span-lite/archive/{pkg_rev['span-lite']}.tar.gz | tar -xz && \ |
| 345 | cd span-lite-* && \ |
| 346 | mkdir build && \ |
| 347 | cd build && \ |
| 348 | cmake {cmake_flags} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \ |
| 349 | make -j{proc_count} && \ |
| 350 | make install |
| 351 | |
| 352 | FROM openbmc-base as openbmc-linux-headers |
| 353 | RUN curl -L https://github.com/openbmc/linux/archive/{pkg_rev['linux-headers']}.tar.gz | tar -xz && \ |
| 354 | cd linux-* && \ |
| 355 | make -j{proc_count} defconfig && \ |
| 356 | make INSTALL_HDR_PATH=/usr/local headers_install |
| 357 | |
| 358 | FROM openbmc-base as openbmc-boost |
| 359 | RUN curl -L https://dl.bintray.com/boostorg/release/{pkg_rev['boost']}/source/boost_$(echo "{pkg_rev['boost']}" | tr '.' '_').tar.bz2 | tar -xj && \ |
| 360 | cd boost_*/ && \ |
| 361 | ./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine && \ |
| 362 | ./b2 && ./b2 install --prefix={prefix} |
| 363 | |
| 364 | FROM openbmc-base as openbmc-tinyxml2 |
| 365 | RUN curl -L https://github.com/leethomason/tinyxml2/archive/{pkg_rev['tinyxml2']}.tar.gz | tar -xz && \ |
| 366 | cd tinyxml2-* && \ |
| 367 | mkdir build && \ |
| 368 | cd build && \ |
| 369 | cmake {cmake_flags} .. && \ |
| 370 | make -j{proc_count} && \ |
| 371 | make install |
| 372 | |
| 373 | FROM openbmc-base as openbmc-boost-url |
| 374 | RUN curl -L https://github.com/CPPAlliance/url/archive/{pkg_rev['boost-url']}.tar.gz | tar -xz && \ |
| 375 | cd url-* && \ |
| 376 | mkdir buildir && \ |
| 377 | cd buildir && \ |
| 378 | cmake {cmake_flags} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \ |
| 379 | make -j{proc_count} && \ |
| 380 | make install |
| 381 | |
| 382 | FROM openbmc-base as openbmc-valijson |
| 383 | RUN curl -L https://github.com/tristanpenman/valijson/archive/{pkg_rev['valijson']}.tar.gz | tar -xz && \ |
| 384 | cd valijson-* && \ |
| 385 | mkdir build && \ |
| 386 | cd build && \ |
| 387 | cmake {cmake_flags} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \ |
| 388 | make -j{proc_count} && \ |
| 389 | make install |
| 390 | |
| 391 | FROM openbmc-base as openbmc-libvncserver |
| 392 | RUN curl -L https://github.com/LibVNC/libvncserver/archive/{pkg_rev['libvncserver']}.tar.gz | tar -xz && \ |
| 393 | cd libvncserver-* && \ |
| 394 | mkdir build && \ |
| 395 | cd build && \ |
| 396 | cmake {cmake_flags} .. && \ |
| 397 | make -j{proc_count} && \ |
| 398 | make install |
| 399 | |
| 400 | FROM openbmc-base as openbmc-stdplus |
| 401 | COPY --from=openbmc-fmt {prefix} {prefix} |
| 402 | COPY --from=openbmc-span-lite {prefix} {prefix} |
| 403 | RUN curl -L https://github.com/openbmc/stdplus/archive/{pkg_rev['openbmc/stdplus']}.tar.gz | tar -xz && \ |
| 404 | cd stdplus-* && \ |
| 405 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 406 | ninja -C build && \ |
| 407 | ninja -C build install |
| 408 | |
| 409 | FROM openbmc-base as openbmc-sdbusplus |
| 410 | RUN curl -L https://github.com/openbmc/sdbusplus/archive/{pkg_rev['openbmc/sdbusplus']}.tar.gz | tar -xz && \ |
| 411 | cd sdbusplus-* && \ |
| 412 | cd tools && ./setup.py install --root=/ --prefix={prefix} && \ |
| 413 | cd .. && meson build {meson_flags} -Dtests=disabled -Dexamples=disabled && \ |
| 414 | ninja -C build && \ |
| 415 | ninja -C build install |
| 416 | |
| 417 | FROM openbmc-base as openbmc-sdeventplus |
| 418 | COPY --from=openbmc-function2 {prefix} {prefix} |
| 419 | COPY --from=openbmc-stdplus {prefix} {prefix} |
| 420 | RUN curl -L https://github.com/openbmc/sdeventplus/archive/{pkg_rev['openbmc/sdeventplus']}.tar.gz | tar -xz && \ |
| 421 | cd sdeventplus-* && \ |
| 422 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 423 | ninja -C build && \ |
| 424 | ninja -C build install |
| 425 | |
| 426 | FROM openbmc-base as openbmc-gpioplus |
| 427 | COPY --from=openbmc-stdplus {prefix} {prefix} |
| 428 | RUN curl -L https://github.com/openbmc/gpioplus/archive/{pkg_rev['openbmc/gpioplus']}.tar.gz | tar -xz && \ |
| 429 | cd gpioplus-* && \ |
| 430 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 431 | ninja -C build && \ |
| 432 | ninja -C build install |
| 433 | |
| 434 | FROM openbmc-base as openbmc-phosphor-dbus-interfaces |
| 435 | COPY --from=openbmc-sdbusplus {prefix} {prefix} |
| 436 | RUN curl -L https://github.com/openbmc/phosphor-dbus-interfaces/archive/{pkg_rev['openbmc/phosphor-dbus-interfaces']}.tar.gz | tar -xz && \ |
| 437 | cd phosphor-dbus-interfaces-* && \ |
| 438 | meson build {meson_flags} -Ddata_org_open_power=true -Ddata_com_ibm=true && \ |
| 439 | ninja -C build && \ |
| 440 | ninja -C build install |
| 441 | |
| 442 | FROM openbmc-base as openbmc-phosphor-logging |
| 443 | COPY --from=openbmc-cereal {prefix} {prefix} |
| 444 | COPY --from=openbmc-sdbusplus {prefix} {prefix} |
| 445 | COPY --from=openbmc-sdeventplus {prefix} {prefix} |
| 446 | COPY --from=openbmc-phosphor-dbus-interfaces {prefix} {prefix} |
| 447 | COPY --from=openbmc-fifo_map {prefix} {prefix} |
| 448 | RUN curl -L https://github.com/openbmc/phosphor-logging/archive/{pkg_rev['openbmc/phosphor-logging']}.tar.gz | tar -xz && \ |
| 449 | cd phosphor-logging-* && \ |
| 450 | ./bootstrap.sh && \ |
| 451 | ./configure {configure_flags} --enable-metadata-processing YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml && \ |
| 452 | make -j{proc_count} && \ |
| 453 | make install |
| 454 | |
| 455 | FROM openbmc-base as openbmc-phosphor-objmgr |
| 456 | COPY --from=openbmc-boost {prefix} {prefix} |
| 457 | COPY --from=openbmc-sdbusplus {prefix} {prefix} |
| 458 | COPY --from=openbmc-tinyxml2 {prefix} {prefix} |
| 459 | COPY --from=openbmc-phosphor-logging {prefix} {prefix} |
| 460 | RUN curl -L https://github.com/openbmc/phosphor-objmgr/archive/{pkg_rev['openbmc/phosphor-objmgr']}.tar.gz | tar -xz && \ |
| 461 | cd phosphor-objmgr-* && \ |
| 462 | ./bootstrap.sh && \ |
| 463 | ./configure {configure_flags} && \ |
| 464 | make -j{proc_count} && \ |
| 465 | make install |
| 466 | |
| 467 | FROM openbmc-base as openbmc-open-power-pdbg |
| 468 | RUN curl -L https://github.com/open-power/pdbg/archive/{pkg_rev['open-power/pdbg']}.tar.gz | tar -xz && \ |
| 469 | cd pdbg-* && \ |
| 470 | ./bootstrap.sh && \ |
| 471 | ./configure {configure_flags} && \ |
| 472 | make -j{proc_count} && \ |
| 473 | make install |
| 474 | |
| 475 | FROM openbmc-base as openbmc-pldm |
| 476 | COPY --from=openbmc-sdbusplus {prefix} {prefix} |
| 477 | COPY --from=openbmc-sdeventplus {prefix} {prefix} |
| 478 | COPY --from=openbmc-boost {prefix} {prefix} |
| 479 | COPY --from=openbmc-phosphor-dbus-interfaces {prefix} {prefix} |
| 480 | COPY --from=openbmc-phosphor-logging {prefix} {prefix} |
| 481 | COPY --from=openbmc-json {prefix} {prefix} |
| 482 | COPY --from=openbmc-CLI11 {prefix} {prefix} |
| 483 | RUN curl -L https://github.com/openbmc/pldm/archive/{pkg_rev['openbmc/pldm']}.tar.gz | tar -xz && \ |
| 484 | cd pldm-* && \ |
| 485 | meson build {meson_flags} -Dlibpldm-only=enabled -Doem-ibm=enabled -Dtests=disabled && \ |
| 486 | ninja -C build && \ |
| 487 | ninja -C build install |
| 488 | |
| 489 | # Build the final output image |
| 490 | FROM openbmc-base |
| 491 | {copy_cmds} |
| 492 | |
| 493 | # Some of our infrastructure still relies on the presence of this file |
| 494 | # even though it is no longer needed to rebuild the docker environment |
| 495 | # NOTE: The file is sorted to ensure the ordering is stable. |
| 496 | RUN echo '{depcache}' > /tmp/depcache |
| 497 | |
| 498 | # Final configuration for the workspace |
| 499 | RUN grep -q {gid} /etc/group || groupadd -g {gid} {username} |
| 500 | RUN mkdir -p "{os.path.dirname(homedir)}" |
| 501 | RUN grep -q {uid} /etc/passwd || useradd -d {homedir} -m -u {uid} -g {gid} {username} |
| 502 | RUN sed -i '1iDefaults umask=000' /etc/sudoers |
| 503 | RUN echo "{username} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers |
| 504 | |
| 505 | {proxy_cmd} |
| 506 | |
| 507 | RUN /bin/bash |
| 508 | """ |
| 509 | |
| 510 | # Do the docker build. |
| 511 | for line in docker.build( |
| 512 | proxy_args, |
| 513 | "--network=host", |
| 514 | "-t", |
| 515 | docker_image_name, |
| 516 | "-", |
| 517 | _in=dockerfile, |
| 518 | _iter=True, |
| 519 | ): |
| 520 | print(line, end="", flush=True) |