xbps-{bin,repo}: add -B flag to set default repo if xbps.conf not found.

(cherry picked from commit 75eac1a1426040a833e0b10e208f2e55fa359532)
This commit is contained in:
Juan RP
2012-09-24 12:03:47 +02:00
parent 04fcb19567
commit 54b6cc7ec1
8 changed files with 52 additions and 16 deletions

View File

@@ -131,15 +131,25 @@ xbps_init(struct xbps_handle *xhp)
if ((rv = cfg_parse(xhp->cfg, xhp->conffile)) != CFG_SUCCESS) {
if (rv == CFG_FILE_ERROR) {
if (errno != ENOENT) {
/*
* Don't error out if config file not found.
* We'll use defaults without any repo or
* virtual packages.
*/
/*
* Don't error out if config file not found.
* If a default repository is set, use it; otherwise
* use defaults (no repos and no virtual packages).
*/
if (errno != ENOENT)
return rv;
}
xhp->conffile = NULL;
if (xhp->repository) {
char *buf;
buf = xbps_xasprintf("repositories = { %s }",
xhp->repository);
assert(buf);
if ((rv = cfg_parse_buf(xhp->cfg, buf)) != 0)
return rv;
free(buf);
}
} else if (rv == CFG_PARSE_ERROR) {
/*
* Parser error from configuration file.