2017-08-02 17:24:03 +00:00
|
|
|
package main
|
2017-05-01 01:23:03 +00:00
|
|
|
|
2017-05-01 01:34:40 +00:00
|
|
|
import (
|
2021-08-02 19:56:19 +00:00
|
|
|
"strings"
|
2018-08-02 22:30:48 +00:00
|
|
|
"sync"
|
2018-03-22 18:23:20 +00:00
|
|
|
|
2020-05-04 07:24:32 +00:00
|
|
|
"github.com/leonelquinteros/gotext"
|
2020-05-02 14:17:20 +00:00
|
|
|
|
2020-08-01 07:55:08 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/db"
|
2020-07-10 00:36:45 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/dep"
|
2021-08-02 19:56:19 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/download"
|
2020-07-05 00:01:08 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/query"
|
2020-08-21 00:39:52 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/settings"
|
2020-06-13 17:29:50 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/stringset"
|
|
|
|
"github.com/Jguer/yay/v10/pkg/text"
|
2017-05-01 01:34:40 +00:00
|
|
|
)
|
2017-05-01 01:23:03 +00:00
|
|
|
|
2017-10-14 16:11:47 +00:00
|
|
|
// createDevelDB forces yay to create a DB of the existing development packages
|
2020-08-21 00:39:52 +00:00
|
|
|
func createDevelDB(config *settings.Configuration, dbExecutor db.Executor) error {
|
2018-08-02 22:30:48 +00:00
|
|
|
var mux sync.Mutex
|
|
|
|
var wg sync.WaitGroup
|
2018-03-22 18:23:20 +00:00
|
|
|
|
2020-08-01 07:55:08 +00:00
|
|
|
_, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
|
2017-05-02 00:06:16 +00:00
|
|
|
if err != nil {
|
2017-08-02 17:24:03 +00:00
|
|
|
return err
|
2017-05-02 00:06:16 +00:00
|
|
|
}
|
2017-08-02 17:24:03 +00:00
|
|
|
|
2021-05-13 05:27:24 +00:00
|
|
|
info, err := query.AURInfoPrint(config.Runtime.AURClient, remoteNames, config.RequestSplitN)
|
2018-03-22 18:23:20 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-25 21:31:20 +00:00
|
|
|
|
2020-07-10 00:36:45 +00:00
|
|
|
bases := dep.GetBases(info)
|
2019-10-16 21:58:55 +00:00
|
|
|
toSkip := pkgbuildsToSkip(bases, stringset.FromSlice(remoteNames))
|
2021-08-02 19:56:19 +00:00
|
|
|
|
|
|
|
targets := make([]string, 0, len(bases))
|
|
|
|
for _, base := range bases {
|
|
|
|
if !toSkip.Get(base.Pkgbase()) {
|
|
|
|
targets = append(targets, base.Pkgbase())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
toSkipSlice := toSkip.ToSlice()
|
|
|
|
if len(toSkipSlice) != 0 {
|
|
|
|
text.OperationInfoln(
|
|
|
|
gotext.Get("PKGBUILD up to date, Skipping (%d/%d): %s",
|
|
|
|
len(toSkipSlice), len(bases), text.Cyan(strings.Join(toSkipSlice, ", "))))
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, errA := download.AURPKGBUILDRepos(config.Runtime.CmdRunner,
|
|
|
|
config.Runtime.CmdBuilder, targets, config.AURURL, config.BuildDir, false); errA != nil {
|
2019-10-13 11:15:51 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
srcinfos, err := parseSrcinfoFiles(bases, false)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-22 18:23:20 +00:00
|
|
|
|
2020-05-02 14:17:20 +00:00
|
|
|
for i := range srcinfos {
|
|
|
|
for iP := range srcinfos[i].Packages {
|
2018-08-02 22:30:48 +00:00
|
|
|
wg.Add(1)
|
2020-08-21 22:39:26 +00:00
|
|
|
go config.Runtime.VCSStore.Update(srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source, &mux, &wg)
|
2018-03-22 18:23:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 22:30:48 +00:00
|
|
|
wg.Wait()
|
2020-05-04 07:24:32 +00:00
|
|
|
text.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
|
2017-08-02 17:24:03 +00:00
|
|
|
return err
|
2017-05-01 01:23:03 +00:00
|
|
|
}
|