move addUpgradeToGraph to depgraph

This commit is contained in:
jguer
2022-11-16 01:11:16 +01:00
parent 2805252365
commit 7f151cd603
3 changed files with 32 additions and 31 deletions

4
cmd.go
View File

@@ -179,7 +179,7 @@ func handleCmd(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Exe
return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
case "U", "upgrade":
return handleUpgrade(ctx, config, dbExecutor, cmdArgs)
return handleUpgrade(ctx, config, cmdArgs)
case "B", "build":
return handleBuild(ctx, config, dbExecutor, cmdArgs)
case "G", "getpkgbuild":
@@ -330,7 +330,7 @@ func handleGetpkgbuild(ctx context.Context, cmdArgs *parser.Arguments, dbExecuto
}
func handleUpgrade(ctx context.Context,
config *settings.Configuration, dbExecutor db.Executor, cmdArgs *parser.Arguments,
config *settings.Configuration, cmdArgs *parser.Arguments,
) error {
return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))

View File

@@ -14,6 +14,7 @@ import (
aurc "github.com/Jguer/aur"
"github.com/Jguer/aur/metadata"
alpm "github.com/Jguer/go-alpm/v2"
gosrc "github.com/Morganamilo/go-srcinfo"
"github.com/leonelquinteros/gotext"
)
@@ -490,3 +491,28 @@ func archStringToString(alpmArches []string, archString []gosrc.ArchString) []st
return pkgs
}
func AddUpgradeToGraph(pkg *db.Upgrade, graph *topo.Graph[string, *InstallInfo]) {
source := Sync
if pkg.Repository == "aur" {
source = AUR
}
reason := Explicit
if pkg.Reason == alpm.PkgReasonDepend {
reason = Dep
}
graph.AddNode(pkg.Name)
graph.SetNodeInfo(pkg.Name, &topo.NodeInfo[*InstallInfo]{
Color: colorMap[reason],
Background: bgColorMap[source],
Value: &InstallInfo{
Source: source,
Reason: reason,
Version: pkg.RemoteVersion,
AURBase: &pkg.Base,
SyncDBName: &pkg.Repository,
},
})
}

View File

@@ -311,12 +311,12 @@ func sysupgradeTargetsV2(ctx context.Context,
}
if isInclude && !include.Get(len(repoUp.Up)-i+len(aurUp.Up)) {
addUpgradeToGraph(pkg, graph)
dep.AddUpgradeToGraph(pkg, graph)
continue
}
if !isInclude && (exclude.Get(len(repoUp.Up)-i+len(aurUp.Up)) || otherExclude.Get(pkg.Repository)) {
addUpgradeToGraph(pkg, graph)
dep.AddUpgradeToGraph(pkg, graph)
continue
}
@@ -330,38 +330,13 @@ func sysupgradeTargetsV2(ctx context.Context,
}
if isInclude && !include.Get(len(aurUp.Up)-i) {
addUpgradeToGraph(pkg, graph)
dep.AddUpgradeToGraph(pkg, graph)
}
if !isInclude && (exclude.Get(len(aurUp.Up)-i) || otherExclude.Get(pkg.Repository)) {
addUpgradeToGraph(pkg, graph)
dep.AddUpgradeToGraph(pkg, graph)
}
}
return graph, ignore, err
}
func addUpgradeToGraph(pkg *db.Upgrade, graph *topo.Graph[string, *dep.InstallInfo]) {
source := dep.Sync
if pkg.Repository == "aur" {
source = dep.AUR
}
reason := dep.Explicit
if pkg.Reason == alpm.PkgReasonDepend {
reason = dep.Dep
}
graph.AddNode(pkg.Name)
graph.SetNodeInfo(pkg.Name, &topo.NodeInfo[*dep.InstallInfo]{
Color: "",
Background: "",
Value: &dep.InstallInfo{
Source: source,
Reason: reason,
Version: pkg.RemoteVersion,
AURBase: &pkg.Base,
SyncDBName: &pkg.Repository,
},
})
}