Improve AUR with AUR dependency installations
This commit is contained in:
@@ -37,6 +37,14 @@ func (h *Handle) LocalPackages() (map[string]dyalpm.Package, error) {
|
||||
return localPkgs, nil
|
||||
}
|
||||
|
||||
func (h *Handle) FindProvidingPackage(depName string) (string, bool) {
|
||||
pkg := h.handle.FindDBSatisfier(h.syncDBs, depName)
|
||||
if pkg != nil {
|
||||
return pkg.Name(), true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (h *Handle) Release() error {
|
||||
if h.handle != nil {
|
||||
h.handle.Release()
|
||||
|
||||
+10
-4
@@ -13,10 +13,16 @@ import (
|
||||
var AURInfoURL = "https://aur.archlinux.org/rpc?v=5&type=info"
|
||||
|
||||
type Package struct {
|
||||
Name string `json:"Name"`
|
||||
PackageBase string `json:"PackageBase"`
|
||||
Version string `json:"Version"`
|
||||
URL string `json:"URL"`
|
||||
Name string `json:"Name"`
|
||||
PackageBase string `json:"PackageBase"`
|
||||
Version string `json:"Version"`
|
||||
URL string `json:"URL"`
|
||||
Depends []string `json:"Depends"`
|
||||
MakeDepends []string `json:"MakeDepends"`
|
||||
}
|
||||
|
||||
func (p Package) AllDepends() []string {
|
||||
return append(p.Depends, p.MakeDepends...)
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
|
||||
@@ -14,6 +14,7 @@ type PackageInfo struct {
|
||||
InAUR bool
|
||||
Exists bool
|
||||
Installed bool
|
||||
Provided string
|
||||
AURInfo *aur.Package
|
||||
}
|
||||
|
||||
@@ -38,10 +39,18 @@ func (f *Fetcher) Close() error {
|
||||
return f.alpmHandle.Release()
|
||||
}
|
||||
|
||||
func (f *Fetcher) FetchAur(packages []string) (map[string]aur.Package, error) {
|
||||
return f.aurClient.Fetch(packages)
|
||||
}
|
||||
|
||||
func (f *Fetcher) GetAURPackage(name string) (aur.Package, bool) {
|
||||
return f.aurClient.Get(name)
|
||||
}
|
||||
|
||||
func (f *Fetcher) FindProvidingPackage(depName string) (string, bool) {
|
||||
return f.alpmHandle.FindProvidingPackage(depName)
|
||||
}
|
||||
|
||||
func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
|
||||
start := time.Now()
|
||||
log.Debug("fetch.Resolve: starting...")
|
||||
@@ -98,6 +107,13 @@ func (f *Fetcher) Resolve(packages []string) (map[string]*PackageInfo, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if providedBy, ok := f.FindProvidingPackage(pkg); ok {
|
||||
log.Debug("fetch.Resolve: %s provided by %s", pkg, providedBy)
|
||||
info.Provided = providedBy
|
||||
info.Exists = true
|
||||
continue
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("package not found: %s", pkg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user