2021-08-02 21:01:43 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-08-12 18:56:23 +02:00
|
|
|
"context"
|
2021-08-02 21:01:43 +02:00
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
2023-02-21 00:58:13 +01:00
|
|
|
"github.com/Jguer/aur"
|
2021-08-02 21:01:43 +02:00
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
|
2023-03-07 22:04:06 +01:00
|
|
|
"github.com/Jguer/yay/v12/pkg/download"
|
2023-08-06 21:39:41 +02:00
|
|
|
"github.com/Jguer/yay/v12/pkg/runtime"
|
2023-03-07 22:04:06 +01:00
|
|
|
"github.com/Jguer/yay/v12/pkg/settings/parser"
|
|
|
|
"github.com/Jguer/yay/v12/pkg/text"
|
2021-08-02 21:01:43 +02:00
|
|
|
)
|
|
|
|
|
2021-08-11 20:13:28 +02:00
|
|
|
// yay -Gp.
|
2023-08-06 21:39:41 +02:00
|
|
|
func printPkgbuilds(dbExecutor download.DBSearcher, aurClient aur.QueryClient,
|
|
|
|
httpClient *http.Client, logger *text.Logger, targets []string,
|
2023-01-03 22:43:56 +01:00
|
|
|
mode parser.TargetMode, aurURL string,
|
|
|
|
) error {
|
2023-08-06 21:39:41 +02:00
|
|
|
pkgbuilds, err := download.PKGBUILDs(dbExecutor, aurClient, httpClient, logger, targets, aurURL, mode)
|
2021-08-02 21:01:43 +02:00
|
|
|
if err != nil {
|
2023-08-06 21:39:41 +02:00
|
|
|
logger.Errorln(err)
|
2021-08-02 21:01:43 +02:00
|
|
|
}
|
|
|
|
|
2023-09-27 12:36:08 +02:00
|
|
|
for target, pkgbuild := range pkgbuilds {
|
|
|
|
logger.Printf("\n\n# %s\n\n%s", target, string(pkgbuild))
|
2021-08-02 21:01:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(pkgbuilds) != len(targets) {
|
|
|
|
missing := []string{}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2021-08-02 21:01:43 +02:00
|
|
|
for _, target := range targets {
|
|
|
|
if _, ok := pkgbuilds[target]; !ok {
|
|
|
|
missing = append(missing, target)
|
|
|
|
}
|
|
|
|
}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2023-08-06 21:39:41 +02:00
|
|
|
logger.Warnln(gotext.Get("Unable to find the following packages:"), " ", strings.Join(missing, ", "))
|
2021-08-02 21:01:43 +02:00
|
|
|
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-08-11 20:13:28 +02:00
|
|
|
// yay -G.
|
2023-02-21 00:58:13 +01:00
|
|
|
func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher, aurClient aur.QueryClient,
|
2023-08-06 21:39:41 +02:00
|
|
|
run *runtime.Runtime, targets []string, force bool,
|
2023-01-03 22:43:56 +01:00
|
|
|
) error {
|
2021-08-02 21:01:43 +02:00
|
|
|
wd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2023-02-21 00:58:13 +01:00
|
|
|
cloned, errD := download.PKGBUILDRepos(ctx, dbExecutor, aurClient,
|
2023-08-06 21:39:41 +02:00
|
|
|
run.CmdBuilder, run.Logger, targets, run.Cfg.Mode, run.Cfg.AURURL, wd, force)
|
2021-08-02 21:01:43 +02:00
|
|
|
if errD != nil {
|
2023-08-06 21:39:41 +02:00
|
|
|
run.Logger.Errorln(errD)
|
2021-08-02 21:01:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(targets) != len(cloned) {
|
|
|
|
missing := []string{}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2021-08-02 21:01:43 +02:00
|
|
|
for _, target := range targets {
|
|
|
|
if _, ok := cloned[target]; !ok {
|
|
|
|
missing = append(missing, target)
|
|
|
|
}
|
|
|
|
}
|
2021-08-11 20:13:28 +02:00
|
|
|
|
2023-08-06 21:39:41 +02:00
|
|
|
run.Logger.Warnln(gotext.Get("Unable to find the following packages:"), " ", strings.Join(missing, ", "))
|
2021-08-02 21:01:43 +02:00
|
|
|
|
|
|
|
err = fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|