build-unit-test-docker: templatize build directives

Create 'pkg_build' function that generates the docker RUN template
necessary to build all the packages.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie7e7a3b3e78c67e6d97a83f3b43c3c54d10b77e6
diff --git a/scripts/build-unit-test-docker b/scripts/build-unit-test-docker
index f8053d3..8784d84 100755
--- a/scripts/build-unit-test-docker
+++ b/scripts/build-unit-test-docker
@@ -27,6 +27,7 @@
 branch = os.environ.get("BRANCH", "master")
 ubuntu_mirror = os.environ.get("UBUNTU_MIRROR")
 http_proxy = os.environ.get("http_proxy")
+prefix = "/usr/local"
 
 # Set up some common variables.
 proc_count = nproc().strip()
@@ -52,35 +53,139 @@
         "url": (
             lambda pkg, rev: f"https://dl.bintray.com/boostorg/release/{rev}/source/{pkg}_{rev.replace('.', '_')}.tar.bz2"
         ),
+        "build_type": "custom",
+        "build_steps": [
+            f"./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine",
+            "./b2",
+            f"./b2 install --prefix={prefix}",
+        ],
     },
-    "USCiLab/cereal": {"rev": "v1.3.0"},
-    "catchorg/Catch2": {"rev": "v2.12.2"},
-    "CLIUtils/CLI11": {"rev": "v1.9.0"},
-    "fmtlib/fmt": {"rev": "6.2.1"},
+    "USCiLab/cereal": {
+        "rev": "v1.3.0",
+        "build_type": "custom",
+        "build_steps": [f"cp -a include/cereal/ {prefix}/include/"],
+    },
+    "catchorg/Catch2": {
+        "rev": "v2.12.2",
+        "build_type": "cmake",
+        "config_flags": ["-DBUILD_TESTING=OFF", "-DCATCH_INSTALL_DOCS=OFF"],
+    },
+    "CLIUtils/CLI11": {
+        "rev": "v1.9.0",
+        "build_type": "cmake",
+        "config_flags": [
+            "-DBUILD_TESTING=OFF",
+            "-DCLI11_BUILD_DOCS=OFF",
+            "-DCLI11_BUILD_EXAMPLES=OFF",
+        ],
+    },
+    "fmtlib/fmt": {
+        "rev": "6.2.1",
+        "build_type": "cmake",
+        "config_flags": [
+            "-DFMT_DOC=OFF",
+            "-DFMT_TEST=OFF",
+        ],
+    },
     # Snapshot from 2020-01-03
-    "Naios/function2": {"rev": "3a0746bf5f601dfed05330aefcb6854354fce07d"},
+    "Naios/function2": {
+        "rev": "3a0746bf5f601dfed05330aefcb6854354fce07d",
+        "build_type": "custom",
+        "build_steps": [
+            f"mkdir {prefix}/include/function2",
+            f"cp include/function2/function2.hpp {prefix}/include/function2/",
+        ],
+    },
     # Snapshot from 2020-02-13
-    "google/googletest": {"rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5"},
+    "google/googletest": {
+        "rev": "23b2a3b1cf803999fb38175f6e9e038a4495c8a5",
+        "build_type": "cmake",
+        "config_env": ["CXXFLAGS=-std=c++17"],
+        "config_flags": ["-DTHREADS_PREFER_PTHREAD_FLAG=ON"],
+    },
     # Release 2020-08-06
-    "nlohmann/json": {"rev": "v3.9.1"},
+    "nlohmann/json": {
+        "rev": "v3.9.1",
+        "build_type": "custom",
+        "build_steps": [
+            f"mkdir {prefix}/include/nlohmann",
+            f"cp include/nlohmann/json.hpp {prefix}/include/nlohmann",
+            f"ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp",
+        ],
+    },
     # Snapshot from 2019-05-24
