diff --git a/README.md b/README.md index 3a3d698..80b604d 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,14 @@ Download the rz-pm binary for your system on the [latest release page](https://g | **GithubCI** | [![Go](https://github.com/rizinorg/rz-pm/actions/workflows/go.yml/badge.svg)](https://github.com/rizinorg/rz-pm/actions/workflows/go.yml) | # Available packages -The official database is available [here](https://github.com/rizinorg/rz-pm-db). + +The official database is available [here](https://github.com/rizinorg/rz-pm-db). You can change the repo by supplying a custom `RZPM_DB_REPO_URL` environment flag like this: + + $ RZPM_DB_REPO_URL=https://github.com/bunnyfoofoo/my-custom-rz-pm-db rz-pm install rz-custom-plugin + +Furthermore, to aid with debugging, you can disable auto-updating the `rz-pm-db` upon each command execution by adding `-should-update-db=false` flag, like this: + + $ rz-pm -should-update-db=false install rz-custom-plugin ## Package example diff --git a/pkg/site.go b/pkg/site.go index 8f739c0..9c7d301 100644 --- a/pkg/site.go +++ b/pkg/site.go @@ -5,6 +5,7 @@ import ( "fmt" "io/fs" "io/ioutil" + "log" "os" "os/exec" "path/filepath" @@ -25,7 +26,17 @@ func SiteDir() string { return filepath.Join(xdg.DataHome, "rz-pm", "site") } -const RZPM_DB_REPO_URL = "https://github.com/rizinorg/rz-pm-db" +var RZPM_DB_REPO_URL string + +func init() { + dbURL := os.Getenv("RZPM_DB_REPO_URL") + if dbURL != "" { + log.Printf("Using custom rz-pm-db Git repo: %s\n", dbURL) + RZPM_DB_REPO_URL = dbURL + } else { + RZPM_DB_REPO_URL = "https://github.com/rizinorg/rz-pm-db" + } +} type Site interface { ListAvailablePackages() ([]Package, error)