Skip to content

Commit

Permalink
support multiple targets. Remove working directory logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Jguer committed Nov 15, 2022
1 parent 3f5eb36 commit 1153ee6
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions local_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/Jguer/yay/v11/pkg/settings"
"github.com/Jguer/yay/v11/pkg/settings/parser"
"github.com/Jguer/yay/v11/pkg/text"
"github.com/Jguer/yay/v11/pkg/topo"

gosrc "github.com/Morganamilo/go-srcinfo"
"github.com/leonelquinteros/gotext"
Expand All @@ -28,29 +29,24 @@ func installLocalPKGBUILD(
) error {
aurCache := config.Runtime.AURCache

wd, err := os.Getwd()
if err != nil {
return errors.Wrap(err, gotext.Get("failed to retrieve working directory"))
}

if len(cmdArgs.Targets) > 1 {
return errors.New(gotext.Get("only one target is allowed"))
}

if len(cmdArgs.Targets) == 1 {
wd = cmdArgs.Targets[0]
}

pkgbuild, err := gosrc.ParseFile(filepath.Join(wd, ".SRCINFO"))
if err != nil {
return errors.Wrap(err, gotext.Get("failed to parse .SRCINFO"))
if len(cmdArgs.Targets) < 1 {
return errors.New(gotext.Get("no target directories specified"))
}

grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm, os.Stdout)
graph := topo.New[string, *dep.InstallInfo]()
for _, target := range cmdArgs.Targets {
var errG error

graph, err := grapher.GraphFromSrcInfo(ctx, nil, wd, pkgbuild)
if err != nil {
return err
pkgbuild, err := gosrc.ParseFile(filepath.Join(target, ".SRCINFO"))
if err != nil {
return errors.Wrap(err, gotext.Get("failed to parse .SRCINFO"))
}

graph, errG = grapher.GraphFromSrcInfo(ctx, graph, target, pkgbuild)
if errG != nil {
return err
}
}

topoSorted := graph.TopoSortedLayerMap()
Expand Down

0 comments on commit 1153ee6

Please sign in to comment.