-    "linux-test-project/lcov": {"rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da"},
+    "linux-test-project/lcov": {
+        "rev": "75fbae1cfc5027f818a0bb865bf6f96fab3202da",
+        "build_type": "make",
+    },
     # dev-5.0 2019-05-03
-    "openbmc/linux": {"rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327"},
+    "openbmc/linux": {
+        "rev": "8bf6567e77f7aa68975b7c9c6d044bba690bf327",
+        "build_type": "custom",
+        "build_steps": [
+            f"make -j{proc_count} defconfig",
+            f"make INSTALL_HDR_PATH={prefix} headers_install",
+        ],
+    },
     # Snapshot from 2019-09-03
-    "LibVNC/libvncserver": {"rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110"},
-    "martinmoene/span-lite": {"rev": "v0.7.0"},
+    "LibVNC/libvncserver": {
+        "rev": "1354f7f1bb6962dab209eddb9d6aac1f03408110",
+        "build_type": "cmake",
+    },
+    "martinmoene/span-lite": {
+        "rev": "v0.7.0",
+        "build_type": "cmake",
+        "config_flags": [
+            "-DSPAN_LITE_OPT_BUILD_TESTS=OFF",
+        ],
+    },
     # version from meta-openembedded/meta-oe/recipes-support/libtinyxml2/libtinyxml2_5.0.1.bb
-    "leethomason/tinyxml2": {"rev": "37bc3aca429f0164adf68c23444540b4a24b5778"},
+    "leethomason/tinyxml2": {
+        "rev": "37bc3aca429f0164adf68c23444540b4a24b5778",
+        "build_type": "cmake",
+    },
     # version from /meta-openembedded/meta-oe/recipes-devtools/boost-url/boost-url_git.bb
-    "CPPAlliance/url": {"rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b"},
+    "CPPAlliance/url": {
+        "rev": "a56ae0df6d3078319755fbaa67822b4fa7fd352b",
+        "build_type": "cmake",
+        "config_flags": [
+            "-DBOOST_URL_BUILD_EXAMPLES=OFF",
+            "-DBOOST_URL_BUILD_TESTS=OFF",
+            "-DBOOST_URL_STANDALONE=ON",
+        ],
+    },
     # version from meta-openembedded/meta-oe/recipes-devtools/valijson/valijson_git.bb
-    "tristanpenman/valijson": {"rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9"},
+    "tristanpenman/valijson": {
+        "rev": "c2f22fddf599d04dc33fcd7ed257c698a05345d9",
+        "build_type": "cmake",
+        "config_flags": [
+            "-DBUILD_TESTS=0",
+            "-DINSTALL_HEADERS=1",
+        ],
+    },
     # version from meta-openembedded/meta-oe/recipes-devtools/nlohmann-fifo/nlohmann-fifo_git.bb
-    "nlohmann/fifo_map": {"rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9"},
-    "open-power/pdbg": {},
-    "openbmc/gpioplus": {"depends": ["openbmc/stdplus"]},
-    "openbmc/phosphor-dbus-interfaces": {"depends": ["openbmc/sdbusplus"]},
+    "nlohmann/fifo_map": {
+        "rev": "0dfbf5dacbb15a32c43f912a7e66a54aae39d0f9",
+        "build_type": "custom",
+        "build_steps": [f"cp src/fifo_map.hpp {prefix}/include/"],
+    },
+    "open-power/pdbg": {"build_type": "autoconf"},
+    "openbmc/gpioplus": {
+        "depends": ["openbmc/stdplus"],
+        "build_type": "meson",
+        "config_flags": [
+            "-Dexamples=false",
+            "-Dtests=disabled",
+        ],
+    },
+    "openbmc/phosphor-dbus-interfaces": {
+        "depends": ["openbmc/sdbusplus"],
+        "build_type": "meson",
+        "config_flags": [
+            "-Ddata_com_ibm=true",
+            "-Ddata_org_open_power=true",
+        ],
+    },
     "openbmc/phosphor-logging": {
         "depends": [
             "USCiLab/cereal",
@@ -88,7 +193,12 @@
             "openbmc/phosphor-dbus-interfaces",
             "openbmc/sdbusplus",
             "openbmc/sdeventplus",
-        ]
+        ],
+        "build_type": "autoconf",
+        "config_flags": [
+            "--enable-metadata-processing",
+            f"YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml",
+        ],
     },
     "openbmc/phosphor-objmgr": {
         "depends": [
@@ -96,7 +206,8 @@
             "leethomason/tinyxml2",
             "openbmc/phosphor-logging",
             "openbmc/sdbusplus",
-        ]
+        ],
+        "build_type": "autoconf",
     },
     "openbmc/pldm": {
         "depends": [
@@ -107,11 +218,42 @@
             "openbmc/phosphor-logging",
             "openbmc/sdbusplus",
             "openbmc/sdeventplus",
-        ]
+        ],
+        "build_type": "meson",
+        "config_flags": [
+            "-Dlibpldm-only=enabled",
+            "-Doem-ibm=enabled",
+            "-Dtests=disabled",
+        ],
     },
