2017-08-02 19:24:03 +02:00
|
|
|
package main
|
2017-05-01 03:23:03 +02:00
|
|
|
|
2017-05-01 03:34:40 +02:00
|
|
|
import (
|
2018-08-03 00:30:48 +02:00
|
|
|
"sync"
|
2018-03-22 19:23:20 +01:00
|
|
|
|
2020-05-04 09:24:32 +02:00
|
|
|
"github.com/leonelquinteros/gotext"
|
2020-05-02 16:17:20 +02:00
|
|
|
|
2020-08-01 09:55:08 +02:00
|
|
|
"github.com/Jguer/yay/v10/pkg/db"
|
2020-07-10 02:36:45 +02:00
|
|
|
"github.com/Jguer/yay/v10/pkg/dep"
|
2020-07-05 02:01:08 +02:00
|
|
|
"github.com/Jguer/yay/v10/pkg/query"
|
2020-08-21 02:39:52 +02:00
|
|
|
"github.com/Jguer/yay/v10/pkg/settings"
|
2020-06-13 19:29:50 +02:00
|
|
|
"github.com/Jguer/yay/v10/pkg/stringset"
|
|
|
|
"github.com/Jguer/yay/v10/pkg/text"
|
2017-05-01 03:34:40 +02:00
|
|
|
)
|
2017-05-01 03:23:03 +02:00
|
|
|
|
2017-10-14 18:11:47 +02:00
|
|
|
// createDevelDB forces yay to create a DB of the existing development packages
|
2020-08-21 02:39:52 +02:00
|
|
|
func createDevelDB(config *settings.Configuration, dbExecutor db.Executor) error {
|
2018-08-03 00:30:48 +02:00
|
|
|
var mux sync.Mutex
|
|
|
|
var wg sync.WaitGroup
|
2018-03-22 19:23:20 +01:00
|
|
|
|
2020-08-01 09:55:08 +02:00
|
|
|
_, remoteNames, err := query.GetPackageNamesBySource(dbExecutor)
|
2017-05-02 02:06:16 +02:00
|
|
|
if err != nil {
|
2017-08-02 19:24:03 +02:00
|
|
|
return err
|
2017-05-02 02:06:16 +02:00
|
|
|
}
|
2017-08-02 19:24:03 +02:00
|
|
|
|
2020-07-10 02:36:45 +02:00
|
|
|
info, err := query.AURInfoPrint(remoteNames, config.RequestSplitN)
|
2018-03-22 19:23:20 +01:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-25 23:31:20 +02:00
|
|
|
|
2020-07-10 02:36:45 +02:00
|
|
|
bases := dep.GetBases(info)
|
2019-10-16 23:58:55 +02:00
|
|
|
toSkip := pkgbuildsToSkip(bases, stringset.FromSlice(remoteNames))
|
2019-10-13 13:15:51 +02:00
|
|
|
_, err = downloadPkgbuilds(bases, toSkip, config.BuildDir)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
srcinfos, err := parseSrcinfoFiles(bases, false)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-22 19:23:20 +01:00
|
|
|
|
2020-05-02 16:17:20 +02:00
|
|
|
for i := range srcinfos {
|
|
|
|
for iP := range srcinfos[i].Packages {
|
2018-08-03 00:30:48 +02:00
|
|
|
wg.Add(1)
|
2020-08-21 02:39:52 +02:00
|
|
|
go savedInfo.Update(srcinfos[i].Packages[iP].Pkgname, srcinfos[i].Source, &mux, &wg)
|
2018-03-22 19:23:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-03 00:30:48 +02:00
|
|
|
wg.Wait()
|
2020-05-04 09:24:32 +02:00
|
|
|
text.OperationInfoln(gotext.Get("GenDB finished. No packages were installed"))
|
2017-08-02 19:24:03 +02:00
|
|
|
return err
|
2017-05-01 03:23:03 +02:00
|
|
|
}
|