Bug fixes and added pre_update.sh pacakge scripts #7
@ -8,6 +8,7 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ type Repository struct {
|
|||||||
type RepositoryEntry struct {
|
type RepositoryEntry struct {
|
||||||
Info *PackageInfo `yaml:"info"`
|
Info *PackageInfo `yaml:"info"`
|
||||||
Download string `yaml:"download"`
|
Download string `yaml:"download"`
|
||||||
|
IsVirtualPackage bool `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repository) ContainsPackage(pkg string) bool {
|
func (repo *Repository) ContainsPackage(pkg string) bool {
|
||||||
@ -39,6 +41,8 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtualPackages := make(map[string][]string)
|
||||||
|
|
||||||
data := string(bytes)
|
data := string(bytes)
|
||||||
for _, b := range strings.Split(data, "---") {
|
for _, b := range strings.Split(data, "---") {
|
||||||
entry := RepositoryEntry{
|
entry := RepositoryEntry{
|
||||||
@ -59,13 +63,31 @@ func (repo *Repository) ReadLocalDatabase() error {
|
|||||||
Provides: make([]string, 0),
|
Provides: make([]string, 0),
|
||||||
},
|
},
|
||||||
Download: "",
|
Download: "",
|
||||||
|
IsVirtualPackage: false,
|
||||||
}
|
}
|
||||||
err := yaml.Unmarshal([]byte(b), &entry)
|
err := yaml.Unmarshal([]byte(b), &entry)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, p := range entry.Info.Provides {
|
||||||
|
virtualPackages[p] = append(virtualPackages[p], entry.Info.Name)
|
||||||
|
}
|
||||||
repo.Entries[entry.Info.Name] = &entry
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user