Bug fix for `ResolveCompetingPackages` when building on RPM-based distro.

The current implementation of `ResolveCompetingPackages` assumes it is running on a
distro that doesn't use RPM. Specifically, it doesn't set the root directory which
allows for confusion between the packages being built for CBL-Mariner and the packages
installed on the build system. This change fix this problem by setting the root
directory when calling the `rpm` command.
This commit is contained in:
Chris Gunn 2022-06-23 11:25:11 -07:00
Родитель 92d61cc545
Коммит aa3e1bd761
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -242,7 +242,7 @@ func assignRPMPath(node *pkggraph.PkgNode, outDir string, resolvedPackages []str
var resolvedRPMs []string
logger.Log.Debugf("Found %d candidates. Resolving.", len(rpmPaths))
resolvedRPMs, err = rpm.ResolveCompetingPackages(rpmPaths...)
resolvedRPMs, err = rpm.ResolveCompetingPackages(*tmpDir, rpmPaths...)
if err != nil {
logger.Log.Errorf("Failed while trying to pick an RPM providing '%s' from the following RPMs: %v", node.VersionedPkg.Name, rpmPaths)
return

Просмотреть файл

@ -280,7 +280,7 @@ func QueryRPMProvides(rpmFile string) (provides []string, err error) {
// ResolveCompetingPackages takes in a list of RPMs and returns only the ones, which would
// end up being installed after resolving outdated, obsoleted, or conflicting packages.
func ResolveCompetingPackages(rpmPaths ...string) (resolvedRPMs []string, err error) {
func ResolveCompetingPackages(rootDir string, rpmPaths ...string) (resolvedRPMs []string, err error) {
const (
queryFormat = ""
installedRPMIndex = 1
@ -290,6 +290,8 @@ func ResolveCompetingPackages(rpmPaths ...string) (resolvedRPMs []string, err er
args := []string{
"-Uvvh",
"--nodeps",
"--root",
rootDir,
"--test",
}
args = append(args, rpmPaths...)