Provided packages should now function correctly
This commit is contained in:
parent
a3d1167358
commit
2d35ac12a1
@ -8,6 +8,7 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -19,8 +20,9 @@ type Repository struct {
|
||||
}
|
||||
|
||||
type RepositoryEntry struct {
|
||||
Info *PackageInfo `yaml:"info"`
|
||||
Download string `yaml:"download"`
|
||||
Info *PackageInfo `yaml:"info"`
|
||||
Download string `yaml:"download"`
|
||||
IsVirtualPackage bool `yaml:"-"`
|
||||
}
|
||||
|
||||
func (repo *Repository) ContainsPackage(pkg string) bool {
|
||||
@ -39,6 +41,8 @@ func (repo *Repository) ReadLocalDatabase() error {
|
||||
return err
|
||||
}
|
||||
|
||||
virtualPackages := make(map[string][]string)
|
||||
|
||||
data := string(bytes)
|
||||
for _, b := range strings.Split(data, "---") {
|
||||
entry := RepositoryEntry{
|
||||
@ -58,14 +62,32 @@ func (repo *Repository) ReadLocalDatabase() error {
|
||||
Conflicts: make([]string, 0),
|
||||
Provides: make([]string, 0),
|
||||
},
|
||||
Download: "",
|
||||
Download: "",
|
||||
IsVirtualPackage: false,
|
||||
}
|
||||
err := yaml.Unmarshal([]byte(b), &entry)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, p := range entry.Info.Provides {
|
||||
virtualPackages[p] = append(virtualPackages[p], entry.Info.Name)
|
||||
}
|
||||
repo.Entries[entry.Info.Name] = &entry
|
||||
}
|
||||
|
||||
for key, value := range virtualPackages {
|
||||
if _, ok := repo.Entries[key]; ok {
|
||||
continue
|
||||
}
|
||||
sort.Strings(value)
|
||||
entry := RepositoryEntry{
|
||||
Info: repo.Entries[value[0]].Info,
|
||||
Download: repo.Entries[value[0]].Download,
|
||||
IsVirtualPackage: true,
|
||||
}
|
||||
repo.Entries[key] = &entry
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user