summaryrefslogtreecommitdiff
path: root/libpod/util.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2019-08-31 07:19:39 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2019-09-06 07:32:42 -0400
commitb2b284111e49d3d953f71a794f25aa9ddfbb8568 (patch)
tree280582a73cb3c3cc080517c5fdaafbbf90846fe0 /libpod/util.go
parenta4572c4f681ef23495495f313ae513d5ba3fd495 (diff)
downloadpodman-b2b284111e49d3d953f71a794f25aa9ddfbb8568.tar.gz
podman-b2b284111e49d3d953f71a794f25aa9ddfbb8568.tar.bz2
podman-b2b284111e49d3d953f71a794f25aa9ddfbb8568.zip
Return information about mount_program (fuse-overlayfs)
We want to get podman info to tell us about the version of the mount program to help us diagnose issues users are having. Also if in rootless mode and slirp4netns is installed reveal package info on slirp4netns. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/util.go')
-rw-r--r--libpod/util.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go
index 164800af4..84fd490bf 100644
--- a/libpod/util.go
+++ b/libpod/util.go
@@ -3,6 +3,7 @@ package libpod
import (
"fmt"
"os"
+ "os/exec"
"path/filepath"
"sort"
"strconv"
@@ -10,6 +11,7 @@ import (
"time"
"github.com/containers/libpod/libpod/define"
+ "github.com/containers/libpod/utils"
"github.com/fsnotify/fsnotify"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -20,6 +22,8 @@ const (
// DefaultTransport is a prefix that we apply to an image name
// to check docker hub first for the image
DefaultTransport = "docker://"
+
+ unknownPackage = "Unknown"
)
// FuncTimer helps measure the execution time of a function
@@ -152,3 +156,36 @@ func JSONDeepCopy(from, to interface{}) error {
}
return json.Unmarshal(tmp, to)
}
+
+func dpkgVersion(path string) string {
+ output := unknownPackage
+ cmd := exec.Command("/usr/bin/dpkg", "-S", path)
+ if outp, err := cmd.Output(); err == nil {
+ output = string(outp)
+ }
+ return strings.Trim(output, "\n")
+}
+
+func rpmVersion(path string) string {
+ output := unknownPackage
+ cmd := exec.Command("/usr/bin/rpm", "-q", "-f", path)
+ if outp, err := cmd.Output(); err == nil {
+ output = string(outp)
+ }
+ return strings.Trim(output, "\n")
+}
+
+func packageVersion(program string) string {
+ if out := rpmVersion(program); out != unknownPackage {
+ return out
+ }
+ return dpkgVersion(program)
+}
+
+func programVersion(mountProgram string) (string, error) {
+ output, err := utils.ExecCmd(mountProgram, "--version")
+ if err != nil {
+ return "", err
+ }
+ return strings.TrimSuffix(output, "\n"), nil
+}