Improve AUR with AUR dependency installations

This commit is contained in:
AI Bot
2026-05-03 17:40:31 +02:00
committed by Riyyi
parent c8cdace4bf
commit b13c9da7a1
5 changed files with 165 additions and 31 deletions
+8
View File
@@ -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
View File
@@ -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 {
+16
View File
@@ -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)
}
}