func rpmDataFromImageFS(image pkgutil.Image) (map[string]util.PackageInfo, error) {
	dbPath, err := rpmEnvCheck(image.FSPath)
	if err != nil {
		logrus.Warnf("Couldn't find RPM database: %s", err.Error())
		return nil, err
	}
	return rpmDataFromFS(image.FSPath, dbPath)
}
rpmDataFromImageFS runs a local rpm binary, if any, to query the image
rpmdb and returns a map of installed packages.
package differs
import (
	"bufio"
	"bytes"
	"context"
	"errors"
	"fmt"
	"math/rand"
	"os"
	"os/exec"
	"path/filepath"
	"strconv"
	"strings"
	"sync"
	"time"
	"github.com/google/go-containerregistry/pkg/name"
	"github.com/google/go-containerregistry/pkg/v1"
	"github.com/google/go-containerregistry/pkg/v1/daemon"
	"github.com/google/go-containerregistry/pkg/v1/mutate"
	"github.com/google/go-containerregistry/pkg/v1/random"
	pkgutil "github.com/GoogleContainerTools/container-diff/pkg/util"
	"github.com/GoogleContainerTools/container-diff/util"
	godocker "github.com/fsouza/go-dockerclient"
	"github.com/nightlyone/lockfile"
	"github.com/sirupsen/logrus"
)
const rpmMacros string = "/usr/lib/rpm/macros"
var rpmCmd = []string{
	"rpm", "--nodigest", "--nosignature",
	"-qa", "--qf", "%{NAME}\t%{VERSION}-%{RELEASE}\t%{SIZE}\n",
}
var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
var daemonMutex sync.Mutex
type RPMAnalyzer struct {
}
func (a RPMAnalyzer) Name() string {
	return "RPMAnalyzer"
}
func (a RPMAnalyzer) Diff(image1, image2 pkgutil.Image) (util.Result, error) {
	diff, err := singleVersionDiff(image1, image2, a)
	return diff, err
}
func (a RPMAnalyzer) Analyze(image pkgutil.Image) (util.Result, error) {
	analysis, err := singleVersionAnalysis(image, a)
	return analysis, err
}
func (a RPMAnalyzer) getPackages(image pkgutil.Image) (map[string]util.PackageInfo, error) {
	path := image.FSPath
	packages := make(map[string]util.PackageInfo)
	if _, err := os.Stat(path); err != nil {
		return packages, err
	}
	rpmBinary := filepath.Join(path, "bin/rpm")
	if _, err := os.Stat(rpmBinary); err != nil {
		rpmBinary = filepath.Join(path, "usr/bin/rpm")
		if _, err = os.Stat(rpmBinary); err != nil {
			logrus.Errorf("Could not detect RPM binary in unpacked image %s", image.Source)
			return packages, nil
		}
	}
	packages, err := rpmDataFromImageFS(image)
	if err != nil {
		logrus.Info("Couldn't retrieve RPM data from extracted filesystem; running query in container")
		return rpmDataFromContainer(image.Image)
	}
	return packages, err
}