From 4481a9de653401b7707855698c362e490c922bb2 Mon Sep 17 00:00:00 2001 From: Jguer Date: Wed, 30 Nov 2016 23:21:56 +0000 Subject: [PATCH] Removed alpm dependencies --- aur/aur.go | 43 ++----------------------------------------- aur/aur_test.go | 27 ++------------------------- 2 files changed, 4 insertions(+), 66 deletions(-) diff --git a/aur/aur.go b/aur/aur.go index 450d5a5e..d04c9d5b 100644 --- a/aur/aur.go +++ b/aur/aur.go @@ -8,7 +8,6 @@ import ( "sort" "strings" - alpm "github.com/demizer/go-alpm" "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 -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) if err != nil { 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 -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") foreign, n, err := pacman.ForeignPackages() @@ -303,44 +302,6 @@ func (a *Result) Dependencies() (aur []string, repo []string, err error) { 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 func NoConfirm(flags []string) bool { noconf := false diff --git a/aur/aur_test.go b/aur/aur_test.go index 1e13b53d..91d4bb35 100644 --- a/aur/aur_test.go +++ b/aur/aur_test.go @@ -1,11 +1,8 @@ package aur import ( - "os" "reflect" "testing" - - "github.com/demizer/go-alpm" ) func TestSearch(t *testing.T) { @@ -63,34 +60,14 @@ func TestInfo(t *testing.T) { } func TestUpgrade(t *testing.T) { - var conf alpm.PacmanConfig - 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{}) + err := Upgrade("/tmp/yaytmp", []string{}) if err != nil { t.Fatalf("Expected err to be nil but it was %s", err) } } 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++ { - Upgrade("/tmp/yaytmp", &conf, []string{}) + Upgrade("/tmp/yaytmp", []string{}) } }