xbps-{install,query}: added -i to ignore repos defined in xbps.d.

See the NEWS file for more information.
This commit is contained in:
Juan RP 2014-11-21 10:56:41 +01:00
parent a72a52da1d
commit 89d11e871f
10 changed files with 94 additions and 5 deletions

4
NEWS
View File

@ -1,5 +1,9 @@
xbps-0.42 (???):
* xbps-{install,query}: added new option (-i, --ignore-conf-repos) to ignore
repositories defined in configuration files (xbps.d). Only repos specified
by the command line will be used (--repository).
* Implemented issue #69 (No way to set globally a custom architecture)
A new configuration keyword "architecture" has been added to override
the native machine architecture (uname -m).

View File

@ -51,6 +51,7 @@ usage(bool fail)
" If specified twice, all files will be\n"
" overwritten.\n"
" -h --help Print help usage\n"
" -i --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -n --dry-run Dry-run mode\n"
" -R,--repository=<url> Add repository to the top of the list.\n"
" This option can be specified multiple times.\n"
@ -90,7 +91,7 @@ repo_import_key_cb(struct xbps_repo *repo, void *arg _unused, bool *done _unused
int
main(int argc, char **argv)
{
const char *shortopts = "AC:c:dfhnR:r:SuVvy";
const char *shortopts = "AC:c:dfhinR:r:SuVvy";
const struct option longopts[] = {
{ "automatic", no_argument, NULL, 'A' },
{ "config", required_argument, NULL, 'C' },
@ -98,6 +99,7 @@ main(int argc, char **argv)
{ "debug", no_argument, NULL, 'd' },
{ "force", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "ignore-conf-repos", no_argument, NULL, 'i' },
{ "dry-run", no_argument, NULL, 'n' },
{ "repository", required_argument, NULL, 'R' },
{ "rootdir", required_argument, NULL, 'r' },
@ -144,6 +146,9 @@ main(int argc, char **argv)
case 'h':
usage(false);
/* NOTREACHED */
case 'i':
flags |= XBPS_FLAG_IGNORE_CONF_REPOS;
break;
case 'n':
drun = true;
break;

View File

@ -81,6 +81,11 @@ is specified twice all files will be unpacked, even
.Em configuration files .
.It Fl h, Fl -help
Show the help usage.
.It Fl i, Fl -ignore-conf-repos
Ignore repositories defined in configuration files.
Only repositories specified in the command line via
.Ar --repository
will be used.
.It Fl n, Fl -dry-run
Dry-run mode. Show what actions would be done but don't do anything.
.It Fl R, Fl -repository=uri

View File

@ -42,6 +42,7 @@ usage(bool fail)
" -c --cachedir <dir> Path to cachedir\n"
" -d --debug Debug mode shown to stderr\n"
" -h --help Print help usage\n"
" -i --ignore-conf-repos Ignore repositories defined in xbps.d\n"
" -p --property PROP[,...] Show properties for PKGNAME\n"
" -R --repository Enable repository mode. This mode explicitly\n"
" looks for packages in repositories.\n"
@ -73,12 +74,13 @@ usage(bool fail)
int
main(int argc, char **argv)
{
const char *shortopts = "C:c:df:hHLlmOo:p:Rr:s:S:VvX:x:";
const char *shortopts = "C:c:df:hHiLlmOo:p:Rr:s:S:VvX:x:";
const struct option longopts[] = {
{ "config", required_argument, NULL, 'C' },
{ "cachedir", required_argument, NULL, 'c' },
{ "debug", no_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
{ "ignore-conf-repos", no_argument, NULL, 'i' },
{ "list-repos", no_argument, NULL, 'L' },
{ "list-pkgs", no_argument, NULL, 'l' },
{ "list-hold-pkgs", no_argument, NULL, 'H' },
@ -137,6 +139,9 @@ main(int argc, char **argv)
case 'h':
usage(false);
/* NOTREACHED */
case 'i':
flags |= XBPS_FLAG_IGNORE_CONF_REPOS;
break;
case 'L':
list_repos = opmode = true;
break;

View File

@ -1,4 +1,4 @@
.Dd November 17, 2014
.Dd November 21, 2014
.Dt XBPS-QUERY 8
.Sh NAME
.Nm xbps-query
@ -65,6 +65,11 @@ If the first character is not '\/' then it's a relative path of
Enables extra debugging shown to stderr.
.It Fl h, Fl -help
Show the help usage.
.It Fl i, Fl -ignore-conf-repos
Ignore repositories defined in configuration files.
Only repositories specified in the command line via
.Ar --repository
will be used.
.It Fl p, Fl -property Ar PROP[,...]
Only match this package property.
Multiple properties can be specified by delimiting them with commas.

View File

@ -48,7 +48,7 @@
*
* This header documents the full API for the XBPS Library.
*/
#define XBPS_API_VERSION "20141121"
#define XBPS_API_VERSION "20141121-1"
#ifndef XBPS_VERSION
#define XBPS_VERSION "UNSET"
@ -176,6 +176,13 @@
*/
#define XBPS_FLAG_BESTMATCH 0x00000100
/**
* @def XBPS_FLAG_IGNORE_CONF_REPOS
* Ignore repos defined in configuration files.
* Must be set through the xbps_handle::flags member.
*/
#define XBPS_FLAG_IGNORE_CONF_REPOS 0x00000200
/**
* @def XBPS_FETCH_CACHECONN
* Default (global) limit of cached connections used in libfetch.

View File

@ -134,6 +134,9 @@ out:
static bool
store_repo(struct xbps_handle *xhp, const char *repo)
{
if (xhp->flags & XBPS_FLAG_IGNORE_CONF_REPOS)
return false;
if (xhp->repositories == NULL)
xhp->repositories = xbps_array_create();

View File

@ -1,4 +1,5 @@
syntax("kyuafile", 1)
test_suite("xbps-query")
atf_test_program{name="ignore_repos_test"}
atf_test_program{name="remote_test"}

View File

@ -1,7 +1,7 @@
TOPDIR = ../../..
-include $(TOPDIR)/config.mk
TESTSHELL = remote_test
TESTSHELL = ignore_repos_test remote_test
TESTSSUBDIR = xbps/xbps-query
EXTRA_FILES = Kyuafile

View File

@ -0,0 +1,54 @@
#! /usr/bin/env atf-sh
# Test that xbps-query(8) -i works as expected
atf_test_case ignore_system
ignore_system_head() {
atf_set "descr" "xbps-query(8) -i: ignore repos defined in the system directory (sharedir/xbps.d)"
}
ignore_system_body() {
mkdir -p repo pkg_A/bin
touch pkg_A/bin/file
ln -s repo repo1
cd repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
rm -f *.xbps
cd ..
systemdir=$(xbps-uhelper getsystemdir)
mkdir -p root/${systemdir}
echo "repository=$PWD/repo1" > root/${systemdir}/myrepo.conf
out="$(xbps-query -C empty.conf --repository=$PWD/repo -i -L|wc -l)"
atf_check_equal "$out" 1
}
atf_test_case ignore_conf
ignore_conf_head() {
atf_set "descr" "xbps-query(8) -i: ignore repos defined in the configuration directory (xbps.d)"
}
ignore_conf_body() {
mkdir -p repo pkg_A/bin
touch pkg_A/bin/file
ln -s repo repo1
cd repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -d -a $PWD/*.xbps
atf_check_equal $? 0
rm -f *.xbps
cd ..
mkdir -p root/xbps.d
echo "repository=$PWD/repo1" > root/xbps.d/myrepo.conf
out="$(xbps-query -r root -C xbps.d --repository=$PWD/repo -i -L|wc -l)"
atf_check_equal "$out" 1
}
atf_init_test_cases() {
atf_add_test_case ignore_conf
atf_add_test_case ignore_system
}