Sfoglia il codice sorgente

test(alpm): implement alpm interfaces

jguer 4 anni fa
parent
commit
3e698f313a
14 ha cambiato i file con 213 aggiunte e 87 eliminazioni
  1. 1 1
      cmd.go
  2. 3 1
      download.go
  3. 1 1
      install.go
  4. 13 26
      pkg/db/executor.go
  5. 21 22
      pkg/db/ialpm/alpm.go
  6. 129 1
      pkg/db/mock/repo.go
  7. 2 2
      pkg/dep/dep.go
  8. 5 4
      pkg/dep/depOrder.go
  9. 7 5
      pkg/dep/depPool.go
  10. 3 1
      pkg/query/filter.go
  11. 8 4
      pkg/vcs/vcs_test.go
  12. 2 2
      query.go
  13. 7 7
      upgrade.go
  14. 11 10
      upgrade_test.go

+ 1 - 1
cmd.go

@@ -6,7 +6,7 @@ import (
 	"net/http"
 	"os"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	"github.com/leonelquinteros/gotext"
 
 	"github.com/Jguer/yay/v10/pkg/completion"

+ 3 - 1
download.go

@@ -11,6 +11,8 @@ import (
 	"github.com/leonelquinteros/gotext"
 	"github.com/pkg/errors"
 
+	alpm "github.com/Jguer/go-alpm/v2"
+
 	"github.com/Jguer/yay/v10/pkg/db"
 	"github.com/Jguer/yay/v10/pkg/dep"
 	"github.com/Jguer/yay/v10/pkg/multierror"
@@ -225,7 +227,7 @@ func getPkgbuildsfromABS(pkgs []string, path string, dbExecutor db.Executor, for
 	downloaded := 0
 
 	for _, pkgN := range pkgs {
-		var pkg db.RepoPackage
+		var pkg alpm.IPackage
 		var err error
 		var url string
 		pkgDB, name := text.SplitDBFromName(pkgN)

+ 1 - 1
install.go

@@ -10,7 +10,7 @@ import (
 	"strings"
 	"sync"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	gosrc "github.com/Morganamilo/go-srcinfo"
 	"github.com/leonelquinteros/gotext"
 

+ 13 - 26
pkg/db/executor.go

@@ -3,43 +3,30 @@ package db
 import (
 	"time"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 
 	"github.com/Jguer/yay/v10/pkg/upgrade"
 )
 
-type RepoPackage interface {
-	Base() string
-	BuildDate() time.Time
-	DB() alpm.IDB
-	Description() string
-	ISize() int64
-	Name() string
-	ShouldIgnore() bool
-	Size() int64
-	Version() string
-	Reason() alpm.PkgReason
-}
-
 type Executor interface {
 	AlpmArch() (string, error)
-	BiggestPackages() []RepoPackage
+	BiggestPackages() []alpm.IPackage
 	Cleanup()
 	IsCorrectVersionInstalled(string, string) bool
 	LastBuildTime() time.Time
-	LocalPackage(string) RepoPackage
-	LocalPackages() []RepoPackage
+	LocalPackage(string) alpm.IPackage
+	LocalPackages() []alpm.IPackage
 	LocalSatisfierExists(string) bool
-	PackageConflicts(RepoPackage) []alpm.Depend
-	PackageDepends(RepoPackage) []alpm.Depend
-	SatisfierFromDB(string, string) RepoPackage
-	PackageGroups(RepoPackage) []string
-	PackageOptionalDepends(RepoPackage) []alpm.Depend
-	PackageProvides(RepoPackage) []alpm.Depend
-	PackagesFromGroup(string) []RepoPackage
+	PackageConflicts(alpm.IPackage) []alpm.Depend
+	PackageDepends(alpm.IPackage) []alpm.Depend
+	SatisfierFromDB(string, string) alpm.IPackage
+	PackageGroups(alpm.IPackage) []string
+	PackageOptionalDepends(alpm.IPackage) []alpm.Depend
+	PackageProvides(alpm.IPackage) []alpm.Depend
+	PackagesFromGroup(string) []alpm.IPackage
 	RefreshHandle() error
 	RepoUpgrades(bool) (upgrade.UpSlice, error)
-	SyncPackages(...string) []RepoPackage
-	SyncSatisfier(string) RepoPackage
+	SyncPackages(...string) []alpm.IPackage
+	SyncSatisfier(string) alpm.IPackage
 	SyncSatisfierExists(string) bool
 }

+ 21 - 22
pkg/db/ialpm/alpm.go

@@ -8,11 +8,10 @@ import (
 	"strconv"
 	"time"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	pacmanconf "github.com/Morganamilo/go-pacmanconf"
 	"github.com/leonelquinteros/gotext"
 
-	"github.com/Jguer/yay/v10/pkg/db"
 	"github.com/Jguer/yay/v10/pkg/settings"
 	"github.com/Jguer/yay/v10/pkg/text"
 	"github.com/Jguer/yay/v10/pkg/upgrade"
@@ -288,7 +287,7 @@ func (ae *AlpmExecutor) IsCorrectVersionInstalled(pkgName, versionRequired strin
 	return alpmPackage.Version() == versionRequired
 }
 
-func (ae *AlpmExecutor) SyncSatisfier(pkgName string) db.RepoPackage {
+func (ae *AlpmExecutor) SyncSatisfier(pkgName string) alpm.IPackage {
 	foundPkg, err := ae.syncDB.FindSatisfier(pkgName)
 	if err != nil {
 		return nil
@@ -296,8 +295,8 @@ func (ae *AlpmExecutor) SyncSatisfier(pkgName string) db.RepoPackage {
 	return foundPkg
 }
 
-func (ae *AlpmExecutor) PackagesFromGroup(groupName string) []db.RepoPackage {
-	groupPackages := []db.RepoPackage{}
+func (ae *AlpmExecutor) PackagesFromGroup(groupName string) []alpm.IPackage {
+	groupPackages := []alpm.IPackage{}
 	_ = ae.syncDB.FindGroupPkgs(groupName).ForEach(func(pkg alpm.IPackage) error {
 		groupPackages = append(groupPackages, pkg)
 		return nil
@@ -305,27 +304,27 @@ func (ae *AlpmExecutor) PackagesFromGroup(groupName string) []db.RepoPackage {
 	return groupPackages
 }
 
-func (ae *AlpmExecutor) LocalPackages() []db.RepoPackage {
-	localPackages := []db.RepoPackage{}
+func (ae *AlpmExecutor) LocalPackages() []alpm.IPackage {
+	localPackages := []alpm.IPackage{}
 	_ = ae.localDB.PkgCache().ForEach(func(pkg alpm.IPackage) error {
-		localPackages = append(localPackages, db.RepoPackage(pkg))
+		localPackages = append(localPackages, pkg)
 		return nil
 	})
 	return localPackages
 }
 
 // SyncPackages searches SyncDB for packages or returns all packages if no search param is given
-func (ae *AlpmExecutor) SyncPackages(pkgNames ...string) []db.RepoPackage {
-	repoPackages := []db.RepoPackage{}
+func (ae *AlpmExecutor) SyncPackages(pkgNames ...string) []alpm.IPackage {
+	repoPackages := []alpm.IPackage{}
 	_ = ae.syncDB.ForEach(func(alpmDB alpm.IDB) error {
 		if len(pkgNames) == 0 {
 			_ = alpmDB.PkgCache().ForEach(func(pkg alpm.IPackage) error {
-				repoPackages = append(repoPackages, db.RepoPackage(pkg))
+				repoPackages = append(repoPackages, pkg)
 				return nil
 			})
 		} else {
 			_ = alpmDB.Search(pkgNames).ForEach(func(pkg alpm.IPackage) error {
-				repoPackages = append(repoPackages, db.RepoPackage(pkg))
+				repoPackages = append(repoPackages, pkg)
 				return nil
 			})
 		}
@@ -334,7 +333,7 @@ func (ae *AlpmExecutor) SyncPackages(pkgNames ...string) []db.RepoPackage {
 	return repoPackages
 }
 
-func (ae *AlpmExecutor) LocalPackage(pkgName string) db.RepoPackage {
+func (ae *AlpmExecutor) LocalPackage(pkgName string) alpm.IPackage {
 	pkg := ae.localDB.Pkg(pkgName)
 	if pkg == nil {
 		return nil
@@ -342,7 +341,7 @@ func (ae *AlpmExecutor) LocalPackage(pkgName string) db.RepoPackage {
 	return pkg
 }
 
-func (ae *AlpmExecutor) SatisfierFromDB(pkgName, dbName string) db.RepoPackage {
+func (ae *AlpmExecutor) SatisfierFromDB(pkgName, dbName string) alpm.IPackage {
 	singleDB, err := ae.handle.SyncDBByName(dbName)
 	if err != nil {
 		return nil
@@ -354,27 +353,27 @@ func (ae *AlpmExecutor) SatisfierFromDB(pkgName, dbName string) db.RepoPackage {
 	return foundPkg
 }
 
-func (ae *AlpmExecutor) PackageDepends(pkg db.RepoPackage) []alpm.Depend {
+func (ae *AlpmExecutor) PackageDepends(pkg alpm.IPackage) []alpm.Depend {
 	alpmPackage := pkg.(*alpm.Package)
 	return alpmPackage.Depends().Slice()
 }
 
-func (ae *AlpmExecutor) PackageOptionalDepends(pkg db.RepoPackage) []alpm.Depend {
+func (ae *AlpmExecutor) PackageOptionalDepends(pkg alpm.IPackage) []alpm.Depend {
 	alpmPackage := pkg.(*alpm.Package)
 	return alpmPackage.OptionalDepends().Slice()
 }
 
-func (ae *AlpmExecutor) PackageProvides(pkg db.RepoPackage) []alpm.Depend {
+func (ae *AlpmExecutor) PackageProvides(pkg alpm.IPackage) []alpm.Depend {
 	alpmPackage := pkg.(*alpm.Package)
 	return alpmPackage.Provides().Slice()
 }
 
-func (ae *AlpmExecutor) PackageConflicts(pkg db.RepoPackage) []alpm.Depend {
+func (ae *AlpmExecutor) PackageConflicts(pkg alpm.IPackage) []alpm.Depend {
 	alpmPackage := pkg.(*alpm.Package)
 	return alpmPackage.Conflicts().Slice()
 }
 
-func (ae *AlpmExecutor) PackageGroups(pkg db.RepoPackage) []string {
+func (ae *AlpmExecutor) PackageGroups(pkg alpm.IPackage) []string {
 	alpmPackage := pkg.(*alpm.Package)
 	return alpmPackage.Groups().Slice()
 }
@@ -425,10 +424,10 @@ func (ae *AlpmExecutor) AlpmArch() (string, error) {
 	return ae.handle.Arch()
 }
 
-func (ae *AlpmExecutor) BiggestPackages() []db.RepoPackage {
-	localPackages := []db.RepoPackage{}
+func (ae *AlpmExecutor) BiggestPackages() []alpm.IPackage {
+	localPackages := []alpm.IPackage{}
 	_ = ae.localDB.PkgCache().SortBySize().ForEach(func(pkg alpm.IPackage) error {
-		localPackages = append(localPackages, db.RepoPackage(pkg))
+		localPackages = append(localPackages, pkg)
 		return nil
 	})
 	return localPackages

+ 129 - 1
pkg/db/mock/repo.go

@@ -3,7 +3,7 @@ package mock
 import (
 	"time"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 )
 
 type Package struct {
@@ -58,3 +58,131 @@ func (p *Package) Version() string {
 func (p *Package) Reason() alpm.PkgReason {
 	return p.PReason
 }
+
+func (p *Package) FileName() string {
+	panic("not implemented") // TODO: Implement
+}
+
+func (p *Package) Base64Signature() string {
+	panic("not implemented") // TODO: Implement
+}
+
+func (p *Package) Validation() alpm.Validation {
+	panic("not implemented") // TODO: Implement
+}
+
+// Architecture returns the package target Architecture.
+func (p *Package) Architecture() string {
+	panic("not implemented") // TODO: Implement
+}
+
+// Backup returns a list of package backups.
+func (p *Package) Backup() alpm.BackupList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Conflicts returns the conflicts of the package as a DependList.
+func (p *Package) Conflicts() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Depends returns the package's dependency list.
+func (p *Package) Depends() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Depends returns the package's optional dependency list.
+func (p *Package) OptionalDepends() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Depends returns the package's check dependency list.
+func (p *Package) CheckDepends() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Depends returns the package's make dependency list.
+func (p *Package) MakeDepends() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Files returns the file list of the package.
+func (p *Package) Files() []alpm.File {
+	panic("not implemented") // TODO: Implement
+}
+
+// ContainsFile checks if the path is in the package filelist
+func (p *Package) ContainsFile(path string) (alpm.File, error) {
+	panic("not implemented") // TODO: Implement
+}
+
+// Groups returns the groups the package belongs to.
+func (p *Package) Groups() alpm.StringList {
+	panic("not implemented") // TODO: Implement
+}
+
+// InstallDate returns the package install date.
+func (p *Package) InstallDate() time.Time {
+	panic("not implemented") // TODO: Implement
+}
+
+// Licenses returns the package license list.
+func (p *Package) Licenses() alpm.StringList {
+	panic("not implemented") // TODO: Implement
+}
+
+// SHA256Sum returns package SHA256Sum.
+func (p *Package) SHA256Sum() string {
+	panic("not implemented") // TODO: Implement
+}
+
+// MD5Sum returns package MD5Sum.
+func (p *Package) MD5Sum() string {
+	panic("not implemented") // TODO: Implement
+}
+
+// Packager returns package packager name.
+func (p *Package) Packager() string {
+	panic("not implemented") // TODO: Implement
+}
+
+// Provides returns DependList of packages provides by package.
+func (p *Package) Provides() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// Origin returns package origin.
+func (p *Package) Origin() alpm.PkgFrom {
+	panic("not implemented") // TODO: Implement
+}
+
+// Replaces returns a DependList with the packages this package replaces.
+func (p *Package) Replaces() alpm.DependList {
+	panic("not implemented") // TODO: Implement
+}
+
+// URL returns the upstream URL of the package.
+func (p *Package) URL() string {
+	panic("not implemented") // TODO: Implement
+}
+
+// ComputeRequiredBy returns the names of reverse dependencies of a package
+func (p *Package) ComputeRequiredBy() []string {
+	panic("not implemented") // TODO: Implement
+}
+
+// ComputeOptionalFor returns the names of packages that optionally
+// require the given package
+func (p *Package) ComputeOptionalFor() []string {
+	panic("not implemented") // TODO: Implement
+}
+
+// SyncNewVersion checks if there is a new version of the
+// package in a given DBlist.
+func (p *Package) SyncNewVersion(l alpm.IDBList) alpm.IPackage {
+	panic("not implemented") // TODO: Implement
+}
+
+func (p *Package) Type() string {
+	panic("not implemented") // TODO: Implement
+}

+ 2 - 2
pkg/dep/dep.go

@@ -3,7 +3,7 @@ package dep
 import (
 	"strings"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	rpc "github.com/mikkeloscar/aur"
 
 	"github.com/Jguer/yay/v10/pkg/db"
@@ -121,7 +121,7 @@ func satisfiesAur(dep string, pkg *rpc.Pkg) bool {
 	return false
 }
 
-func satisfiesRepo(dep string, pkg db.RepoPackage, dbExecutor db.Executor) bool {
+func satisfiesRepo(dep string, pkg alpm.IPackage, dbExecutor db.Executor) bool {
 	if pkgSatisfies(pkg.Name(), pkg.Version(), dep) {
 		return true
 	}

+ 5 - 4
pkg/dep/depOrder.go

@@ -5,21 +5,22 @@ import (
 
 	rpc "github.com/mikkeloscar/aur"
 
-	"github.com/Jguer/yay/v10/pkg/db"
+	alpm "github.com/Jguer/go-alpm/v2"
+
 	"github.com/Jguer/yay/v10/pkg/stringset"
 	"github.com/Jguer/yay/v10/pkg/text"
 )
 
 type Order struct {
 	Aur     []Base
-	Repo    []db.RepoPackage
+	Repo    []alpm.IPackage
 	Runtime stringset.StringSet
 }
 
 func makeOrder() *Order {
 	return &Order{
 		make([]Base, 0),
-		make([]db.RepoPackage, 0),
+		make([]alpm.IPackage, 0),
 		make(stringset.StringSet),
 	}
 }
@@ -78,7 +79,7 @@ func (do *Order) orderPkgAur(pkg *rpc.Pkg, dp *Pool, runtime bool) {
 	do.Aur = append(do.Aur, Base{pkg})
 }
 
-func (do *Order) orderPkgRepo(pkg db.RepoPackage, dp *Pool, runtime bool) {
+func (do *Order) orderPkgRepo(pkg alpm.IPackage, dp *Pool, runtime bool) {
 	if runtime {
 		do.Runtime.Set(pkg.Name())
 	}

+ 7 - 5
pkg/dep/depPool.go

@@ -12,6 +12,8 @@ import (
 	"github.com/leonelquinteros/gotext"
 	rpc "github.com/mikkeloscar/aur"
 
+	alpm "github.com/Jguer/go-alpm/v2"
+
 	"github.com/Jguer/yay/v10/pkg/db"
 	"github.com/Jguer/yay/v10/pkg/query"
 	"github.com/Jguer/yay/v10/pkg/settings"
@@ -53,7 +55,7 @@ func (t Target) String() string {
 type Pool struct {
 	Targets      []Target
 	Explicit     stringset.StringSet
-	Repo         map[string]db.RepoPackage
+	Repo         map[string]alpm.IPackage
 	Aur          map[string]*rpc.Pkg
 	AurCache     map[string]*rpc.Pkg
 	Groups       []string
@@ -65,7 +67,7 @@ func makePool(dbExecutor db.Executor) *Pool {
 	dp := &Pool{
 		make([]Target, 0),
 		make(stringset.StringSet),
-		make(map[string]db.RepoPackage),
+		make(map[string]alpm.IPackage),
 		make(map[string]*rpc.Pkg),
 		make(map[string]*rpc.Pkg),
 		make([]string, 0),
@@ -99,7 +101,7 @@ func (dp *Pool) ResolveTargets(pkgs []string,
 			continue
 		}
 
-		var foundPkg db.RepoPackage
+		var foundPkg alpm.IPackage
 
 		// aur/ prefix means we only check the aur
 		if target.DB == "aur" || mode == settings.ModeAUR {
@@ -324,7 +326,7 @@ func (dp *Pool) resolveAURPackages(pkgs stringset.StringSet,
 	return err
 }
 
-func (dp *Pool) ResolveRepoDependency(pkg db.RepoPackage) {
+func (dp *Pool) ResolveRepoDependency(pkg alpm.IPackage) {
 	dp.Repo[pkg.Name()] = pkg
 
 	for _, dep := range dp.AlpmExecutor.PackageDepends(pkg) {
@@ -438,7 +440,7 @@ func (dp *Pool) findSatisfierAurCache(dep string, ignoreProviders, noConfirm, pr
 	return nil
 }
 
-func (dp *Pool) findSatisfierRepo(dep string) db.RepoPackage {
+func (dp *Pool) findSatisfierRepo(dep string) alpm.IPackage {
 	for _, pkg := range dp.Repo {
 		if satisfiesRepo(dep, pkg, dp.AlpmExecutor) {
 			return pkg

+ 3 - 1
pkg/query/filter.go

@@ -3,6 +3,8 @@ package query
 import (
 	"github.com/leonelquinteros/gotext"
 
+	"github.com/Jguer/go-alpm/v2"
+
 	"github.com/Jguer/yay/v10/pkg/db"
 	"github.com/Jguer/yay/v10/pkg/settings"
 	"github.com/Jguer/yay/v10/pkg/text"
@@ -25,7 +27,7 @@ outer:
 
 // GetRemotePackages returns packages with no correspondence in SyncDBS.
 func GetRemotePackages(dbExecutor db.Executor) (
-	remote []db.RepoPackage,
+	remote []alpm.IPackage,
 	remoteNames []string) {
 outer:
 	for _, localpkg := range dbExecutor.LocalPackages() {

+ 8 - 4
pkg/vcs/vcs_test.go

@@ -246,9 +246,12 @@ func TestInfoStore_Update(t *testing.T) {
 		fields fields
 		args   args
 	}{
-		{name: "simple",
-			args: args{pkgName: "hello",
-				sources: []gosrc.ArchString{{Value: "git://github.com/jguer/yay.git#branch=master"}}},
+		{
+			name: "simple",
+			args: args{
+				pkgName: "hello",
+				sources: []gosrc.ArchString{{Value: "git://github.com/jguer/yay.git#branch=master"}},
+			},
 			fields: fields{
 				OriginsByPackage: make(map[string]OriginInfoByURL),
 				CmdBuilder:       &exe.CmdBuilder{GitBin: "git", GitFlags: []string{""}},
@@ -305,7 +308,8 @@ func TestInfoStore_Remove(t *testing.T) {
 		fields fields
 		args   args
 	}{
-		{name: "simple",
+		{
+			name: "simple",
 			args: args{pkgs: []string{"a", "c"}},
 			fields: fields{
 				OriginsByPackage: map[string]OriginInfoByURL{

+ 2 - 2
query.go

@@ -7,7 +7,7 @@ import (
 	"sort"
 	"strings"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	"github.com/leonelquinteros/gotext"
 	rpc "github.com/mikkeloscar/aur"
 
@@ -22,7 +22,7 @@ import (
 type aurQuery []rpc.Pkg
 
 // Query holds the results of a repository search.
-type repoQuery []db.RepoPackage
+type repoQuery []alpm.IPackage
 
 func (s repoQuery) Reverse() {
 	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {

+ 7 - 7
upgrade.go

@@ -6,7 +6,7 @@ import (
 	"strings"
 	"sync"
 
-	"github.com/Jguer/go-alpm/v2"
+	alpm "github.com/Jguer/go-alpm/v2"
 	"github.com/leonelquinteros/gotext"
 
 	"github.com/Jguer/yay/v10/pkg/db"
@@ -99,10 +99,10 @@ func upList(warnings *query.AURWarnings, dbExecutor db.Executor, enableDowngrade
 }
 
 func upDevel(
-	remote []db.RepoPackage,
+	remote []alpm.IPackage,
 	aurdata map[string]*rpc.Pkg,
 	localCache *vcs.InfoStore) upgrade.UpSlice {
-	toUpdate := make([]db.RepoPackage, 0, len(aurdata))
+	toUpdate := make([]alpm.IPackage, 0, len(aurdata))
 	toRemove := make([]string, 0)
 
 	var mux1, mux2 sync.Mutex
@@ -155,7 +155,7 @@ func upDevel(
 	return toUpgrade
 }
 
-func printIgnoringPackage(pkg db.RepoPackage, newPkgVersion string) {
+func printIgnoringPackage(pkg alpm.IPackage, newPkgVersion string) {
 	left, right := upgrade.GetVersionDiff(pkg.Version(), newPkgVersion)
 
 	text.Warnln(gotext.Get("%s: ignoring package upgrade (%s => %s)",
@@ -166,7 +166,7 @@ func printIgnoringPackage(pkg db.RepoPackage, newPkgVersion string) {
 
 // upAUR gathers foreign packages and checks if they have new versions.
 // Output: Upgrade type package list.
-func upAUR(remote []db.RepoPackage, aurdata map[string]*rpc.Pkg, timeUpdate bool) upgrade.UpSlice {
+func upAUR(remote []alpm.IPackage, aurdata map[string]*rpc.Pkg, timeUpdate bool) upgrade.UpSlice {
 	toUpgrade := make(upgrade.UpSlice, 0)
 
 	for _, pkg := range remote {
@@ -195,7 +195,7 @@ func upAUR(remote []db.RepoPackage, aurdata map[string]*rpc.Pkg, timeUpdate bool
 }
 
 func printLocalNewerThanAUR(
-	remote []db.RepoPackage, aurdata map[string]*rpc.Pkg) {
+	remote []alpm.IPackage, aurdata map[string]*rpc.Pkg) {
 	for _, pkg := range remote {
 		aurPkg, ok := aurdata[pkg.Name()]
 		if !ok {
@@ -223,7 +223,7 @@ func isDevelName(name string) bool {
 	return strings.Contains(name, "-always-")
 }
 
-func isDevelPackage(pkg db.RepoPackage) bool {
+func isDevelPackage(pkg alpm.IPackage) bool {
 	return isDevelName(pkg.Name()) || isDevelName(pkg.Base())
 }
 

+ 11 - 10
upgrade_test.go

@@ -13,7 +13,8 @@ import (
 	rpc "github.com/mikkeloscar/aur"
 	"github.com/stretchr/testify/assert"
 
-	"github.com/Jguer/yay/v10/pkg/db"
+	alpm "github.com/Jguer/go-alpm/v2"
+
 	"github.com/Jguer/yay/v10/pkg/db/mock"
 	"github.com/Jguer/yay/v10/pkg/settings"
 	"github.com/Jguer/yay/v10/pkg/upgrade"
@@ -22,7 +23,7 @@ import (
 
 func Test_upAUR(t *testing.T) {
 	type args struct {
-		remote     []db.RepoPackage
+		remote     []alpm.IPackage
 		aurdata    map[string]*rpc.Pkg
 		timeUpdate bool
 	}
@@ -34,7 +35,7 @@ func Test_upAUR(t *testing.T) {
 		{
 			name: "No Updates",
 			args: args{
-				remote: []db.RepoPackage{
+				remote: []alpm.IPackage{
 					&mock.Package{PName: "hello", PVersion: "2.0.0"},
 					&mock.Package{PName: "local_pkg", PVersion: "1.1.0"},
 					&mock.Package{PName: "ignored", PVersion: "1.0.0", PShouldIgnore: true},
@@ -50,7 +51,7 @@ func Test_upAUR(t *testing.T) {
 		{
 			name: "Simple Update",
 			args: args{
-				remote:     []db.RepoPackage{&mock.Package{PName: "hello", PVersion: "2.0.0"}},
+				remote:     []alpm.IPackage{&mock.Package{PName: "hello", PVersion: "2.0.0"}},
 				aurdata:    map[string]*rpc.Pkg{"hello": {Version: "2.1.0", Name: "hello"}},
 				timeUpdate: false,
 			},
@@ -59,7 +60,7 @@ func Test_upAUR(t *testing.T) {
 		{
 			name: "Time Update",
 			args: args{
-				remote:     []db.RepoPackage{&mock.Package{PName: "hello", PVersion: "2.0.0", PBuildDate: time.Now()}},
+				remote:     []alpm.IPackage{&mock.Package{PName: "hello", PVersion: "2.0.0", PBuildDate: time.Now()}},
 				aurdata:    map[string]*rpc.Pkg{"hello": {Version: "2.0.0", Name: "hello", LastModified: int(time.Now().AddDate(0, 0, 2).Unix())}},
 				timeUpdate: true,
 			},
@@ -120,7 +121,7 @@ func Test_upDevel(t *testing.T) {
 	}
 
 	type args struct {
-		remote  []db.RepoPackage
+		remote  []alpm.IPackage
 		aurdata map[string]*rpc.Pkg
 		cached  vcs.InfoStore
 	}
@@ -137,7 +138,7 @@ func Test_upDevel(t *testing.T) {
 					Runner:     config.Runtime.CmdRunner,
 					CmdBuilder: config.Runtime.CmdBuilder,
 				},
-				remote: []db.RepoPackage{
+				remote: []alpm.IPackage{
 					&mock.Package{PName: "hello", PVersion: "2.0.0"},
 					&mock.Package{PName: "local_pkg", PVersion: "1.1.0"},
 					&mock.Package{PName: "ignored", PVersion: "1.0.0", PShouldIgnore: true},
@@ -192,7 +193,7 @@ func Test_upDevel(t *testing.T) {
 						},
 					},
 				},
-				remote: []db.RepoPackage{
+				remote: []alpm.IPackage{
 					&mock.Package{PName: "hello", PVersion: "2.0.0"},
 					&mock.Package{PName: "hello2", PVersion: "3.0.0"},
 					&mock.Package{PName: "hello4", PVersion: "4.0.0"},
@@ -235,7 +236,7 @@ func Test_upDevel(t *testing.T) {
 						},
 					},
 				},
-				remote:  []db.RepoPackage{&mock.Package{PName: "hello", PVersion: "2.0.0"}},
+				remote:  []alpm.IPackage{&mock.Package{PName: "hello", PVersion: "2.0.0"}},
 				aurdata: map[string]*rpc.Pkg{"hello": {Version: "2.0.0", Name: "hello"}},
 			},
 			want: upgrade.UpSlice{},
@@ -257,7 +258,7 @@ func Test_upDevel(t *testing.T) {
 						},
 					},
 				},
-				remote:  []db.RepoPackage{&mock.Package{PName: "hello", PVersion: "2.0.0", PShouldIgnore: true}},
+				remote:  []alpm.IPackage{&mock.Package{PName: "hello", PVersion: "2.0.0", PShouldIgnore: true}},
 				aurdata: map[string]*rpc.Pkg{"hello": {Version: "2.0.0", Name: "hello"}},
 			},
 			want: upgrade.UpSlice{},