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