2022-09-09 20:57:18 +02:00
|
|
|
// Experimental code for install local with dependency refactoring
|
|
|
|
// Not at feature parity with install.go
|
2022-08-21 07:14:52 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-08-22 23:28:53 +02:00
|
|
|
"path/filepath"
|
2022-12-18 21:14:41 +01:00
|
|
|
"strings"
|
2022-08-21 07:14:52 +02:00
|
|
|
|
|
|
|
"github.com/Jguer/yay/v11/pkg/db"
|
2022-08-22 23:28:53 +02:00
|
|
|
"github.com/Jguer/yay/v11/pkg/dep"
|
2022-12-29 13:34:53 +01:00
|
|
|
"github.com/Jguer/yay/v11/pkg/multierror"
|
2022-09-06 23:38:47 +02:00
|
|
|
"github.com/Jguer/yay/v11/pkg/settings"
|
2022-08-21 07:14:52 +02:00
|
|
|
"github.com/Jguer/yay/v11/pkg/settings/parser"
|
2022-11-16 00:45:59 +01:00
|
|
|
"github.com/Jguer/yay/v11/pkg/topo"
|
2022-09-11 23:15:31 +02:00
|
|
|
|
|
|
|
gosrc "github.com/Morganamilo/go-srcinfo"
|
2022-11-15 15:44:50 +01:00
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
"github.com/pkg/errors"
|
2022-08-21 07:14:52 +02:00
|
|
|
)
|
|
|
|
|
2022-09-09 20:57:18 +02:00
|
|
|
var ErrInstallRepoPkgs = errors.New(gotext.Get("error installing repo packages"))
|
|
|
|
|
2022-08-21 07:14:52 +02:00
|
|
|
func installLocalPKGBUILD(
|
|
|
|
ctx context.Context,
|
2022-11-15 16:22:57 +01:00
|
|
|
config *settings.Configuration,
|
2022-08-21 07:14:52 +02:00
|
|
|
cmdArgs *parser.Arguments,
|
|
|
|
dbExecutor db.Executor,
|
|
|
|
) error {
|
2022-11-15 16:22:57 +01:00
|
|
|
aurCache := config.Runtime.AURCache
|
2022-12-18 21:14:41 +01:00
|
|
|
noCheck := strings.Contains(config.MFlags, "--nocheck")
|
2022-09-04 23:45:40 +02:00
|
|
|
|
2022-11-16 00:45:59 +01:00
|
|
|
if len(cmdArgs.Targets) < 1 {
|
|
|
|
return errors.New(gotext.Get("no target directories specified"))
|
2022-08-22 23:28:53 +02:00
|
|
|
}
|
|
|
|
|
2023-02-21 00:14:59 +01:00
|
|
|
grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm,
|
|
|
|
cmdArgs.ExistsDouble("d", "nodeps"), noCheck, cmdArgs.ExistsArg("needed"),
|
|
|
|
config.Runtime.Logger.Child("grapher"))
|
2022-11-16 00:45:59 +01:00
|
|
|
graph := topo.New[string, *dep.InstallInfo]()
|
|
|
|
for _, target := range cmdArgs.Targets {
|
|
|
|
var errG error
|
2022-09-06 23:38:47 +02:00
|
|
|
|
2022-11-16 00:45:59 +01:00
|
|
|
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
|
|
|
|
}
|
2022-08-22 23:28:53 +02:00
|
|
|
}
|
|
|
|
|
2022-11-20 14:02:01 +01:00
|
|
|
opService := NewOperationService(ctx, config, dbExecutor)
|
2022-12-29 13:34:53 +01:00
|
|
|
multiErr := &multierror.MultiError{}
|
|
|
|
targets := graph.TopoSortedLayerMap(func(name string, ii *dep.InstallInfo) error {
|
|
|
|
if ii.Source == dep.Missing {
|
|
|
|
multiErr.Add(errors.New(gotext.Get("could not find %s%s", name, ii.Version)))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
|
|
|
|
if err := multiErr.Return(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return opService.Run(ctx, cmdArgs, targets)
|
2022-09-09 20:57:18 +02:00
|
|
|
}
|