mirror of
https://github.com/Jguer/yay
synced 2024-10-31 13:42:27 +00:00
Use new dependency code in install()
The old depTree and depCatagories has been changed to depPool and depOrder in the install function.
This commit is contained in:
parent
b585cec123
commit
2e7a022b7c
3 changed files with 67 additions and 60 deletions
18
depOrder.go
18
depOrder.go
|
@ -133,3 +133,21 @@ func (do *depOrder) getBases() {
|
|||
do.Bases[pkg.PackageBase] = append(do.Bases[pkg.PackageBase], pkg)
|
||||
}
|
||||
}
|
||||
|
||||
func (do *depOrder) HasMake() bool {
|
||||
return len(do.Runtime) != len(do.Aur)+len(do.Repo)
|
||||
}
|
||||
|
||||
func (do *depOrder) getMake() []string {
|
||||
makeOnly := make([]string, 0, len(do.Aur)+len(do.Repo)-len(do.Runtime))
|
||||
|
||||
for _, pkg := range do.Aur {
|
||||
makeOnly = append(makeOnly, pkg.Name)
|
||||
}
|
||||
|
||||
for _, pkg := range do.Repo {
|
||||
makeOnly = append(makeOnly, pkg.Name())
|
||||
}
|
||||
|
||||
return makeOnly
|
||||
}
|
||||
|
|
73
install.go
73
install.go
|
@ -18,7 +18,7 @@ func install(parser *arguments) error {
|
|||
requestTargets := parser.targets.toSlice()
|
||||
var err error
|
||||
var incompatible stringSet
|
||||
var dc *depCatagories
|
||||
var do *depOrder
|
||||
var toClean []*rpc.Pkg
|
||||
var toEdit []*rpc.Pkg
|
||||
|
||||
|
@ -61,7 +61,17 @@ func install(parser *arguments) error {
|
|||
//if len(aurTargets) > 0 || parser.existsArg("u", "sysupgrade") && len(remoteNames) > 0 {
|
||||
// fmt.Println(bold(cyan("::") + " Querying AUR..."))
|
||||
//}
|
||||
dt, err := getDepTree(requestTargets, warnings)
|
||||
dp, err := getDepPool(cmdArgs.targets.toSlice())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dp.CheckMissing()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = dp.CheckConflicts()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -79,16 +89,6 @@ func install(parser *arguments) error {
|
|||
requestTargets[i] = name
|
||||
}
|
||||
|
||||
if len(dt.Missing) > 0 {
|
||||
str := bold(red(arrow+" Error: ")) + "Could not find all required packages:"
|
||||
|
||||
for name := range dt.Missing {
|
||||
str += "\n " + name
|
||||
}
|
||||
|
||||
return fmt.Errorf("%s", str)
|
||||
}
|
||||
|
||||
//create the arguments to pass for the repo install
|
||||
arguments := parser.copy()
|
||||
arguments.delArg("y", "refresh")
|
||||
|
@ -131,61 +131,50 @@ func install(parser *arguments) error {
|
|||
}
|
||||
}
|
||||
|
||||
hasAur := false
|
||||
for pkg := range parser.targets {
|
||||
_, ok := dt.Aur[pkg]
|
||||
if ok {
|
||||
hasAur = true
|
||||
}
|
||||
}
|
||||
hasAur := len(dp.Aur) > 0
|
||||
|
||||
if hasAur && 0 == os.Geteuid() {
|
||||
return fmt.Errorf(bold(red(arrow)) + " Refusing to install AUR Packages as root, Aborting.")
|
||||
}
|
||||
|
||||
dc, err = getDepCatagories(requestTargets, dt)
|
||||
do = getDepOrder(dp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, pkg := range dc.Repo {
|
||||
for _, pkg := range do.Repo {
|
||||
arguments.addTarget(pkg.DB().Name() + "/" + pkg.Name())
|
||||
}
|
||||
|
||||
for pkg := range dt.Groups {
|
||||
for _, pkg := range dp.Groups {
|
||||
arguments.addTarget(pkg)
|
||||
}
|
||||
|
||||
if len(dc.Aur) == 0 && len(arguments.targets) == 0 && !parser.existsArg("u", "sysupgrade") {
|
||||
if len(do.Aur) == 0 && len(arguments.targets) == 0 && !parser.existsArg("u", "sysupgrade") {
|
||||
fmt.Println("There is nothing to do")
|
||||
return nil
|
||||
}
|
||||
|
||||
if hasAur {
|
||||
hasAur = len(dc.Aur) != 0
|
||||
hasAur = len(do.Aur) != 0
|
||||
|
||||
err = checkForAllConflicts(dc)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printDepCatagories(dc)
|
||||
do.Print()
|
||||
fmt.Println()
|
||||
|
||||
if len(dc.MakeOnly) > 0 {
|
||||
if do.HasMake() {
|
||||
if !continueTask("Remove make dependencies after install?", "yY") {
|
||||
removeMake = true
|
||||
}
|
||||
}
|
||||
|
||||
toClean, toEdit, err = cleanEditNumberMenu(dc.Aur, dc.Bases, remoteNamesCache)
|
||||
toClean, toEdit, err = cleanEditNumberMenu(do.Aur, do.Bases, remoteNamesCache)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cleanBuilds(toClean)
|
||||
|
||||
err = downloadPkgBuilds(dc.Aur, parser.targets, dc.Bases)
|
||||
err = downloadPkgBuilds(do.Aur, parser.targets, do.Bases)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -205,17 +194,17 @@ func install(parser *arguments) error {
|
|||
}
|
||||
|
||||
//initial srcinfo parse before pkgver() bump
|
||||
err = parseSRCINFOFiles(dc.Aur, srcinfosStale, dc.Bases)
|
||||
err = parseSRCINFOFiles(do.Aur, srcinfosStale, do.Bases)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
incompatible, err = getIncompatible(dc.Aur, srcinfosStale, dc.Bases)
|
||||
incompatible, err = getIncompatible(do.Aur, srcinfosStale, do.Bases)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = checkPgpKeys(dc.Aur, dc.Bases, srcinfosStale)
|
||||
err = checkPgpKeys(do.Aur, do.Bases, srcinfosStale)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -230,7 +219,7 @@ func install(parser *arguments) error {
|
|||
depArguments := makeArguments()
|
||||
depArguments.addArg("D", "asdeps")
|
||||
|
||||
for _, pkg := range dc.Repo {
|
||||
for _, pkg := range do.Repo {
|
||||
if !parser.targets.get(pkg.Name()) && !localNamesCache.get(pkg.Name()) && !remoteNamesCache.get(pkg.Name()) {
|
||||
depArguments.addTarget(pkg.Name())
|
||||
}
|
||||
|
@ -250,17 +239,17 @@ func install(parser *arguments) error {
|
|||
uask := alpm.QuestionType(ask) | alpm.QuestionTypeConflictPkg
|
||||
cmdArgs.globals["ask"] = fmt.Sprint(uask)
|
||||
|
||||
err = downloadPkgBuildsSources(dc.Aur, dc.Bases, incompatible)
|
||||
err = downloadPkgBuildsSources(do.Aur, do.Bases, incompatible)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = buildInstallPkgBuilds(dc.Aur, srcinfosStale, parser.targets, parser, dc.Bases, incompatible)
|
||||
err = buildInstallPkgBuilds(do.Aur, srcinfosStale, parser.targets, parser, do.Bases, incompatible)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(dc.MakeOnly) > 0 {
|
||||
if do.HasMake() {
|
||||
if !removeMake {
|
||||
return nil
|
||||
}
|
||||
|
@ -268,7 +257,7 @@ func install(parser *arguments) error {
|
|||
removeArguments := makeArguments()
|
||||
removeArguments.addArg("R", "u")
|
||||
|
||||
for pkg := range dc.MakeOnly {
|
||||
for _, pkg := range do.getMake() {
|
||||
removeArguments.addTarget(pkg)
|
||||
}
|
||||
|
||||
|
@ -283,7 +272,7 @@ func install(parser *arguments) error {
|
|||
}
|
||||
|
||||
if config.CleanAfter {
|
||||
clean(dc.Aur)
|
||||
clean(do.Aur)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
36
print.go
36
print.go
|
@ -189,7 +189,7 @@ func (u upSlice) print() {
|
|||
}
|
||||
|
||||
// printDownloadsFromRepo prints repository packages to be downloaded
|
||||
func printDepCatagories(dc *depCatagories) {
|
||||
func (do *depOrder) Print() {
|
||||
repo := ""
|
||||
repoMake := ""
|
||||
aur := ""
|
||||
|
@ -200,47 +200,47 @@ func printDepCatagories(dc *depCatagories) {
|
|||
aurLen := 0
|
||||
aurMakeLen := 0
|
||||
|
||||
for _, pkg := range dc.Repo {
|
||||
if dc.MakeOnly.get(pkg.Name()) {
|
||||
repoMake += " " + pkg.Name() + "-" + pkg.Version()
|
||||
repoMakeLen++
|
||||
} else {
|
||||
for _, pkg := range do.Repo {
|
||||
if do.Runtime.get(pkg.Name()) {
|
||||
repo += " " + pkg.Name() + "-" + pkg.Version()
|
||||
repoLen++
|
||||
} else {
|
||||
repoMake += " " + pkg.Name() + "-" + pkg.Version()
|
||||
repoMakeLen++
|
||||
}
|
||||
}
|
||||
|
||||
for _, pkg := range dc.Aur {
|
||||
for _, pkg := range do.Aur {
|
||||
pkgStr := " " + pkg.PackageBase + "-" + pkg.Version
|
||||
pkgStrMake := pkgStr
|
||||
|
||||
push := false
|
||||
pushMake := false
|
||||
|
||||
if len(dc.Bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
||||
if len(do.Bases[pkg.PackageBase]) > 1 || pkg.PackageBase != pkg.Name {
|
||||
pkgStr += " ("
|
||||
pkgStrMake += " ("
|
||||
|
||||
for _, split := range dc.Bases[pkg.PackageBase] {
|
||||
if dc.MakeOnly.get(split.Name) {
|
||||
pkgStrMake += split.Name + " "
|
||||
aurMakeLen++
|
||||
pushMake = true
|
||||
} else {
|
||||
for _, split := range do.Bases[pkg.PackageBase] {
|
||||
if do.Runtime.get(split.Name) {
|
||||
pkgStr += split.Name + " "
|
||||
aurLen++
|
||||
push = true
|
||||
} else {
|
||||
pkgStrMake += split.Name + " "
|
||||
aurMakeLen++
|
||||
pushMake = true
|
||||
}
|
||||
}
|
||||
|
||||
pkgStr = pkgStr[:len(pkgStr)-1] + ")"
|
||||
pkgStrMake = pkgStrMake[:len(pkgStrMake)-1] + ")"
|
||||
} else if dc.MakeOnly.get(pkg.Name) {
|
||||
aurMakeLen++
|
||||
pushMake = true
|
||||
} else {
|
||||
} else if do.Runtime.get(pkg.Name) {
|
||||
aurLen++
|
||||
push = true
|
||||
} else {
|
||||
aurMakeLen++
|
||||
pushMake = true
|
||||
}
|
||||
|
||||
if push {
|
||||
|
|
Loading…
Reference in a new issue