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

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.17 (???): xbps-0.17 (???):
* xbps-bin(8), xbps-repo(8): added a new flag -B to set default repository
to install packages, in case xbps.conf couldn't be found.
* xbps-create(8): a new utility to create XBPS binary packages; package * xbps-create(8): a new utility to create XBPS binary packages; package
files must be installed to a directory prior to executing this utility. files must be installed to a directory prior to executing this utility.

View File

@ -47,6 +47,7 @@ usage(bool fail)
"Usage: xbps-bin [options] target [arguments]\n\n" "Usage: xbps-bin [options] target [arguments]\n\n"
"[options]\n" "[options]\n"
" -A Enable Automatic installation (shown as orphan)\n" " -A Enable Automatic installation (shown as orphan)\n"
" -B repo Set <repo> as default repository if xbps.conf not found.\n"
" -C file Full path to configuration file\n" " -C file Full path to configuration file\n"
" -c cachedir Full path to cachedir, to store downloaded binpkgs\n" " -c cachedir Full path to cachedir, to store downloaded binpkgs\n"
" -d Debug mode shown to stderr\n" " -d Debug mode shown to stderr\n"
@ -111,23 +112,26 @@ main(int argc, char **argv)
struct xferstat xfer; struct xferstat xfer;
struct list_pkgver_cb lpc; struct list_pkgver_cb lpc;
struct sigaction sa; struct sigaction sa;
const char *rootdir, *cachedir, *conffile, *option; const char *rootdir, *cachedir, *conffile, *option, *defrepo;
int i, c, flags, rv; int i, c, flags, rv;
bool rsync, yes, reqby_force, force_rm_with_deps, recursive_rm; bool rsync, yes, reqby_force, force_rm_with_deps, recursive_rm;
bool reinstall, show_download_pkglist_url, dry_run; bool reinstall, show_download_pkglist_url, dry_run;
size_t maxcols; size_t maxcols;
rootdir = cachedir = conffile = option = NULL; rootdir = cachedir = conffile = option = defrepo = NULL;
flags = rv = 0; flags = rv = 0;
reqby_force = rsync = yes = dry_run = force_rm_with_deps = false; reqby_force = rsync = yes = dry_run = force_rm_with_deps = false;
recursive_rm = reinstall = show_download_pkglist_url = false; recursive_rm = reinstall = show_download_pkglist_url = false;
while ((c = getopt(argc, argv, "AC:c:dDFfhMno:Rr:SVvy")) != -1) { while ((c = getopt(argc, argv, "AB:C:c:dDFfhMno:Rr:SVvy")) != -1) {
switch (c) { switch (c) {
case 'A': case 'A':
flags |= XBPS_FLAG_INSTALL_AUTO; flags |= XBPS_FLAG_INSTALL_AUTO;
break; break;
case 'B':
defrepo = optarg;
break;
case 'C': case 'C':
conffile = optarg; conffile = optarg;
break; break;
@ -210,6 +214,7 @@ main(int argc, char **argv)
xh.cachedir = cachedir; xh.cachedir = cachedir;
xh.conffile = conffile; xh.conffile = conffile;
xh.flags = flags; xh.flags = flags;
xh.repository = defrepo;
if (flags & XBPS_FLAG_VERBOSE) if (flags & XBPS_FLAG_VERBOSE)
xh.unpack_cb = unpack_progress_cb_verbose; xh.unpack_cb = unpack_progress_cb_verbose;
else else

View File

@ -1,4 +1,4 @@
.Dd June 5, 2012 .Dd September 24, 2012
.Os Void GNU/Linux .Os Void GNU/Linux
.Dt xbps-bin 8 .Dt xbps-bin 8
.Sh NAME .Sh NAME
@ -36,6 +36,9 @@ and
.Em update .Em update
targets. targets.
Targetted packages and its required dependencies will be matched. Targetted packages and its required dependencies will be matched.
.It Fl B Ar repository
If a configuration file cannot be found, this repository will be used as
as primary source to install packages.
.It Fl C Ar conffile .It Fl C Ar conffile
Full path to the XBPS configuration file. By default set to Full path to the XBPS configuration file. By default set to
.Pa /etc/xbps/xbps.conf . .Pa /etc/xbps/xbps.conf .

View File

@ -44,6 +44,7 @@ usage(bool fail)
fprintf(stdout, fprintf(stdout,
"Usage: xbps-repo [options] target [arguments]\n\n" "Usage: xbps-repo [options] target [arguments]\n\n"
"[options]\n" "[options]\n"
" -B repo Set <repo> as default repository if xbps.conf not found.\n"
" -C file Full path to configuration file\n" " -C file Full path to configuration file\n"
" -c cachedir Full path to cachedir to store downloaded binpkgs\n" " -c cachedir Full path to cachedir to store downloaded binpkgs\n"
" -d Debug mode shown to stderr\n" " -d Debug mode shown to stderr\n"
@ -92,13 +93,16 @@ main(int argc, char **argv)
struct xferstat xfer; struct xferstat xfer;
struct repo_search_data rsd; struct repo_search_data rsd;
prop_dictionary_t pkgd; prop_dictionary_t pkgd;
const char *rootdir, *cachedir, *conffile, *option; const char *rootdir, *cachedir, *conffile, *option, *defrepo;
int flags = 0, c, rv = 0; int flags = 0, c, rv = 0;
rootdir = cachedir = conffile = option = NULL; rootdir = cachedir = conffile = option = defrepo = NULL;
while ((c = getopt(argc, argv, "C:c:dho:r:V")) != -1) { while ((c = getopt(argc, argv, "B:C:c:dho:r:V")) != -1) {
switch (c) { switch (c) {
case 'B':
defrepo = optarg;
break;
case 'C': case 'C':
conffile = optarg; conffile = optarg;
break; break;
@ -144,6 +148,7 @@ main(int argc, char **argv)
xh.rootdir = rootdir; xh.rootdir = rootdir;
xh.cachedir = cachedir; xh.cachedir = cachedir;
xh.conffile = conffile; xh.conffile = conffile;
xh.repository = defrepo;
if ((rv = xbps_init(&xh)) != 0) { if ((rv = xbps_init(&xh)) != 0) {
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n", xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",

View File

@ -1,4 +1,4 @@
.Dd July 31, 2012 .Dd September 24, 2012
.Os Void GNU/Linux .Os Void GNU/Linux
.Dt xbps-repo 8 .Dt xbps-repo 8
.Sh NAME .Sh NAME
@ -18,6 +18,9 @@ repositories, list repositories, search for packages and show information
of a binary package in repository pool, among other things. of a binary package in repository pool, among other things.
.Sh OPTIONS .Sh OPTIONS
.Bl -tag -width Fl .Bl -tag -width Fl
.It Fl B Ar repository
If a configuration file cannot be found, this repository will be used as
as primary source to install packages.
.It Fl C Ar conffile .It Fl C Ar conffile
Full path to the XBPS configuration file. By default set to Full path to the XBPS configuration file. By default set to
.Pa /etc/xbps/xbps.conf . .Pa /etc/xbps/xbps.conf .

2
configure vendored
View File

@ -444,7 +444,7 @@ int main(void) {
return 0; return 0;
} }
EOF EOF
if $XCC -lprop _$func.c -o _$func 2>/dev/null; then if ! $XCC -lprop _$func.c -o _$func 2>/dev/null; then
PROPLIB=yes PROPLIB=yes
echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK
echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK

View File

@ -528,6 +528,13 @@ struct xbps_handle {
char *cachedir_priv; char *cachedir_priv;
char *metadir_priv; char *metadir_priv;
char *un_machine; char *un_machine;
/*
* @var repository
*
* Default repository to be used if a configuration file
* couldn't be found.
*/
const char *repository;
/** /**
* @var conffile * @var conffile
* *

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_parse(xhp->cfg, xhp->conffile)) != CFG_SUCCESS) {
if (rv == CFG_FILE_ERROR) { if (rv == CFG_FILE_ERROR) {
if (errno != ENOENT) { /*
/* * Don't error out if config file not found.
* Don't error out if config file not found. * If a default repository is set, use it; otherwise
* We'll use defaults without any repo or * use defaults (no repos and no virtual packages).
* virtual packages. */
*/ if (errno != ENOENT)
return rv; return rv;
}
xhp->conffile = NULL; 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) { } else if (rv == CFG_PARSE_ERROR) {
/* /*
* Parser error from configuration file. * Parser error from configuration file.