mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 01:27:21 +01:00
Removed alpm dependencies
This commit is contained in:
parent
b17aca7bc2
commit
4481a9de65
43
aur/aur.go
43
aur/aur.go
@ -8,7 +8,6 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
alpm "github.com/demizer/go-alpm"
|
|
||||||
"github.com/jguer/yay/pacman"
|
"github.com/jguer/yay/pacman"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ func MultiInfo(pkgS []string) (Query, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Install sends system commands to make and install a package from pkgName
|
// Install sends system commands to make and install a package from pkgName
|
||||||
func Install(pkg string, baseDir string, conf *alpm.PacmanConfig, flags []string) (err error) {
|
func Install(pkg string, baseDir string, flags []string) (err error) {
|
||||||
q, n, err := Info(pkg)
|
q, n, err := Info(pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -151,7 +150,7 @@ func Install(pkg string, baseDir string, conf *alpm.PacmanConfig, flags []string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Upgrade tries to update every foreign package installed in the system
|
// Upgrade tries to update every foreign package installed in the system
|
||||||
func Upgrade(baseDir string, conf *alpm.PacmanConfig, flags []string) error {
|
func Upgrade(baseDir string, flags []string) error {
|
||||||
fmt.Println("\x1b[1;36;1m::\x1b[0m\x1b[1m Starting AUR upgrade...\x1b[0m")
|
fmt.Println("\x1b[1;36;1m::\x1b[0m\x1b[1m Starting AUR upgrade...\x1b[0m")
|
||||||
|
|
||||||
foreign, n, err := pacman.ForeignPackages()
|
foreign, n, err := pacman.ForeignPackages()
|
||||||
@ -303,44 +302,6 @@ func (a *Result) Dependencies() (aur []string, repo []string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// IspkgInstalled returns true if pkgName is installed
|
|
||||||
func IspkgInstalled(pkgName string) (bool, error) {
|
|
||||||
h, err := alpm.Init("/", "/var/lib/pacman")
|
|
||||||
defer h.Release()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
localDb, err := h.LocalDb()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = localDb.PkgByName(pkgName)
|
|
||||||
if err != nil {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// IspkgInRepo returns true if pkgName is in a synced repo
|
|
||||||
func IspkgInRepo(pkgName string, conf *alpm.PacmanConfig) (bool, error) {
|
|
||||||
h, err := conf.CreateHandle()
|
|
||||||
defer h.Release()
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
|
|
||||||
dbList, _ := h.SyncDbs()
|
|
||||||
for _, db := range dbList.Slice() {
|
|
||||||
_, err = db.PkgByName(pkgName)
|
|
||||||
if err == nil {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// NoConfirm returns true if prompts should be ignored
|
// NoConfirm returns true if prompts should be ignored
|
||||||
func NoConfirm(flags []string) bool {
|
func NoConfirm(flags []string) bool {
|
||||||
noconf := false
|
noconf := false
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package aur
|
package aur
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/demizer/go-alpm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSearch(t *testing.T) {
|
func TestSearch(t *testing.T) {
|
||||||
@ -63,34 +60,14 @@ func TestInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpgrade(t *testing.T) {
|
func TestUpgrade(t *testing.T) {
|
||||||
var conf alpm.PacmanConfig
|
err := Upgrade("/tmp/yaytmp", []string{})
|
||||||
file, err := os.Open("/etc/pacman.conf")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
conf, err = alpm.ParseConfig(file)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
err = Upgrade("/tmp/yaytmp", &conf, []string{})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Expected err to be nil but it was %s", err)
|
t.Fatalf("Expected err to be nil but it was %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkUpgrade(b *testing.B) {
|
func BenchmarkUpgrade(b *testing.B) {
|
||||||
var conf alpm.PacmanConfig
|
|
||||||
file, err := os.Open("/etc/pacman.conf")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
conf, err = alpm.ParseConfig(file)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for n := 0; n < b.N; n++ {
|
for n := 0; n < b.N; n++ {
|
||||||
Upgrade("/tmp/yaytmp", &conf, []string{})
|
Upgrade("/tmp/yaytmp", []string{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user