mirror of
https://github.com/Jguer/yay
synced 2024-09-14 13:51:12 +00:00
Add --aururl
This commit is contained in:
parent
23ff1e79df
commit
0454e8918b
|
@ -35,6 +35,7 @@ const (
|
||||||
|
|
||||||
// Configuration stores yay's config.
|
// Configuration stores yay's config.
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
|
AURURL string `json:"aururl"`
|
||||||
BuildDir string `json:"buildDir"`
|
BuildDir string `json:"buildDir"`
|
||||||
Editor string `json:"editor"`
|
Editor string `json:"editor"`
|
||||||
EditorFlags string `json:"editorflags"`
|
EditorFlags string `json:"editorflags"`
|
||||||
|
@ -84,9 +85,6 @@ const configFileName string = "config.json"
|
||||||
// vcsFileName holds the name of the vcs file.
|
// vcsFileName holds the name of the vcs file.
|
||||||
const vcsFileName string = "vcs.json"
|
const vcsFileName string = "vcs.json"
|
||||||
|
|
||||||
// baseURL givers the AUR default address.
|
|
||||||
const baseURL string = "https://aur.archlinux.org"
|
|
||||||
|
|
||||||
// useColor enables/disables colored printing
|
// useColor enables/disables colored printing
|
||||||
var useColor bool
|
var useColor bool
|
||||||
|
|
||||||
|
@ -149,6 +147,7 @@ func (config *Configuration) saveConfig() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultSettings(config *Configuration) {
|
func defaultSettings(config *Configuration) {
|
||||||
|
config.AURURL = "https://aur.archlinux.org"
|
||||||
config.BuildDir = cacheHome
|
config.BuildDir = cacheHome
|
||||||
config.CleanAfter = false
|
config.CleanAfter = false
|
||||||
config.Editor = ""
|
config.Editor = ""
|
||||||
|
|
|
@ -845,7 +845,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldUseGit(filepath.Join(config.BuildDir, pkg)) {
|
if shouldUseGit(filepath.Join(config.BuildDir, pkg)) {
|
||||||
clone, err := gitDownload(baseURL+"/"+pkg+".git", buildDir, pkg)
|
clone, err := gitDownload(config.AURURL+"/"+pkg+".git", buildDir, pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
return
|
return
|
||||||
|
@ -856,7 +856,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS
|
||||||
mux.Unlock()
|
mux.Unlock()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err := downloadAndUnpack(baseURL+base.URLPath(), buildDir)
|
err := downloadAndUnpack(config.AURURL+base.URLPath(), buildDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
return
|
return
|
||||||
|
|
10
main.go
10
main.go
|
@ -4,10 +4,13 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
alpm "github.com/jguer/go-alpm"
|
alpm "github.com/jguer/go-alpm"
|
||||||
|
rpc "github.com/mikkeloscar/aur"
|
||||||
)
|
)
|
||||||
|
|
||||||
func setPaths() error {
|
func setPaths() error {
|
||||||
|
@ -47,6 +50,13 @@ func initConfig() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url, err := url.Parse(config.AURURL)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
url.Path = path.Join(url.Path, "")
|
||||||
|
rpc.AURURL = url.String() + "/rpc.php?"
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,7 @@ func isArg(arg string) bool {
|
||||||
case "x", "regex":
|
case "x", "regex":
|
||||||
case "machinereadable":
|
case "machinereadable":
|
||||||
//yay options
|
//yay options
|
||||||
|
case "aururl":
|
||||||
case "save":
|
case "save":
|
||||||
case "afterclean":
|
case "afterclean":
|
||||||
case "noafterclean":
|
case "noafterclean":
|
||||||
|
@ -493,6 +494,8 @@ func isArg(arg string) bool {
|
||||||
|
|
||||||
func handleConfig(option, value string) bool {
|
func handleConfig(option, value string) bool {
|
||||||
switch option {
|
switch option {
|
||||||
|
case "aururl":
|
||||||
|
config.AURURL = value
|
||||||
case "save":
|
case "save":
|
||||||
shouldSaveConfig = true
|
shouldSaveConfig = true
|
||||||
case "afterclean":
|
case "afterclean":
|
||||||
|
@ -702,6 +705,7 @@ func hasParam(arg string) bool {
|
||||||
case "gpgdir":
|
case "gpgdir":
|
||||||
case "color":
|
case "color":
|
||||||
//yay params
|
//yay params
|
||||||
|
case "aururl":
|
||||||
case "mflags":
|
case "mflags":
|
||||||
case "gpgflags":
|
case "gpgflags":
|
||||||
case "gitflags":
|
case "gitflags":
|
||||||
|
|
4
print.go
4
print.go
|
@ -285,7 +285,7 @@ func PrintInfo(a *rpc.Pkg) {
|
||||||
printInfoValue("Version", a.Version)
|
printInfoValue("Version", a.Version)
|
||||||
printInfoValue("Description", a.Description)
|
printInfoValue("Description", a.Description)
|
||||||
printInfoValue("URL", a.URL)
|
printInfoValue("URL", a.URL)
|
||||||
printInfoValue("AUR URL", baseURL+"/packages/"+a.Name)
|
printInfoValue("AUR URL", config.AURURL+"/packages/"+a.Name)
|
||||||
printInfoValue("Groups", strings.Join(a.Groups, " "))
|
printInfoValue("Groups", strings.Join(a.Groups, " "))
|
||||||
printInfoValue("Licenses", strings.Join(a.License, " "))
|
printInfoValue("Licenses", strings.Join(a.License, " "))
|
||||||
printInfoValue("Provides", strings.Join(a.Provides, " "))
|
printInfoValue("Provides", strings.Join(a.Provides, " "))
|
||||||
|
@ -310,7 +310,7 @@ func PrintInfo(a *rpc.Pkg) {
|
||||||
printInfoValue("ID", fmt.Sprintf("%d", a.ID))
|
printInfoValue("ID", fmt.Sprintf("%d", a.ID))
|
||||||
printInfoValue("Package Base ID", fmt.Sprintf("%d", a.PackageBaseID))
|
printInfoValue("Package Base ID", fmt.Sprintf("%d", a.PackageBaseID))
|
||||||
printInfoValue("Package Base", a.PackageBase)
|
printInfoValue("Package Base", a.PackageBase)
|
||||||
printInfoValue("Snapshot URL", baseURL+a.URLPath)
|
printInfoValue("Snapshot URL", config.AURURL+a.URLPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
Loading…
Reference in a new issue