-
-
Notifications
You must be signed in to change notification settings - Fork 364
/
vcs.go
75 lines (60 loc) · 1.8 KB
/
vcs.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
68
69
70
71
72
73
74
75
package main
import (
"context"
"sync"
"github.com/Jguer/aur"
"github.com/leonelquinteros/gotext"
"github.com/Jguer/yay/v12/pkg/db"
"github.com/Jguer/yay/v12/pkg/dep"
"github.com/Jguer/yay/v12/pkg/runtime"
"github.com/Jguer/yay/v12/pkg/sync/srcinfo"
"github.com/Jguer/yay/v12/pkg/sync/workdir"
)
func infoToInstallInfo(info []aur.Pkg) []map[string]*dep.InstallInfo {
installInfo := make([]map[string]*dep.InstallInfo, 1)
installInfo[0] = map[string]*dep.InstallInfo{}
for i := range info {
pkg := &info[i]
installInfo[0][pkg.Name] = &dep.InstallInfo{
AURBase: &pkg.PackageBase,
Source: dep.AUR,
}
}
return installInfo
}
// createDevelDB forces yay to create a DB of the existing development packages.
func createDevelDB(ctx context.Context, run *runtime.Runtime, dbExecutor db.Executor) error {
remoteNames := dbExecutor.InstalledRemotePackageNames()
run.QueryBuilder.Execute(ctx, dbExecutor, remoteNames)
info, err := run.AURClient.Get(ctx, &aur.Query{
Needles: remoteNames,
By: aur.Name,
Contains: false,
})
if err != nil {
return err
}
preper := workdir.NewPreparerWithoutHooks(dbExecutor, run.CmdBuilder, run.Cfg, run.Logger.Child("workdir"), false)
mapInfo := infoToInstallInfo(info)
pkgBuildDirsByBase, err := preper.Run(ctx, run, mapInfo)
if err != nil {
return err
}
srcinfos, err := srcinfo.ParseSrcinfoFilesByBase(run.Logger.Child("srcinfo"), pkgBuildDirsByBase, false)
if err != nil {
return err
}
var wg sync.WaitGroup
for i := range srcinfos {
for iP := range srcinfos[i].Packages {
wg.Add(1)
go func(i string, iP int) {
run.VCSStore.Update(ctx, srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source)
wg.Done()
}(i, iP)
}
}
wg.Wait()
run.Logger.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
return err
}