-    "openbmc/sdbusplus": {},
-    "openbmc/sdeventplus": {"depends": ["Naios/function2", "openbmc/stdplus"]},
-    "openbmc/stdplus": {"depends": ["fmtlib/fmt", "martinmoene/span-lite"]},
+    "openbmc/sdbusplus": {
+        "build_type": "meson",
+        "custom_post_dl": [
+            "cd tools",
+            f"./setup.py install --root=/ --prefix={prefix}",
+            "cd ..",
+        ],
+        "config_flags": [
+            "-Dexamples=disabled",
+            "-Dtests=disabled",
+        ],
+    },
+    "openbmc/sdeventplus": {
+        "depends": ["Naios/function2", "openbmc/stdplus"],
+        "build_type": "meson",
+        "config_flags": [
+            "-Dexamples=false",
+            "-Dtests=disabled",
+        ],
+    },
+    "openbmc/stdplus": {
+        "depends": ["fmtlib/fmt", "martinmoene/span-lite"],
+        "build_type": "meson",
+        "config_flags": [
+            "-Dexamples=false",
+            "-Dtests=disabled",
+        ],
+    },
 }
 
 
@@ -131,6 +273,18 @@
     return f"https://github.com/{pkg}/archive/{pkg_rev(pkg)}.tar.gz"
 
 
+def pkg_download(pkg):
+    url = pkg_url(pkg)
+    if ".tar." not in url:
+        raise NotImplementedError(f"Unhandled download type for {pkg}: {url}")
+    cmd = f"curl -L {url} | tar -x"
+    if url.endswith(".bz2"):
+        cmd += "j"
+    if url.endswith(".gz"):
+        cmd += "z"
+    return cmd
+
+
 def pkg_copycmds(pkg=None):
     pkgs = []
     if pkg:
@@ -149,6 +303,75 @@
     return copy_cmds
 
 
