diff --git a/NEWS b/NEWS index 2d2f77d9..6c70b8e8 100644 --- a/NEWS +++ b/NEWS @@ -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). diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 1921ade5..2eb75c72 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -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= 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; diff --git a/bin/xbps-install/xbps-install.8 b/bin/xbps-install/xbps-install.8 index 42cd7975..5035a12f 100644 --- a/bin/xbps-install/xbps-install.8 +++ b/bin/xbps-install/xbps-install.8 @@ -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 diff --git a/bin/xbps-query/main.c b/bin/xbps-query/main.c index 237eeb69..9f1b8b6d 100644 --- a/bin/xbps-query/main.c +++ b/bin/xbps-query/main.c @@ -42,6 +42,7 @@ usage(bool fail) " -c --cachedir 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; diff --git a/bin/xbps-query/xbps-query.8 b/bin/xbps-query/xbps-query.8 index 38d50e11..df21d609 100644 --- a/bin/xbps-query/xbps-query.8 +++ b/bin/xbps-query/xbps-query.8 @@ -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. diff --git a/include/xbps.h.in b/include/xbps.h.in index 95acdbe2..b7989393 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -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. diff --git a/lib/initend.c b/lib/initend.c index 67d83dcf..d8f670af 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -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(); diff --git a/tests/xbps/xbps-query/Kyuafile b/tests/xbps/xbps-query/Kyuafile index 5ef044ed..20bc1fdf 100644 --- a/tests/xbps/xbps-query/Kyuafile +++ b/tests/xbps/xbps-query/Kyuafile @@ -1,4 +1,5 @@ syntax("kyuafile", 1) test_suite("xbps-query") +atf_test_program{name="ignore_repos_test"} atf_test_program{name="remote_test"} diff --git a/tests/xbps/xbps-query/Makefile b/tests/xbps/xbps-query/Makefile index 0886a4b9..0d5271a5 100644 --- a/tests/xbps/xbps-query/Makefile +++ b/tests/xbps/xbps-query/Makefile @@ -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 diff --git a/tests/xbps/xbps-query/ignore_repos_test.sh b/tests/xbps/xbps-query/ignore_repos_test.sh new file mode 100644 index 00000000..8e8b9061 --- /dev/null +++ b/tests/xbps/xbps-query/ignore_repos_test.sh @@ -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 +}