Skip to content
2 changes: 1 addition & 1 deletion internal/ospackage/rpmutils/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func DownloadPackagesComplete(pkgList []string, destDir, dotFile string, pkgSour
urls := make([]string, len(sorted_pkgs))
for i, pkg := range sorted_pkgs {
urls[i] = pkg.URL
downloadPkgList = append(downloadPkgList, pkg.Name)
downloadPkgList = append(downloadPkgList, filepath.Base(pkg.URL))
}

// Ensure dest directory exists
Expand Down
12 changes: 12 additions & 0 deletions internal/ospackage/rpmutils/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,18 @@ func ResolveTopPackageConflicts(want string, all []ospackage.PackageInfo) (ospac
}
}

// If no candidates found, check Provides field
if len(candidates) == 0 {
for _, pi := range all {
for _, provided := range pi.Provides {
if provided == want {
candidates = append(candidates, pi)
break
}
}
}
}

if len(candidates) == 0 {
return ospackage.PackageInfo{}, false
}
Expand Down
7 changes: 3 additions & 4 deletions internal/ospackage/rpmutils/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"io"
"os"
"path"
"path/filepath"
"sort"
"strings"
Expand Down Expand Up @@ -254,11 +253,11 @@ func ParseRepositoryMetadata(baseURL, gzHref string) ([]ospackage.PackageInfo, e
}

case "location":
// read the href and build full URL + infer Name (filename)
// read the href and build full URL
for _, a := range elem.Attr {
if a.Name.Local == "href" {
curInfo.URL = strings.TrimRight(baseURL, "/") + "/" + strings.TrimLeft(a.Value, "/")
curInfo.Name = path.Base(a.Value)
// Note: Don't set Name from location href - it should come from <name> element
break
}
}
Expand Down Expand Up @@ -380,7 +379,7 @@ func ParseRepositoryMetadata(baseURL, gzHref string) ([]ospackage.PackageInfo, e
// canonical package name
if tok2, err2 := dec.Token(); err2 == nil {
if cd, ok := tok2.(xml.CharData); ok && curInfo != nil {
curInfo.Name = string(cd)
curInfo.Name = strings.TrimSpace(string(cd))
}
}

Expand Down
6 changes: 3 additions & 3 deletions internal/ospackage/rpmutils/resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func TestParsePrimary(t *testing.T) {
filename: "primary.xml.gz",
expectedError: false,
expectedCount: 2,
expectedNames: []string{"bash-5.1-8.el9.x86_64.rpm", "glibc-2.32-1.el9.x86_64.rpm"},
expectedNames: []string{"bash", "glibc"},
},
{
name: "empty metadata",
Expand Down Expand Up @@ -330,13 +330,13 @@ func TestParsePrimary(t *testing.T) {
// Check bash package details
var bashPkg *ospackage.PackageInfo
for _, pkg := range packages {
if pkg.Name == "bash-5.1-8.el9.x86_64.rpm" {
if pkg.Name == "bash" {
bashPkg = &pkg
break
}
}
if bashPkg == nil {
t.Fatal("bash-5.1-8.el9.x86_64.rpm package not found")
t.Fatal("bash package not found")
}

if bashPkg.License != "GPLv3+" {
Expand Down
Loading