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