mirror of
https://github.com/Jguer/yay.git
synced 2025-12-06 00:02:43 -05:00
Progress on RPC dependency parsing
This commit is contained in:
parent
6671cefef0
commit
bf0c6e4692
91
aur.go
91
aur.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
@ -11,6 +12,35 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// AurInfo is the result of an info search
|
||||||
|
type AurInfo struct {
|
||||||
|
Version int `json:"version"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Resultcount int `json:"resultcount"`
|
||||||
|
Results []struct {
|
||||||
|
ID int `json:"ID"`
|
||||||
|
Name string `json:"Name"`
|
||||||
|
PackageBaseID int `json:"PackageBaseID"`
|
||||||
|
PackageBase string `json:"PackageBase"`
|
||||||
|
Version string `json:"Version"`
|
||||||
|
Description string `json:"Description"`
|
||||||
|
URL string `json:"URL"`
|
||||||
|
NumVotes int `json:"NumVotes"`
|
||||||
|
Popularity float64 `json:"Popularity"`
|
||||||
|
OutOfDate interface{} `json:"OutOfDate"`
|
||||||
|
Maintainer string `json:"Maintainer"`
|
||||||
|
FirstSubmitted int `json:"FirstSubmitted"`
|
||||||
|
LastModified int `json:"LastModified"`
|
||||||
|
URLPath string `json:"URLPath"`
|
||||||
|
Depends []string `json:"Depends"`
|
||||||
|
MakeDepends []string `json:"MakeDepends"`
|
||||||
|
OptDepends []string `json:"OptDepends"`
|
||||||
|
Conflicts []string `json:"Conflicts"`
|
||||||
|
License []string `json:"License"`
|
||||||
|
Keywords []string `json:"Keywords"`
|
||||||
|
} `json:"results"`
|
||||||
|
}
|
||||||
|
|
||||||
// AurResult describes an AUR package
|
// AurResult describes an AUR package
|
||||||
type AurResult struct {
|
type AurResult struct {
|
||||||
ID int `json:"ID"`
|
ID int `json:"ID"`
|
||||||
@ -66,6 +96,12 @@ func searchAurPackages(pkg string) (search AurSearch) {
|
|||||||
return search
|
return search
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func infoAurPackage(pkg string) (info AurInfo) {
|
||||||
|
fmt.Println("https://aur.archlinux.org/rpc/?v=5&type=info&arg[]=" + pkg)
|
||||||
|
getJSON("https://aur.archlinux.org/rpc/?v=5&type=info&arg[]="+pkg, &info)
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
func (r AurSearch) printSearch(index int) (err error) {
|
func (r AurSearch) printSearch(index int) (err error) {
|
||||||
for i, result := range r.Results {
|
for i, result := range r.Results {
|
||||||
if index != SearchMode {
|
if index != SearchMode {
|
||||||
@ -121,10 +157,61 @@ func downloadFile(filepath string, url string) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a AurResult) getAURDependencies() {
|
// To implement
|
||||||
|
func (a AurResult) getDepsfromFile(pkgbuildLoc string) (err error) {
|
||||||
|
var depend string
|
||||||
|
file, err := os.Open(pkgbuildLoc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
if strings.Contains(scanner.Text(), "optdepends=(") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if strings.Contains(scanner.Text(), "depends=(") {
|
||||||
|
depend = scanner.Text()
|
||||||
|
fields := strings.Fields(depend)
|
||||||
|
|
||||||
|
for _, i := range fields {
|
||||||
|
fmt.Println(i)
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a AurResult) getDepsFromRPC() (err error) {
|
||||||
|
info := infoAurPackage(a.Name)
|
||||||
|
fmt.Printf("%+v\n", info)
|
||||||
|
|
||||||
|
f := func(c rune) bool {
|
||||||
|
return c == '>' || c == '<' || c == '=' || c == ' '
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, deps := range info.Results[0].MakeDepends {
|
||||||
|
fields := strings.FieldsFunc(deps, f)
|
||||||
|
fmt.Println(fields[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, deps := range info.Results[0].Depends {
|
||||||
|
fields := strings.FieldsFunc(deps, f)
|
||||||
|
fmt.Println(fields[0])
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a AurResult) getAURDependencies() (err error) {
|
||||||
|
a.getDepsFromRPC()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a AurResult) installResult() (err error) {
|
func (a AurResult) installResult() (err error) {
|
||||||
// No need to use filepath.separators because it won't run on inferior platforms
|
// No need to use filepath.separators because it won't run on inferior platforms
|
||||||
err = os.MkdirAll(BuildDir+"builds", 0755)
|
err = os.MkdirAll(BuildDir+"builds", 0755)
|
||||||
@ -153,7 +240,9 @@ func (a AurResult) installResult() (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
a.getAURDependencies()
|
a.getAURDependencies()
|
||||||
|
os.Exit(0)
|
||||||
|
|
||||||
fmt.Print("==> Edit PKGBUILD? (y/n)")
|
fmt.Print("==> Edit PKGBUILD? (y/n)")
|
||||||
var response string
|
var response string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user