Skip to content

Commit

Permalink
Update go-alpm
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Feb 4, 2019
1 parent dcc323c commit 5ce4a49
Show file tree
Hide file tree
Showing 27 changed files with 364 additions and 365 deletions.
6 changes: 3 additions & 3 deletions callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func questionCallback(question alpm.QuestionAny) {
var db string

qp.Providers(alpmHandle).ForEach(func(pkg alpm.Package) error {
thisDb := pkg.DB().Name()
thisDB := pkg.DB().Name()

if db != thisDb {
db = thisDb
if db != thisDB {
db = thisDB
str += bold(cyan("\n:: ")) + bold("Repository "+db+"\n ")
}
str += fmt.Sprintf("%d) %s ", size, pkg.Name())
Expand Down
4 changes: 2 additions & 2 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func syncList(parser *arguments) error {
}

if (mode == modeAny || mode == modeAUR) && (len(parser.targets) == 0 || aur) {
localDb, err := alpmHandle.LocalDb()
localDB, err := alpmHandle.LocalDB()
if err != nil {
return err
}
Expand All @@ -419,7 +419,7 @@ func syncList(parser *arguments) error {
} else {
fmt.Printf("%s %s %s", magenta("aur"), bold(name), bold(green("unknown-version")))

if _, err := localDb.PkgByName(name); err == nil {
if _, err := localDB.Pkg(name); err == nil {
fmt.Print(bold(blue(" [Installed]")))
}

Expand Down
4 changes: 2 additions & 2 deletions completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ func createAURList(out *os.File) (err error) {

//CreatePackageList appends Repo packages to completion cache
func createRepoList(out *os.File) (err error) {
dbList, err := alpmHandle.SyncDbs()
dbList, err := alpmHandle.SyncDBs()
if err != nil {
return
}

_ = dbList.ForEach(func(db alpm.Db) error {
_ = dbList.ForEach(func(db alpm.DB) error {
_ = db.PkgCache().ForEach(func(pkg alpm.Package) error {
out.WriteString(pkg.Name())
out.WriteString("\t" + pkg.DB().Name() + "\n")
Expand Down
12 changes: 6 additions & 6 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ func configureAlpm(conf *pacmanconf.Config) error {

for _, repo := range pacmanConf.Repos {
// TODO: set SigLevel
db, err := alpmHandle.RegisterSyncDb(repo.Name, 0)
db, err := alpmHandle.RegisterSyncDB(repo.Name, 0)
if err != nil {
return err
}
Expand All @@ -371,7 +371,7 @@ func configureAlpm(conf *pacmanconf.Config) error {

}

if err = alpmHandle.SetCacheDirs(pacmanConf.CacheDir...); err != nil {
if err = alpmHandle.SetCacheDirs(pacmanConf.CacheDir); err != nil {
return err
}

Expand All @@ -390,23 +390,23 @@ func configureAlpm(conf *pacmanconf.Config) error {
return err
}

if err = alpmHandle.SetIgnorePkgs(pacmanConf.IgnorePkg...); err != nil {
if err = alpmHandle.SetIgnorePkgs(pacmanConf.IgnorePkg); err != nil {
return err
}

if err = alpmHandle.SetIgnoreGroups(pacmanConf.IgnoreGroup...); err != nil {
if err = alpmHandle.SetIgnoreGroups(pacmanConf.IgnoreGroup); err != nil {
return err
}

if err = alpmHandle.SetArch(pacmanConf.Architecture); err != nil {
return err
}

if err = alpmHandle.SetNoUpgrades(pacmanConf.NoUpgrade...); err != nil {
if err = alpmHandle.SetNoUpgrades(pacmanConf.NoUpgrade); err != nil {
return err
}

if alpmHandle.SetNoExtracts(pacmanConf.NoExtract...); err != nil {
if alpmHandle.SetNoExtracts(pacmanConf.NoExtract); err != nil {
return err
}

Expand Down
2 changes: 1 addition & 1 deletion dep.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func satisfiesRepo(dep string, pkg *alpm.Package) bool {
}

//split apart db/package to db and package
func splitDbFromName(pkg string) (string, string) {
func splitDBFromName(pkg string) (string, string) {
split := strings.SplitN(pkg, "/", 2)

if len(split) == 2 {
Expand Down
8 changes: 4 additions & 4 deletions depCheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (dp *depPool) checkInnerConflict(name string, conflict string, conflicts ma
}

func (dp *depPool) checkForwardConflict(name string, conflict string, conflicts mapStringSet) {
dp.LocalDb.PkgCache().ForEach(func(pkg alpm.Package) error {
dp.LocalDB.PkgCache().ForEach(func(pkg alpm.Package) error {
if pkg.Name() == name || dp.hasPackage(pkg.Name()) {
return nil
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (dp *depPool) checkForwardConflicts(conflicts mapStringSet) {
}

func (dp *depPool) checkReverseConflicts(conflicts mapStringSet) {
dp.LocalDb.PkgCache().ForEach(func(pkg alpm.Package) error {
dp.LocalDB.PkgCache().ForEach(func(pkg alpm.Package) error {
if dp.hasPackage(pkg.Name()) {
return nil
}
Expand Down Expand Up @@ -227,7 +227,7 @@ func (dp *depPool) _checkMissing(dep string, stack []string, missing *missing) {
missing.Good.set(dep)
for _, deps := range [3][]string{aurPkg.Depends, aurPkg.MakeDepends, aurPkg.CheckDepends} {
for _, aurDep := range deps {
if _, err := dp.LocalDb.PkgCache().FindSatisfier(aurDep); err == nil {
if _, err := dp.LocalDB.PkgCache().FindSatisfier(aurDep); err == nil {
missing.Good.set(aurDep)
continue
}
Expand All @@ -243,7 +243,7 @@ func (dp *depPool) _checkMissing(dep string, stack []string, missing *missing) {
if repoPkg != nil {
missing.Good.set(dep)
repoPkg.Depends().ForEach(func(repoDep alpm.Depend) error {
if _, err := dp.LocalDb.PkgCache().FindSatisfier(repoDep.String()); err == nil {
if _, err := dp.LocalDB.PkgCache().FindSatisfier(repoDep.String()); err == nil {
missing.Good.set(repoDep.String())
return nil
}
Expand Down
50 changes: 25 additions & 25 deletions depPool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import (
)

type target struct {
Db string
DB string
Name string
Mod string
Version string
}

func toTarget(pkg string) target {
db, dep := splitDbFromName(pkg)
db, dep := splitDBFromName(pkg)
name, mod, version := splitDep(dep)

return target{
Expand All @@ -33,8 +33,8 @@ func (t target) DepString() string {
}

func (t target) String() string {
if t.Db != "" {
return t.Db + "/" + t.DepString()
if t.DB != "" {
return t.DB + "/" + t.DepString()
}

return t.DepString()
Expand All @@ -47,17 +47,17 @@ type depPool struct {
Aur map[string]*rpc.Pkg
AurCache map[string]*rpc.Pkg
Groups []string
LocalDb *alpm.Db
SyncDb alpm.DbList
LocalDB *alpm.DB
SyncDB alpm.DBList
Warnings *aurWarnings
}

func makeDepPool() (*depPool, error) {
localDb, err := alpmHandle.LocalDb()
localDB, err := alpmHandle.LocalDB()
if err != nil {
return nil, err
}
syncDb, err := alpmHandle.SyncDbs()
syncDB, err := alpmHandle.SyncDBs()
if err != nil {
return nil, err
}
Expand All @@ -69,8 +69,8 @@ func makeDepPool() (*depPool, error) {
make(map[string]*rpc.Pkg),
make(map[string]*rpc.Pkg),
make([]string, 0),
localDb,
syncDb,
localDB,
syncDB,
nil,
}

Expand Down Expand Up @@ -100,25 +100,25 @@ func (dp *depPool) ResolveTargets(pkgs []string) error {
}

var foundPkg *alpm.Package
var singleDb *alpm.Db
var singleDB *alpm.DB

// aur/ prefix means we only check the aur
if target.Db == "aur" || mode == modeAUR {
if target.DB == "aur" || mode == modeAUR {
dp.Targets = append(dp.Targets, target)
aurTargets.set(target.DepString())
continue
}

// If there'ss a different priefix only look in that repo
if target.Db != "" {
singleDb, err = alpmHandle.SyncDbByName(target.Db)
if target.DB != "" {
singleDB, err = alpmHandle.SyncDBByName(target.DB)
if err != nil {
return err
}
foundPkg, err = singleDb.PkgCache().FindSatisfier(target.DepString())
foundPkg, err = singleDB.PkgCache().FindSatisfier(target.DepString())
//otherwise find it in any repo
} else {
foundPkg, err = dp.SyncDb.FindSatisfier(target.DepString())
foundPkg, err = dp.SyncDB.FindSatisfier(target.DepString())
}

if err == nil {
Expand All @@ -130,11 +130,11 @@ func (dp *depPool) ResolveTargets(pkgs []string) error {
//check for groups
//currently we don't resolve the packages in a group
//only check if the group exists
//would be better to check the groups from singleDb if
//would be better to check the groups from singleDB if
//the user specified a db but there's no easy way to do
//it without making alpm_lists so don't bother for now
//db/group is probably a rare use case
group, err := dp.SyncDb.PkgCachebyGroup(target.Name)
group, err := dp.SyncDB.FindGroupPkgs(target.Name)
if err == nil {
dp.Groups = append(dp.Groups, target.String())
group.ForEach(func(pkg alpm.Package) error {
Expand All @@ -146,7 +146,7 @@ func (dp *depPool) ResolveTargets(pkgs []string) error {
}

//if there was no db prefix check the aur
if target.Db == "" {
if target.DB == "" {
aurTargets.set(target.DepString())
}

Expand Down Expand Up @@ -207,7 +207,7 @@ func (dp *depPool) findProvides(pkgs stringSet) error {
}

for pkg := range pkgs {
if _, err := dp.LocalDb.PkgByName(pkg); err == nil {
if _, err := dp.LocalDB.Pkg(pkg); err == nil {
continue
}
wg.Add(1)
Expand Down Expand Up @@ -301,10 +301,10 @@ func (dp *depPool) resolveAURPackages(pkgs stringSet, explicit bool) error {
continue
}

_, isInstalled := dp.LocalDb.PkgCache().FindSatisfier(dep) //has satisfier installed: skip
_, isInstalled := dp.LocalDB.PkgCache().FindSatisfier(dep) //has satisfier installed: skip
hm := hideMenus
hideMenus = isInstalled == nil
repoPkg, inRepos := dp.SyncDb.FindSatisfier(dep) //has satisfier in repo: fetch it
repoPkg, inRepos := dp.SyncDB.FindSatisfier(dep) //has satisfier in repo: fetch it
hideMenus = hm
if isInstalled == nil && (config.ReBuild != "tree" || inRepos == nil) {
continue
Expand Down Expand Up @@ -335,13 +335,13 @@ func (dp *depPool) ResolveRepoDependency(pkg *alpm.Package) {
}

//has satisfier installed: skip
_, isInstalled := dp.LocalDb.PkgCache().FindSatisfier(dep.String())
_, isInstalled := dp.LocalDB.PkgCache().FindSatisfier(dep.String())
if isInstalled == nil {
return
}

//has satisfier in repo: fetch it
repoPkg, inRepos := dp.SyncDb.FindSatisfier(dep.String())
repoPkg, inRepos := dp.SyncDB.FindSatisfier(dep.String())
if inRepos != nil {
return
}
Expand Down Expand Up @@ -389,7 +389,7 @@ func (dp *depPool) findSatisfierAurCache(dep string) *rpc.Pkg {
seen := make(stringSet)
providers := makeProviders(depName)

if _, err := dp.LocalDb.PkgByName(depName); err == nil {
if _, err := dp.LocalDB.Pkg(depName); err == nil {
if pkg, ok := dp.AurCache[dep]; ok && pkgSatisfies(pkg.Name, pkg.Version, dep) {
return pkg
}
Expand Down
16 changes: 8 additions & 8 deletions download.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func getPkgbuilds(pkgs []string) error {
aur, repo, err := packageSlices(pkgs)

for n := range aur {
_, pkg := splitDbFromName(aur[n])
_, pkg := splitDBFromName(aur[n])
aur[n] = pkg
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func getPkgbuildsfromABS(pkgs []string, path string) (bool, error) {
missing := make([]string, 0)
downloaded := 0

dbList, err := alpmHandle.SyncDbs()
dbList, err := alpmHandle.SyncDBs()
if err != nil {
return false, err
}
Expand All @@ -212,15 +212,15 @@ func getPkgbuildsfromABS(pkgs []string, path string) (bool, error) {
var pkg *alpm.Package
var err error
var url string
pkgDb, name := splitDbFromName(pkgN)
pkgDB, name := splitDBFromName(pkgN)

if pkgDb != "" {
if db, err := alpmHandle.SyncDbByName(pkgDb); err == nil {
pkg, err = db.PkgByName(name)
if pkgDB != "" {
if db, err := alpmHandle.SyncDBByName(pkgDB); err == nil {
pkg, err = db.Pkg(name)
}
} else {
dbList.ForEach(func(db alpm.Db) error {
if pkg, err = db.PkgByName(name); err == nil {
dbList.ForEach(func(db alpm.DB) error {
if pkg, err = db.Pkg(name); err == nil {
return fmt.Errorf("")
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/Jguer/yay/v9
require (
github.com/Morganamilo/go-pacmanconf v0.0.0-20180910220353-9c5265e1b14f
github.com/Morganamilo/go-srcinfo v0.0.0-20180702014333-368edc79b2c5
github.com/jguer/go-alpm v0.0.0-20180914002751-643c287316a5
github.com/jguer/go-alpm v0.0.0-20181021002825-676ad6bbf3c0
github.com/mikkeloscar/aur v0.0.0-20181111113612-b71516da3ae9
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/Morganamilo/go-srcinfo v0.0.0-20180702014333-368edc79b2c5 h1:0mWTtDLD
github.com/Morganamilo/go-srcinfo v0.0.0-20180702014333-368edc79b2c5/go.mod h1:MP6VGY1NNpVUmYIEgoM9acix95KQqIRyqQ0hCLsyYUY=
github.com/jguer/go-alpm v0.0.0-20180914002751-643c287316a5 h1:JPIXUHXLZYwYUTlGpCCRMNFt8IRAyLPUsnXYqOJ6U/w=
github.com/jguer/go-alpm v0.0.0-20180914002751-643c287316a5/go.mod h1:1F60/e8oQFVJrZRH0TBqwtiB5ajJ5avOc4MoGRY9CFU=
github.com/jguer/go-alpm v0.0.0-20181021002825-676ad6bbf3c0 h1:MtH4SM1pw+23QhMERYK38DyGNqf6F3zUhxeKmQhuHC0=
github.com/jguer/go-alpm v0.0.0-20181021002825-676ad6bbf3c0/go.mod h1:1F60/e8oQFVJrZRH0TBqwtiB5ajJ5avOc4MoGRY9CFU=
github.com/mikkeloscar/aur v0.0.0-20180725140122-f998dbf94dc4 h1:qgHSZbD0g3W7KAkZFzXlSqgriYnzEUFS1gkgEiv2GrE=
github.com/mikkeloscar/aur v0.0.0-20180725140122-f998dbf94dc4/go.mod h1:n1NKHoldRNhIEufSx1PiDYcd2W+wpbz5/5K+p2eNDVk=
github.com/mikkeloscar/aur v0.0.0-20181111113612-b71516da3ae9 h1:g4TBYa1sjv/TZfU9t82oYlRneu8cCVr3dnazE7os5vw=
Expand Down
Loading

0 comments on commit 5ce4a49

Please sign in to comment.