From 0f1086cf7c2f8d5dbff2e31dfa4f4f8d3864281f Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 7 Aug 2018 06:42:02 -0600 Subject: Add dpkg support for returning oci/conmon versions Signed-off-by: Daniel J Walsh Closes: #1224 Approved by: baude --- libpod/oci_linux.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libpod/oci_linux.go b/libpod/oci_linux.go index e105680b7..bdf859d7d 100644 --- a/libpod/oci_linux.go +++ b/libpod/oci_linux.go @@ -113,10 +113,25 @@ func rpmVersion(path string) string { return strings.Trim(output, "\n") } +func dpkgVersion(path string) string { + output := "Unknown" + cmd := exec.Command("/usr/bin/dpkg", "-S", path) + if outp, err := cmd.Output(); err == nil { + output = string(outp) + } + return strings.Trim(output, "\n") +} + func (r *OCIRuntime) pathPackage() string { - return rpmVersion(r.path) + if out := rpmVersion(r.path); out != "Unknown" { + return out + } + return dpkgVersion(r.path) } func (r *OCIRuntime) conmonPackage() string { - return rpmVersion(r.conmonPath) + if out := rpmVersion(r.conmonPath); out != "Unknown" { + return out + } + return dpkgVersion(r.conmonPath) } -- cgit v1.2.3-54-g00ecf