+def pkg_cd_srcdir(pkg):
+    return f"cd {pkg.split('/')[-1]}* && "
+
+
+def pkg_build(pkg):
+    result = f"RUN {pkg_download(pkg)} && "
+    result += pkg_cd_srcdir(pkg)
+
+    if "custom_post_dl" in packages[pkg]:
+        result += " && ".join(packages[pkg]["custom_post_dl"]) + " && "
+
+    build_type = packages[pkg]["build_type"]
+    if build_type == "autoconf":
+        result += pkg_build_autoconf(pkg)
+    elif build_type == "cmake":
+        result += pkg_build_cmake(pkg)
+    elif build_type == "custom":
+        result += pkg_build_custom(pkg)
+    elif build_type == "make":
+        result += pkg_build_make(pkg)
+    elif build_type == "meson":
+        result += pkg_build_meson(pkg)
+    else:
+        raise NotImplementedError(
+            f"Unhandled build type for {pkg}: {packages[pkg]['build_type']}"
+        )
+
+    return result
+
+
+def pkg_build_autoconf(pkg):
+    options = " ".join(packages[pkg].get("config_flags", []))
+    env = " ".join(packages[pkg].get("config_env", []))
+    result = "./bootstrap.sh && "
+    result += f"{env} ./configure {configure_flags} {options} && "
+    result += f"make -j{proc_count} && "
+    result += "make install "
+    return result
+
+
+def pkg_build_cmake(pkg):
+    options = " ".join(packages[pkg].get("config_flags", []))
+    env = " ".join(packages[pkg].get("config_env", []))
+    result = "mkdir builddir && cd builddir && "
+    result += f"{env} cmake {cmake_flags} {options} .. && "
+    result += f"make -j{proc_count} && "
+    result += f"make install &&"
+    result += "cd .. "
+    return result
+
+
+def pkg_build_custom(pkg):
+    return " && ".join(packages[pkg].get("build_steps", []))
+
+
+def pkg_build_make(pkg):
+    result = f"make -j{proc_count} && "
+    result += "make install "
+    return result
+
+
+def pkg_build_meson(pkg):
+    options = " ".join(packages[pkg].get("config_flags", []))
+    env = " ".join(packages[pkg].get("config_env", []))
+    result = f"{env} meson builddir {meson_flags} {options} && "
+    result += "ninja -C builddir && ninja -C builddir install "
+    return result
+
+
 # Look up the HEAD for missing a static rev.
 pkg_lookups = {}
 for pkg in packages.keys():
@@ -171,7 +394,6 @@
     depcache += "%s:%s," % (pkg, pkg_rev(pkg))
 
 # Define common flags used for builds
-prefix = "/usr/local"
 configure_flags = " ".join(
     [
         f"--prefix={prefix}",
@@ -333,215 +555,103 @@
 
 FROM openbmc-base as {pkg_stagename('linux-test-project/lcov')}
 {pkg_copycmds('linux-test-project/lcov')}
-RUN curl -L {pkg_url('linux-test-project/lcov')} | tar -xz && \
-cd lcov-* && \
-make -j{proc_count} && \
-make install
+{pkg_build('linux-test-project/lcov')}
 
 FROM openbmc-base as {pkg_stagename('Naios/function2')}
 {pkg_copycmds('Naios/function2')}
-RUN curl -L {pkg_url('Naios/function2')} | tar -xz && \
-cd function2-* && \
-mkdir {prefix}/include/function2 && \
-cp include/function2/function2.hpp {prefix}/include/function2/
+{pkg_build('Naios/function2')}
 
 FROM openbmc-base as {pkg_stagename('google/googletest')}
 {pkg_copycmds('google/googletest')}
-RUN curl -L {pkg_url('google/googletest')} | tar -xz && \
-cd googletest-* && \
-mkdir build && \
-cd build && \
-CXXFLAGS=-std=c++17 cmake {cmake_flags} -DTHREADS_PREFER_PTHREAD_FLAG=ON .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('google/googletest')}
 
 FROM openbmc-base as {pkg_stagename('catchorg/Catch2')}
 {pkg_copycmds('catchorg/Catch2')}
-RUN curl -L {pkg_url('catchorg/Catch2')} | tar -xz && \
-cd Catch2-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} -DBUILD_TESTING=OFF -DCATCH_INSTALL_DOCS=OFF .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('catchorg/Catch2')}
 
 FROM openbmc-base as {pkg_stagename('USCiLab/cereal')}
 {pkg_copycmds('USCiLab/cereal')}
-RUN curl -L {pkg_url('USCiLab/cereal')} | tar -xz && \
-cp -a cereal-*/include/cereal/ {prefix}/include/
+{pkg_build('USCiLab/cereal')}
 
 FROM openbmc-base as {pkg_stagename('CLIUtils/CLI11')}
 {pkg_copycmds('CLIUtils/CLI11')}
