Merge pull request #235 from Morganamilo/fix#228

Add support for db/name
This commit is contained in:
Morgana 2018-03-13 17:14:22 +00:00 committed by GitHub
commit f9d4d9bafb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 24 deletions

8
cmd.go
View file

@ -588,10 +588,10 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}
if isInclude && include.get(target) {
arguments.addTarget(pkg.Name())
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
}
if !isInclude && !exclude.get(target) {
arguments.addTarget(pkg.Name())
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
}
}
@ -602,10 +602,10 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}
if isInclude && include.get(target) {
arguments.addTarget(pkg.Name)
arguments.addTarget("aur/" + pkg.Name)
}
if !isInclude && !exclude.get(target) {
arguments.addTarget(pkg.Name)
arguments.addTarget("aur/" + pkg.Name)
}
}

View file

@ -50,6 +50,17 @@ func getNameFromDep(dep string) string {
})[0]
}
//split apart db/package to db and package
func splitDbFromName(pkg string) (string, string) {
split := strings.SplitN(pkg, "/", 2)
if len(split) == 2 {
return split[0], split[1]
} else {
return "", split[0]
}
}
// Step two of dependency resolving. We already have all the information on the
// packages we need, now it's just about ordering them correctly.
// pkgs is a list of targets, the packages we want to install. Dependencies are
@ -94,7 +105,8 @@ func getDepCatagories(pkgs []string, dt *depTree) (*depCatagories, error) {
}
for _, pkg := range pkgs {
dep := getNameFromDep(pkg)
_, name := splitDbFromName(pkg)
dep := getNameFromDep(name)
alpmpkg, exists := dt.Repo[dep]
if exists {
repoDepCatagoriesRecursive(alpmpkg, dc, dt, false)
@ -262,10 +274,13 @@ func getDepTree(pkgs []string) (*depTree, error) {
continue
}//*/
db, name := splitDbFromName(pkg)
// Check the repos for a matching dep
repoPkg, inRepos := syncDb.FindSatisfier(pkg)
if inRepos == nil {
repoTreeRecursive(repoPkg, dt, localDb, syncDb)
foundPkg, errdb := syncDb.FindSatisfier(name)
found := errdb == nil && (foundPkg.DB().Name() == db || db == "")
if found {
repoTreeRecursive(foundPkg, dt, localDb, syncDb)
continue
}
@ -274,7 +289,11 @@ func getDepTree(pkgs []string) (*depTree, error) {
continue
}
dt.ToProcess.set(pkg)
if db == "" || db == "aur" {
dt.ToProcess.set(name)
} else {
dt.Missing.set(pkg)
}
}
err = depTreeRecursive(dt, localDb, syncDb, false)

View file

@ -17,7 +17,8 @@ import (
// Install handles package installs
func install(parser *arguments) error {
removeMake := false
aurTargets, repoTargets, err := packageSlices(parser.targets.toSlice())
requestTargets := parser.targets.toSlice()
aurTargets, repoTargets, err := packageSlices(requestTargets)
if err != nil {
return err
}
@ -25,9 +26,6 @@ func install(parser *arguments) error {
srcinfos := make(map[string]*gopkg.PKGBUILD)
var dc *depCatagories
//fmt.Println(green(arrow), green("Resolving Dependencies"))
requestTargets := append(aurTargets, repoTargets...)
//remotenames: names of all non repo packages on the system
_, _, _, remoteNames, err := filterPackages()
if err != nil {
@ -106,9 +104,9 @@ func install(parser *arguments) error {
arguments.addTarget(pkg.Name())
}
for _, pkg := range repoTargets {
arguments.addTarget(pkg)
}
//for _, pkg := range repoTargets {
// arguments.addTarget(pkg)
//}
if len(dc.Aur) == 0 && len(arguments.targets) == 0 {
fmt.Println("There is nothing to do")

View file

@ -228,13 +228,10 @@ func packageSlices(toCheck []string) (aur []string, repo []string, err error) {
}
for _, _pkg := range toCheck {
if i := strings.Index(_pkg, "/"); i != -1 {
_pkg = _pkg[i+1:]
}
pkg := getNameFromDep(_pkg)
db, name := splitDbFromName(_pkg)
_, errdb := dbList.FindSatisfier(_pkg)
found := errdb == nil
foundPkg, errdb := dbList.FindSatisfier(name)
found := errdb == nil && (foundPkg.DB().Name() == db || db == "")
if !found {
_, errdb = dbList.PkgCachebyGroup(_pkg)
@ -242,9 +239,9 @@ func packageSlices(toCheck []string) (aur []string, repo []string, err error) {
}
if found {
repo = append(repo, pkg)
repo = append(repo, _pkg)
} else {
aur = append(aur, pkg)
aur = append(aur, _pkg)
}
}