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 | |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 48 | # Packages to include in image. |
| 49 | packages = { |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 50 | "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 Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 60 | # Snapshot from 2020-01-03 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 61 | "Naios/function2": {"rev": "3a0746bf5f601dfed05330aefcb6854354fce07d"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 62 | # Snapshot from 2020-02-13 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 63 | "google/googletest": {"rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 64 | # Release 2020-08-06 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 65 | "nlohmann/json": {"rev": "v3.9.1"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 66 | # Snapshot from 2019-05-24 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 67 | "linux-test-project/lcov": {"rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 68 | # dev-5.0 2019-05-03 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 69 | "openbmc/linux": {"rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 70 | # Snapshot from 2019-09-03 |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 71 | "LibVNC/libvncserver": {"rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110"}, |
| 72 | "martinmoene/span-lite": {"rev": "v0.7.0"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 73 | # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 74 | "leethomason/tinyxml2": {"rev": "37bc3aca429f0164adf68c23444540b4a24b5778"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 75 | # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 76 | "CPPAlliance/url": {"rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 77 | # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 78 | "tristanpenman/valijson": {"rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9"}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 79 | # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 80 | "nlohmann/fifo_map": {"rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9"}, |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 81 | "open-power/pdbg": {}, |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 82 | "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 Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 112 | "openbmc/sdbusplus": {}, |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 113 | "openbmc/sdeventplus": {"depends": ["Naios/function2", "openbmc/stdplus"]}, |
| 114 | "openbmc/stdplus": {"depends": ["fmtlib/fmt", "martinmoene/span-lite"]}, |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 115 | } |
| 116 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 117 | |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 118 | def pkg_rev(pkg): |
| 119 | return packages[pkg]["rev"] |
| 120 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 121 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 122 | def pkg_stagename(pkg): |
| 123 | if not pkg.startswith("openbmc/"): |
| 124 | pkg = "openbmc/" + pkg |
| 125 | return pkg.replace("/", "-") |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 126 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 127 | |
| 128 | def 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 Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 134 | def 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 Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 152 | # Look up the HEAD for missing a static rev. |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 153 | pkg_lookups = {} |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 154 | for pkg in packages.keys(): |
| 155 | if "rev" in packages[pkg]: |
| 156 | continue |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 157 | pkg_lookups[pkg] = git( |
| 158 | "ls-remote", "--heads", f"https://github.com/{pkg}", _bg=True |
| 159 | ) |
| 160 | for pkg, result in pkg_lookups.items(): |
| 161 | for line in result.stdout.decode().split("\n"): |
| 162 | if f"refs/heads/{branch}" in line: |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 163 | 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 Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 166 | |
| 167 | # Create the contents of the '/tmp/depcache'. |
| 168 | # This needs to be sorted for consistency. |
| 169 | depcache = "" |
Patrick Williams | 7204324 | 2021-02-02 10:31:45 -0600 | [diff] [blame] | 170 | for pkg in sorted(packages.keys()): |
| 171 | depcache += "%s:%s," % (pkg, pkg_rev(pkg)) |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 172 | |
| 173 | # Define common flags used for builds |
| 174 | prefix = "/usr/local" |
| 175 | configure_flags = " ".join( |
| 176 | [ |
| 177 | f"--prefix={prefix}", |
| 178 | ] |
| 179 | ) |
| 180 | cmake_flags = " ".join( |
| 181 | [ |
| 182 | "-DCMAKE_BUILD_TYPE=RelWithDebInfo", |
| 183 | "-DBUILD_SHARED_LIBS=ON", |
| 184 | f"-DCMAKE_INSTALL_PREFIX:PATH={prefix}", |
| 185 | ] |
| 186 | ) |
| 187 | meson_flags = " ".join( |
| 188 | [ |
| 189 | "--wrap-mode=nodownload", |
| 190 | f"-Dprefix={prefix}", |
| 191 | ] |
| 192 | ) |
| 193 | |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 194 | # 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 Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 197 | copy_cmds = pkg_copycmds() |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 198 | |
| 199 | # Special flags if setting up a deb mirror. |
| 200 | mirror = "" |
| 201 | if "ubuntu" in distro and ubuntu_mirror: |
| 202 | mirror = f""" |
| 203 | RUN 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. |
| 211 | proxy_cmd = "" |
| 212 | proxy_args = [] |
| 213 | if http_proxy: |
| 214 | proxy_cmd = f""" |
| 215 | RUN 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 |
| 228 | dockerfile = f""" |
| 229 | FROM {docker_base}{distro} as openbmc-base |
| 230 | |
| 231 | {mirror} |
| 232 | |
| 233 | ENV DEBIAN_FRONTEND noninteractive |
| 234 | |
| 235 | ENV 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 |
| 240 | RUN 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 |
| 244 | RUN 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 |
| 247 | RUN sed -i '/-\(backports\|security\) /d' /etc/apt/sources.list.d/debug.list |
| 248 | |
| 249 | RUN cat /etc/apt/sources.list.d/debug.list |
| 250 | |
| 251 | RUN 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 | |
| 315 | RUN 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 | |
| 322 | RUN 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 | |
| 328 | RUN pip3 install inflection |
| 329 | RUN pip3 install pycodestyle |
| 330 | RUN pip3 install jsonschema |
| 331 | RUN pip3 install meson==0.54.3 |
| 332 | RUN pip3 install protobuf |
| 333 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 334 | FROM openbmc-base as {pkg_stagename('linux-test-project/lcov')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 335 | {pkg_copycmds('linux-test-project/lcov')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 336 | RUN curl -L {pkg_url('linux-test-project/lcov')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 337 | cd lcov-* && \ |
| 338 | make -j{proc_count} && \ |
| 339 | make install |
| 340 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 341 | FROM openbmc-base as {pkg_stagename('Naios/function2')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 342 | {pkg_copycmds('Naios/function2')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 343 | RUN curl -L {pkg_url('Naios/function2')} | tar -xz && \ |
| 344 | cd function2-* && \ |
| 345 | mkdir {prefix}/include/function2 && \ |
| 346 | cp include/function2/function2.hpp {prefix}/include/function2/ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 347 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 348 | FROM openbmc-base as {pkg_stagename('google/googletest')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 349 | {pkg_copycmds('google/googletest')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 350 | RUN curl -L {pkg_url('google/googletest')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 351 | cd googletest-* && \ |
| 352 | mkdir build && \ |
| 353 | cd build && \ |
| 354 | CXXFLAGS=-std=c++17 cmake {cmake_flags} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \ |
| 355 | make -j{proc_count} && \ |
| 356 | make install |
| 357 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 358 | FROM openbmc-base as {pkg_stagename('catchorg/Catch2')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 359 | {pkg_copycmds('catchorg/Catch2')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 360 | RUN curl -L {pkg_url('catchorg/Catch2')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 361 | cd Catch2-* && \ |
| 362 | mkdir build && \ |
| 363 | cd build && \ |
| 364 | cmake {cmake_flags} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \ |
| 365 | make -j{proc_count} && \ |
| 366 | make install |
| 367 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 368 | FROM openbmc-base as {pkg_stagename('USCiLab/cereal')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 369 | {pkg_copycmds('USCiLab/cereal')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 370 | RUN curl -L {pkg_url('USCiLab/cereal')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 371 | cp -a cereal-*/include/cereal/ {prefix}/include/ |
| 372 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 373 | FROM openbmc-base as {pkg_stagename('CLIUtils/CLI11')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 374 | {pkg_copycmds('CLIUtils/CLI11')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 375 | RUN curl -L {pkg_url('CLIUtils/CLI11')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 376 | cd CLI11-* && \ |
| 377 | mkdir build && \ |
| 378 | cd build && \ |
| 379 | cmake {cmake_flags} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \ |
| 380 | make -j{proc_count} && \ |
| 381 | make install |
| 382 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 383 | FROM openbmc-base as {pkg_stagename('fmtlib/fmt')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 384 | {pkg_copycmds('fmtlib/fmt')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 385 | RUN curl -L {pkg_url('fmtlib/fmt')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 386 | cd fmt-* && \ |
| 387 | mkdir build && \ |
| 388 | cd build && \ |
| 389 | cmake {cmake_flags} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \ |
| 390 | make -j{proc_count} && \ |
| 391 | make install |
| 392 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 393 | FROM openbmc-base as {pkg_stagename('nlohmann/json')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 394 | {pkg_copycmds('nlohmann/json')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 395 | RUN curl -L {pkg_url('nlohmann/json')} | tar -xz && \ |
| 396 | cd json-* && \ |
| 397 | mkdir {prefix}/include/nlohmann && \ |
| 398 | cp include/nlohmann/json.hpp {prefix}/include/nlohmann && \ |
| 399 | ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 400 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 401 | FROM openbmc-base as {pkg_stagename('nlohmann/fifo_map')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 402 | {pkg_copycmds('nlohmann/fifo_map')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 403 | RUN curl -L {pkg_url('nlohmann/fifo_map')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 404 | cd fifo_map-*/src && cp fifo_map.hpp {prefix}/include/ |
| 405 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 406 | FROM openbmc-base as {pkg_stagename('martinmoene/span-lite')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 407 | {pkg_copycmds('martinmoene/span-lite')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 408 | RUN curl -L {pkg_url('martinmoene/span-lite')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 409 | cd span-lite-* && \ |
| 410 | mkdir build && \ |
| 411 | cd build && \ |
| 412 | cmake {cmake_flags} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \ |
| 413 | make -j{proc_count} && \ |
| 414 | make install |
| 415 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 416 | FROM openbmc-base as {pkg_stagename('openbmc/linux')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 417 | {pkg_copycmds('openbmc/linux')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 418 | RUN curl -L {pkg_url('openbmc/linux')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 419 | cd linux-* && \ |
| 420 | make -j{proc_count} defconfig && \ |
| 421 | make INSTALL_HDR_PATH=/usr/local headers_install |
| 422 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 423 | FROM openbmc-base as {pkg_stagename('boost')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 424 | {pkg_copycmds('boost')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 425 | RUN curl -L {pkg_url('boost')} | tar -xj && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 426 | cd boost_*/ && \ |
| 427 | ./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine && \ |
| 428 | ./b2 && ./b2 install --prefix={prefix} |
| 429 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 430 | FROM openbmc-base as {pkg_stagename('leethomason/tinyxml2')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 431 | {pkg_copycmds('leethomason/tinyxml2')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 432 | RUN curl -L {pkg_url('leethomason/tinyxml2')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 433 | cd tinyxml2-* && \ |
| 434 | mkdir build && \ |
| 435 | cd build && \ |
| 436 | cmake {cmake_flags} .. && \ |
| 437 | make -j{proc_count} && \ |
| 438 | make install |
| 439 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 440 | FROM openbmc-base as {pkg_stagename('CPPAlliance/url')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 441 | {pkg_copycmds('CPPAlliance/url')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 442 | RUN curl -L {pkg_url('CPPAlliance/url')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 443 | cd url-* && \ |
| 444 | mkdir buildir && \ |
| 445 | cd buildir && \ |
| 446 | cmake {cmake_flags} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \ |
| 447 | make -j{proc_count} && \ |
| 448 | make install |
| 449 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 450 | FROM openbmc-base as {pkg_stagename('tristanpenman/valijson')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 451 | {pkg_copycmds('tristanpenman/valijson')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 452 | RUN curl -L {pkg_url('tristanpenman/valijson')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 453 | cd valijson-* && \ |
| 454 | mkdir build && \ |
| 455 | cd build && \ |
| 456 | cmake {cmake_flags} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \ |
| 457 | make -j{proc_count} && \ |
| 458 | make install |
| 459 | |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 460 | FROM openbmc-base as {pkg_stagename('LibVNC/libvncserver')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 461 | {pkg_copycmds('LibVNC/libvncserver')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 462 | RUN curl -L {pkg_url('LibVNC/libvncserver')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 463 | cd libvncserver-* && \ |
| 464 | mkdir build && \ |
| 465 | cd build && \ |
| 466 | cmake {cmake_flags} .. && \ |
| 467 | make -j{proc_count} && \ |
| 468 | make install |
| 469 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 470 | FROM openbmc-base as {pkg_stagename('openbmc/stdplus')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 471 | {pkg_copycmds('openbmc/stdplus')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 472 | RUN curl -L {pkg_url('openbmc/stdplus')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 473 | cd stdplus-* && \ |
| 474 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 475 | ninja -C build && \ |
| 476 | ninja -C build install |
| 477 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 478 | FROM openbmc-base as {pkg_stagename('openbmc/sdbusplus')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 479 | {pkg_copycmds('openbmc/sdbusplus')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 480 | RUN curl -L {pkg_url('openbmc/sdbusplus')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 481 | cd sdbusplus-* && \ |
| 482 | cd tools && ./setup.py install --root=/ --prefix={prefix} && \ |
| 483 | cd .. && meson build {meson_flags} -Dtests=disabled -Dexamples=disabled && \ |
| 484 | ninja -C build && \ |
| 485 | ninja -C build install |
| 486 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 487 | FROM openbmc-base as {pkg_stagename('openbmc/sdeventplus')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 488 | {pkg_copycmds('openbmc/sdeventplus')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 489 | RUN curl -L {pkg_url('openbmc/sdeventplus')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 490 | cd sdeventplus-* && \ |
| 491 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 492 | ninja -C build && \ |
| 493 | ninja -C build install |
| 494 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 495 | FROM openbmc-base as {pkg_stagename('openbmc/gpioplus')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 496 | {pkg_copycmds('openbmc/gpioplus')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 497 | RUN curl -L {pkg_url('openbmc/gpioplus')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 498 | cd gpioplus-* && \ |
| 499 | meson build {meson_flags} -Dtests=disabled -Dexamples=false && \ |
| 500 | ninja -C build && \ |
| 501 | ninja -C build install |
| 502 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 503 | FROM openbmc-base as {pkg_stagename('openbmc/phosphor-dbus-interfaces')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 504 | {pkg_copycmds('openbmc/phosphor-dbus-interfaces')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 505 | RUN curl -L {pkg_url('openbmc/phosphor-dbus-interfaces')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 506 | cd phosphor-dbus-interfaces-* && \ |
| 507 | meson build {meson_flags} -Ddata_org_open_power=true -Ddata_com_ibm=true && \ |
| 508 | ninja -C build && \ |
| 509 | ninja -C build install |
| 510 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 511 | FROM openbmc-base as {pkg_stagename('openbmc/phosphor-logging')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 512 | {pkg_copycmds('openbmc/phosphor-logging')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 513 | RUN curl -L {pkg_url('openbmc/phosphor-logging')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 514 | cd phosphor-logging-* && \ |
| 515 | ./bootstrap.sh && \ |
| 516 | ./configure {configure_flags} --enable-metadata-processing YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml && \ |
| 517 | make -j{proc_count} && \ |
| 518 | make install |
| 519 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 520 | FROM openbmc-base as {pkg_stagename('openbmc/phosphor-objmgr')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 521 | {pkg_copycmds('openbmc/phosphor-objmgr')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 522 | RUN curl -L {pkg_url('openbmc/phosphor-objmgr')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 523 | cd phosphor-objmgr-* && \ |
| 524 | ./bootstrap.sh && \ |
| 525 | ./configure {configure_flags} && \ |
| 526 | make -j{proc_count} && \ |
| 527 | make install |
| 528 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 529 | FROM openbmc-base as {pkg_stagename('open-power/pdbg')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 530 | {pkg_copycmds('open-power/pdbg')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 531 | RUN curl -L {pkg_url('open-power/pdbg')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 532 | cd pdbg-* && \ |
| 533 | ./bootstrap.sh && \ |
| 534 | ./configure {configure_flags} && \ |
| 535 | make -j{proc_count} && \ |
| 536 | make install |
| 537 | |
Patrick Williams | e139874 | 2021-02-02 12:20:20 -0600 | [diff] [blame] | 538 | FROM openbmc-base as {pkg_stagename('openbmc/pldm')} |
Patrick Williams | 8339461 | 2021-02-03 07:12:50 -0600 | [diff] [blame^] | 539 | {pkg_copycmds('openbmc/pldm')} |
Patrick Williams | 2abc4a4 | 2021-02-03 06:11:40 -0600 | [diff] [blame] | 540 | RUN curl -L {pkg_url('openbmc/pldm')} | tar -xz && \ |
Patrick Williams | 02871c9 | 2021-02-01 20:57:19 -0600 | [diff] [blame] | 541 | cd pldm-* && \ |
| 542 | meson build {meson_flags} -Dlibpldm-only=enabled -Doem-ibm=enabled -Dtests=disabled && \ |
| 543 | ninja -C build && \ |
| 544 | ninja -C build install |
| 545 | |
| 546 | # Build the final output image |
| 547 | FROM 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. |
| 553 | RUN echo '{depcache}' > /tmp/depcache |
| 554 | |
| 555 | # Final configuration for the workspace |
| 556 | RUN grep -q {gid} /etc/group || groupadd -g {gid} {username} |
| 557 | RUN mkdir -p "{os.path.dirname(homedir)}" |
| 558 | RUN grep -q {uid} /etc/passwd || useradd -d {homedir} -m -u {uid} -g {gid} {username} |
| 559 | RUN sed -i '1iDefaults umask=000' /etc/sudoers |
| 560 | RUN echo "{username} ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers |
| 561 | |
| 562 | {proxy_cmd} |
| 563 | |
| 564 | RUN /bin/bash |
| 565 | """ |
| 566 | |
| 567 | # Do the docker build. |
| 568 | for 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) |