forked from Jguer/yay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal_install.go
67 lines (56 loc) · 1.84 KB
/
local_install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Experimental code for install local with dependency refactoring
// Not at feature parity with install.go
package main
import (
"context"
"os"
"path/filepath"
"strings"
"github.com/Jguer/yay/v11/pkg/db"
"github.com/Jguer/yay/v11/pkg/dep"
"github.com/Jguer/yay/v11/pkg/multierror"
"github.com/Jguer/yay/v11/pkg/settings"
"github.com/Jguer/yay/v11/pkg/settings/parser"
"github.com/Jguer/yay/v11/pkg/topo"
gosrc "github.com/Morganamilo/go-srcinfo"
"github.com/leonelquinteros/gotext"
"github.com/pkg/errors"
)
var ErrInstallRepoPkgs = errors.New(gotext.Get("error installing repo packages"))
func installLocalPKGBUILD(
ctx context.Context,
config *settings.Configuration,
cmdArgs *parser.Arguments,
dbExecutor db.Executor,
) error {
aurCache := config.Runtime.AURCache
noCheck := strings.Contains(config.MFlags, "--nocheck")
if len(cmdArgs.Targets) < 1 {
return errors.New(gotext.Get("no target directories specified"))
}
grapher := dep.NewGrapher(dbExecutor, aurCache, false, settings.NoConfirm, os.Stdout, cmdArgs.ExistsDouble("d", "nodeps"), noCheck)
graph := topo.New[string, *dep.InstallInfo]()
for _, target := range cmdArgs.Targets {
var errG error
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
}
}
opService := NewOperationService(ctx, config, dbExecutor)
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)
}