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:
parent
04fcb19567
commit
54b6cc7ec1
3
NEWS
3
NEWS
@ -1,5 +1,8 @@
|
||||
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
|
||||
files must be installed to a directory prior to executing this utility.
|
||||
|
||||
|
@ -47,6 +47,7 @@ usage(bool fail)
|
||||
"Usage: xbps-bin [options] target [arguments]\n\n"
|
||||
"[options]\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 cachedir Full path to cachedir, to store downloaded binpkgs\n"
|
||||
" -d Debug mode shown to stderr\n"
|
||||
@ -111,23 +112,26 @@ main(int argc, char **argv)
|
||||
struct xferstat xfer;
|
||||
struct list_pkgver_cb lpc;
|
||||
struct sigaction sa;
|
||||
const char *rootdir, *cachedir, *conffile, *option;
|
||||
const char *rootdir, *cachedir, *conffile, *option, *defrepo;
|
||||
int i, c, flags, rv;
|
||||
bool rsync, yes, reqby_force, force_rm_with_deps, recursive_rm;
|
||||
bool reinstall, show_download_pkglist_url, dry_run;
|
||||
size_t maxcols;
|
||||
|
||||
rootdir = cachedir = conffile = option = NULL;
|
||||
rootdir = cachedir = conffile = option = defrepo = NULL;
|
||||
flags = rv = 0;
|
||||
reqby_force = rsync = yes = dry_run = force_rm_with_deps = 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) {
|
||||
case 'A':
|
||||
flags |= XBPS_FLAG_INSTALL_AUTO;
|
||||
break;
|
||||
case 'B':
|
||||
defrepo = optarg;
|
||||
break;
|
||||
case 'C':
|
||||
conffile = optarg;
|
||||
break;
|
||||
@ -210,6 +214,7 @@ main(int argc, char **argv)
|
||||
xh.cachedir = cachedir;
|
||||
xh.conffile = conffile;
|
||||
xh.flags = flags;
|
||||
xh.repository = defrepo;
|
||||
if (flags & XBPS_FLAG_VERBOSE)
|
||||
xh.unpack_cb = unpack_progress_cb_verbose;
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
.Dd June 5, 2012
|
||||
.Dd September 24, 2012
|
||||
.Os Void GNU/Linux
|
||||
.Dt xbps-bin 8
|
||||
.Sh NAME
|
||||
@ -36,6 +36,9 @@ and
|
||||
.Em update
|
||||
targets.
|
||||
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
|
||||
Full path to the XBPS configuration file. By default set to
|
||||
.Pa /etc/xbps/xbps.conf .
|
||||
|
@ -44,6 +44,7 @@ usage(bool fail)
|
||||
fprintf(stdout,
|
||||
"Usage: xbps-repo [options] target [arguments]\n\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 cachedir Full path to cachedir to store downloaded binpkgs\n"
|
||||
" -d Debug mode shown to stderr\n"
|
||||
@ -92,13 +93,16 @@ main(int argc, char **argv)
|
||||
struct xferstat xfer;
|
||||
struct repo_search_data rsd;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *rootdir, *cachedir, *conffile, *option;
|
||||
const char *rootdir, *cachedir, *conffile, *option, *defrepo;
|
||||
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) {
|
||||
case 'B':
|
||||
defrepo = optarg;
|
||||
break;
|
||||
case 'C':
|
||||
conffile = optarg;
|
||||
break;
|
||||
@ -144,6 +148,7 @@ main(int argc, char **argv)
|
||||
xh.rootdir = rootdir;
|
||||
xh.cachedir = cachedir;
|
||||
xh.conffile = conffile;
|
||||
xh.repository = defrepo;
|
||||
|
||||
if ((rv = xbps_init(&xh)) != 0) {
|
||||
xbps_error_printf("xbps-repo: couldn't initialize library: %s\n",
|
||||
|
@ -1,4 +1,4 @@
|
||||
.Dd July 31, 2012
|
||||
.Dd September 24, 2012
|
||||
.Os Void GNU/Linux
|
||||
.Dt xbps-repo 8
|
||||
.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.
|
||||
.Sh OPTIONS
|
||||
.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
|
||||
Full path to the XBPS configuration file. By default set to
|
||||
.Pa /etc/xbps/xbps.conf .
|
||||
|
2
configure
vendored
2
configure
vendored
@ -444,7 +444,7 @@ int main(void) {
|
||||
return 0;
|
||||
}
|
||||
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
|
||||
echo "USE_EXTERNAL_PROPLIB = 1" >>$CONFIG_MK
|
||||
echo "LDFLAGS += -lz -lpthread -lprop" >>$CONFIG_MK
|
||||
|
@ -528,6 +528,13 @@ struct xbps_handle {
|
||||
char *cachedir_priv;
|
||||
char *metadir_priv;
|
||||
char *un_machine;
|
||||
/*
|
||||
* @var repository
|
||||
*
|
||||
* Default repository to be used if a configuration file
|
||||
* couldn't be found.
|
||||
*/
|
||||
const char *repository;
|
||||
/**
|
||||
* @var conffile
|
||||
*
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user