2021-08-02 19:01:43 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/leonelquinteros/gotext"
|
|
|
|
|
|
|
|
"github.com/Jguer/yay/v10/pkg/download"
|
|
|
|
"github.com/Jguer/yay/v10/pkg/settings"
|
2021-08-11 16:40:59 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/settings/parser"
|
2021-08-02 19:01:43 +00:00
|
|
|
"github.com/Jguer/yay/v10/pkg/text"
|
|
|
|
)
|
|
|
|
|
2021-08-11 18:13:28 +00:00
|
|
|
// yay -Gp.
|
|
|
|
func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, targets []string,
|
2021-08-11 16:40:59 +00:00
|
|
|
mode parser.TargetMode, aurURL string) error {
|
|
|
|
pkgbuilds, err := download.PKGBUILDs(dbExecutor, 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
|
|
|
|
2021-08-02 19:01:43 +00:00
|
|
|
text.Warnln(gotext.Get("Unable to find the following packages:"), strings.Join(missing, ", "))
|
|
|
|
|
|
|
|
return fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-08-11 18:13:28 +00:00
|
|
|
// yay -G.
|
|
|
|
func getPkgbuilds(dbExecutor download.DBSearcher, config *settings.Configuration, targets []string,
|
2021-08-02 19:01:43 +00:00
|
|
|
force bool) error {
|
|
|
|
wd, err := os.Getwd()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-08-11 18:13:28 +00:00
|
|
|
|
2021-08-08 18:22:39 +00:00
|
|
|
cloned, errD := download.PKGBUILDRepos(dbExecutor,
|
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
|
|
|
|
2021-08-02 19:01:43 +00:00
|
|
|
text.Warnln(gotext.Get("Unable to find the following packages:"), strings.Join(missing, ", "))
|
|
|
|
|
|
|
|
err = fmt.Errorf("")
|
|
|
|
}
|
|
|
|
|
|
|
|
return err
|
|
|
|
}
|