xbps-install(8): -R now overrides the repository list set in a configuration file.

Now -R can be used independently if a configuration file exists or not.
This commit is contained in:
Juan RP 2013-04-18 18:17:14 +02:00
parent 3a5d6b1376
commit 5fd7565e6c
4 changed files with 26 additions and 13 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.23 (???): xbps-0.23 (???):
* xbps-install(8): the default repository (-R) now overrides any repository
set in a configuration file.
* xbps-rindex(8): in clean mode (-c) also remove obsolete entries from index-files, * xbps-rindex(8): in clean mode (-c) also remove obsolete entries from index-files,
which were not matched due to different tests. which were not matched due to different tests.

View File

@ -1,4 +1,4 @@
.Dd March 4, 2013 .Dd April 18, 2013
.Os Void Linux .Os Void Linux
.Dt xbps-install 8 .Dt xbps-install 8
.Sh NAME .Sh NAME
@ -70,7 +70,8 @@ Show the help usage.
.It Fl n, Fl -dry-run .It Fl n, Fl -dry-run
Dry-run mode. Show what actions would be done but don't do anything. Dry-run mode. Show what actions would be done but don't do anything.
.It Fl R, Fl -repository Ar uri .It Fl R, Fl -repository Ar uri
Default repository to be used if no repository is specified in configuration file. Default repository to be used overriding repository list in configuration file.
Only a single repository can be specified.
.It Fl r, Fl -rootdir Ar dir .It Fl r, Fl -rootdir Ar dir
Specifies a full path for the target root directory. Specifies a full path for the target root directory.
.It Fl S, Fl -sync .It Fl S, Fl -sync

View File

@ -48,7 +48,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.7" #define XBPS_PKGINDEX_VERSION "1.7"
#define XBPS_API_VERSION "20130315" #define XBPS_API_VERSION "20130418"
#ifndef XBPS_VERSION #ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET" #define XBPS_VERSION "UNSET"

View File

@ -75,6 +75,22 @@ set_metadir(struct xbps_handle *xh)
} }
} }
static int
config_inject_repos(struct xbps_handle *xh)
{
char *buf;
if (xh->repository) {
int rv;
buf = xbps_xasprintf("repositories = { %s }", xh->repository);
if ((rv = cfg_parse_buf(xh->cfg, buf)) != 0)
return rv;
free(buf);
}
return 0;
}
static void static void
config_inject_vpkgs(struct xbps_handle *xh) config_inject_vpkgs(struct xbps_handle *xh)
{ {
@ -189,16 +205,6 @@ xbps_init(struct xbps_handle *xhp)
if (errno != ENOENT) if (errno != ENOENT)
return rv; return rv;
xhp->conffile = NULL;
if (xhp->repository) {
char *buf;
buf = xbps_xasprintf("repositories = { %s }",
xhp->repository);
if ((rv = cfg_parse_buf(xhp->cfg, buf)) != 0)
return rv;
free(buf);
}
} else if (rv == CFG_PARSE_ERROR) { } else if (rv == CFG_PARSE_ERROR) {
/* /*
* Parser error from configuration file. * Parser error from configuration file.
@ -206,6 +212,9 @@ xbps_init(struct xbps_handle *xhp)
return ENOTSUP; return ENOTSUP;
} }
} }
/* Inject custom repo overriding the ones from configuration file */
if ((rv = config_inject_repos(xhp)) != 0)
return rv;
xbps_dbg_printf(xhp, "Configuration file: %s\n", xbps_dbg_printf(xhp, "Configuration file: %s\n",
xhp->conffile ? xhp->conffile : "not found"); xhp->conffile ? xhp->conffile : "not found");