mirror of
https://github.com/Jguer/yay.git
synced 2024-11-06 09:07:21 +01:00
8916cd174b
* rework relationship between runtime and cfg * separate runtime from cfg * simplify instantiation logic * move installer to appropriate package * move operator to sync package * add tests for srcinfo service * consolidate srcinfo service in sync * add logger to srcinfo * add logger to preparer * remove unused text functions * remove remaining text.* from srcinfo * remove global logger parts * remove global org method exports * remove global logger * move text->input * add rule to prevent fmt.Print * update golangci go version * remove outdated FAQs * remove outdated FAQs
76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
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
|
|
}
|