Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for db/name #235

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd.go
Original file line number Diff line number Diff line change
@@ -574,10 +574,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())
}
}

@@ -588,10 +588,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)
}
}

29 changes: 24 additions & 5 deletions dependencies.go
Original file line number Diff line number Diff line change
@@ -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)
@@ -258,10 +270,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
}

@@ -270,7 +285,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)
12 changes: 5 additions & 7 deletions install.go
Original file line number Diff line number Diff line change
@@ -17,17 +17,15 @@ 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
}

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")
13 changes: 5 additions & 8 deletions query.go
Original file line number Diff line number Diff line change
@@ -228,23 +228,20 @@ 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)
found = errdb == nil
}

if found {
repo = append(repo, pkg)
repo = append(repo, _pkg)
} else {
aur = append(aur, pkg)
aur = append(aur, _pkg)
}
}