-RUN curl -L {pkg_url('CLIUtils/CLI11')} | tar -xz && \
-cd CLI11-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} -DCLI11_BUILD_DOCS=OFF -DBUILD_TESTING=OFF -DCLI11_BUILD_EXAMPLES=OFF .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('CLIUtils/CLI11')}
 
 FROM openbmc-base as {pkg_stagename('fmtlib/fmt')}
 {pkg_copycmds('fmtlib/fmt')}
-RUN curl -L {pkg_url('fmtlib/fmt')} | tar -xz && \
-cd fmt-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} -DFMT_DOC=OFF -DFMT_TEST=OFF .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('fmtlib/fmt')}
 
 FROM openbmc-base as {pkg_stagename('nlohmann/json')}
 {pkg_copycmds('nlohmann/json')}
-RUN curl -L {pkg_url('nlohmann/json')} | tar -xz && \
-cd json-* && \
-mkdir {prefix}/include/nlohmann && \
-cp include/nlohmann/json.hpp {prefix}/include/nlohmann && \
-ln -s {prefix}/include/nlohmann/json.hpp {prefix}/include/json.hpp
+{pkg_build('nlohmann/json')}
 
 FROM openbmc-base as {pkg_stagename('nlohmann/fifo_map')}
 {pkg_copycmds('nlohmann/fifo_map')}
-RUN curl -L {pkg_url('nlohmann/fifo_map')} | tar -xz && \
-cd fifo_map-*/src && cp fifo_map.hpp {prefix}/include/
+{pkg_build('nlohmann/fifo_map')}
 
 FROM openbmc-base as {pkg_stagename('martinmoene/span-lite')}
 {pkg_copycmds('martinmoene/span-lite')}
-RUN curl -L {pkg_url('martinmoene/span-lite')} | tar -xz && \
-cd span-lite-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} -DSPAN_LITE_OPT_BUILD_TESTS=OFF .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('martinmoene/span-lite')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/linux')}
 {pkg_copycmds('openbmc/linux')}
-RUN curl -L {pkg_url('openbmc/linux')} | tar -xz && \
-cd linux-* && \
-make -j{proc_count} defconfig && \
-make INSTALL_HDR_PATH=/usr/local headers_install
+{pkg_build('openbmc/linux')}
 
 FROM openbmc-base as {pkg_stagename('boost')}
 {pkg_copycmds('boost')}
-RUN curl -L {pkg_url('boost')} | tar -xj && \
-cd boost_*/ && \
-./bootstrap.sh --prefix={prefix} --with-libraries=context,coroutine && \
-./b2 && ./b2 install --prefix={prefix}
+{pkg_build('boost')}
 
 FROM openbmc-base as {pkg_stagename('leethomason/tinyxml2')}
 {pkg_copycmds('leethomason/tinyxml2')}
-RUN curl -L {pkg_url('leethomason/tinyxml2')} | tar -xz && \
-cd tinyxml2-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('leethomason/tinyxml2')}
 
 FROM openbmc-base as {pkg_stagename('CPPAlliance/url')}
 {pkg_copycmds('CPPAlliance/url')}
-RUN curl -L {pkg_url('CPPAlliance/url')} | tar -xz && \
-cd url-* && \
-mkdir buildir && \
-cd buildir && \
-cmake {cmake_flags} -DBOOST_URL_STANDALONE=ON -DBOOST_URL_BUILD_TESTS=OFF -DBOOST_URL_BUILD_EXAMPLES=OFF .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('CPPAlliance/url')}
 
 FROM openbmc-base as {pkg_stagename('tristanpenman/valijson')}
 {pkg_copycmds('tristanpenman/valijson')}
-RUN curl -L {pkg_url('tristanpenman/valijson')} | tar -xz && \
-cd valijson-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} -DINSTALL_HEADERS=1 -DBUILD_TESTS=0 .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('tristanpenman/valijson')}
 
 FROM openbmc-base as {pkg_stagename('LibVNC/libvncserver')}
 {pkg_copycmds('LibVNC/libvncserver')}
