diff --git a/config.go b/config.go index 6b84665c..0148c8c8 100644 --- a/config.go +++ b/config.go @@ -35,6 +35,7 @@ const ( // Configuration stores yay's config. type Configuration struct { + AURURL string `json:"aururl"` BuildDir string `json:"buildDir"` Editor string `json:"editor"` EditorFlags string `json:"editorflags"` @@ -84,9 +85,6 @@ const configFileName string = "config.json" // vcsFileName holds the name of the vcs file. const vcsFileName string = "vcs.json" -// baseURL givers the AUR default address. -const baseURL string = "https://aur.archlinux.org" - // useColor enables/disables colored printing var useColor bool @@ -149,6 +147,7 @@ func (config *Configuration) saveConfig() error { } func defaultSettings(config *Configuration) { + config.AURURL = "https://aur.archlinux.org" config.BuildDir = cacheHome config.CleanAfter = false config.Editor = "" diff --git a/install.go b/install.go index 0ebc37e6..ecceb784 100644 --- a/install.go +++ b/install.go @@ -845,7 +845,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS } 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 { errs.Add(err) return @@ -856,7 +856,7 @@ func downloadPkgbuilds(bases []Base, toSkip stringSet, buildDir string) (stringS mux.Unlock() } } else { - err := downloadAndUnpack(baseURL+base.URLPath(), buildDir) + err := downloadAndUnpack(config.AURURL+base.URLPath(), buildDir) if err != nil { errs.Add(err) return diff --git a/main.go b/main.go index 53a6db58..5198abf8 100644 --- a/main.go +++ b/main.go @@ -4,10 +4,13 @@ import ( "encoding/json" "fmt" "os" + "path" "path/filepath" "strings" + "net/url" alpm "github.com/jguer/go-alpm" + rpc "github.com/mikkeloscar/aur" ) 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 } diff --git a/parser.go b/parser.go index 27b45589..bc25a387 100644 --- a/parser.go +++ b/parser.go @@ -414,6 +414,7 @@ func isArg(arg string) bool { case "x", "regex": case "machinereadable": //yay options + case "aururl": case "save": case "afterclean": case "noafterclean": @@ -493,6 +494,8 @@ func isArg(arg string) bool { func handleConfig(option, value string) bool { switch option { + case "aururl": + config.AURURL = value case "save": shouldSaveConfig = true case "afterclean": @@ -702,6 +705,7 @@ func hasParam(arg string) bool { case "gpgdir": case "color": //yay params + case "aururl": case "mflags": case "gpgflags": case "gitflags": diff --git a/print.go b/print.go index 40284a8b..cb477932 100644 --- a/print.go +++ b/print.go @@ -285,7 +285,7 @@ func PrintInfo(a *rpc.Pkg) { printInfoValue("Version", a.Version) printInfoValue("Description", a.Description) 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("Licenses", strings.Join(a.License, " ")) printInfoValue("Provides", strings.Join(a.Provides, " ")) @@ -310,7 +310,7 @@ func PrintInfo(a *rpc.Pkg) { printInfoValue("ID", fmt.Sprintf("%d", a.ID)) printInfoValue("Package Base ID", fmt.Sprintf("%d", a.PackageBaseID)) printInfoValue("Package Base", a.PackageBase) - printInfoValue("Snapshot URL", baseURL+a.URLPath) + printInfoValue("Snapshot URL", config.AURURL+a.URLPath) } fmt.Println()