-RUN curl -L {pkg_url('LibVNC/libvncserver')} | tar -xz && \
-cd libvncserver-* && \
-mkdir build && \
-cd build && \
-cmake {cmake_flags} .. && \
-make -j{proc_count} && \
-make install
+{pkg_build('LibVNC/libvncserver')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/stdplus')}
 {pkg_copycmds('openbmc/stdplus')}
-RUN curl -L {pkg_url('openbmc/stdplus')} | tar -xz && \
-cd stdplus-* && \
-meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/stdplus')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/sdbusplus')}
 {pkg_copycmds('openbmc/sdbusplus')}
-RUN curl -L {pkg_url('openbmc/sdbusplus')} | tar -xz && \
-cd sdbusplus-* && \
-cd tools && ./setup.py install --root=/ --prefix={prefix} && \
-cd .. && meson build {meson_flags} -Dtests=disabled -Dexamples=disabled && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/sdbusplus')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/sdeventplus')}
 {pkg_copycmds('openbmc/sdeventplus')}
-RUN curl -L {pkg_url('openbmc/sdeventplus')} | tar -xz && \
-cd sdeventplus-* && \
-meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/sdeventplus')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/gpioplus')}
 {pkg_copycmds('openbmc/gpioplus')}
-RUN curl -L {pkg_url('openbmc/gpioplus')} | tar -xz && \
-cd gpioplus-* && \
-meson build {meson_flags} -Dtests=disabled -Dexamples=false && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/gpioplus')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/phosphor-dbus-interfaces')}
 {pkg_copycmds('openbmc/phosphor-dbus-interfaces')}
-RUN curl -L {pkg_url('openbmc/phosphor-dbus-interfaces')} | tar -xz && \
-cd phosphor-dbus-interfaces-* && \
-meson build {meson_flags} -Ddata_org_open_power=true -Ddata_com_ibm=true && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/phosphor-dbus-interfaces')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/phosphor-logging')}
 {pkg_copycmds('openbmc/phosphor-logging')}
-RUN curl -L {pkg_url('openbmc/phosphor-logging')} | tar -xz && \
-cd phosphor-logging-* && \
-./bootstrap.sh && \
-./configure {configure_flags} --enable-metadata-processing YAML_DIR={prefix}/share/phosphor-dbus-yaml/yaml && \
-make -j{proc_count} && \
-make install
+{pkg_build('openbmc/phosphor-logging')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/phosphor-objmgr')}
 {pkg_copycmds('openbmc/phosphor-objmgr')}
-RUN curl -L {pkg_url('openbmc/phosphor-objmgr')} | tar -xz && \
-cd phosphor-objmgr-* && \
-./bootstrap.sh && \
-./configure {configure_flags} && \
-make -j{proc_count} && \
-make install
+{pkg_build('openbmc/phosphor-objmgr')}
 
 FROM openbmc-base as {pkg_stagename('open-power/pdbg')}
 {pkg_copycmds('open-power/pdbg')}
-RUN curl -L {pkg_url('open-power/pdbg')} | tar -xz && \
-cd pdbg-* && \
-./bootstrap.sh && \
-./configure {configure_flags} && \
-make -j{proc_count} && \
-make install
+{pkg_build('open-power/pdbg')}
 
 FROM openbmc-base as {pkg_stagename('openbmc/pldm')}
 {pkg_copycmds('openbmc/pldm')}
-RUN curl -L {pkg_url('openbmc/pldm')} | tar -xz && \
-cd pldm-* && \
-meson build {meson_flags} -Dlibpldm-only=enabled -Doem-ibm=enabled -Dtests=disabled && \
-ninja -C build && \
-ninja -C build install
+{pkg_build('openbmc/pldm')}
 
 # Build the final output image
 FROM openbmc-base