xbps-query: list unavailable repositories in -L mode
This commit is contained in:
parent
49bd3d62b5
commit
ce4fd6a63c
@ -23,6 +23,7 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
@ -178,8 +179,8 @@ list_pkgs_pkgdb(struct xbps_handle *xhp)
|
||||
return xbps_pkgdb_foreach_cb(xhp, list_pkgs_in_dict, &lpc);
|
||||
}
|
||||
|
||||
static int
|
||||
repo_list_uri_cb(struct xbps_repo *repo, void *arg UNUSED, bool *done UNUSED)
|
||||
static void
|
||||
repo_list_uri(struct xbps_repo *repo)
|
||||
{
|
||||
const char *signedby = NULL;
|
||||
uint16_t pubkeysize = 0;
|
||||
@ -204,19 +205,29 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg UNUSED, bool *done UNUSED)
|
||||
if (hexfp)
|
||||
free(hexfp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
repo_list_uri_err(const char *repouri)
|
||||
{
|
||||
printf("%5zd %s (RSA maybe-signed)\n", (ssize_t) -1, repouri);
|
||||
}
|
||||
|
||||
int
|
||||
repo_list(struct xbps_handle *xhp)
|
||||
{
|
||||
int rv;
|
||||
struct xbps_repo *repo = NULL;
|
||||
const char *repouri = NULL;
|
||||
|
||||
rv = xbps_rpool_foreach(xhp, repo_list_uri_cb, NULL);
|
||||
if (rv != 0 && rv != ENOTSUP) {
|
||||
fprintf(stderr, "Failed to initialize rpool: %s\n",
|
||||
strerror(rv));
|
||||
return rv;
|
||||
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {
|
||||
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
|
||||
repo = xbps_repo_open(xhp, repouri);
|
||||
if (repo) {
|
||||
repo_list_uri(repo);
|
||||
xbps_repo_close(repo);
|
||||
} else {
|
||||
repo_list_uri_err(repouri);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,5 +2,6 @@ syntax("kyuafile", 1)
|
||||
|
||||
test_suite("xbps-query")
|
||||
atf_test_program{name="ignore_repos_test"}
|
||||
atf_test_program{name="list_test"}
|
||||
atf_test_program{name="remote_test"}
|
||||
atf_test_program{name="query_test"}
|
||||
|
@ -1,7 +1,7 @@
|
||||
TOPDIR = ../../..
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
TESTSHELL = ignore_repos_test remote_test query_test
|
||||
TESTSHELL = ignore_repos_test list_test remote_test query_test
|
||||
TESTSSUBDIR = xbps/xbps-query
|
||||
EXTRA_FILES = Kyuafile
|
||||
|
||||
|
28
tests/xbps/xbps-query/list_test.sh
Normal file
28
tests/xbps/xbps-query/list_test.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#! /usr/bin/env atf-sh
|
||||
# Test that xbps-query(1) list modes work as expected
|
||||
|
||||
atf_test_case list_repos
|
||||
|
||||
list_repos_head() {
|
||||
atf_set "descr" "xbps-query(1) -L"
|
||||
}
|
||||
|
||||
list_repos_body() {
|
||||
mkdir -p some_repo pkg_A/bin
|
||||
touch pkg_A/bin/file
|
||||
cd some_repo
|
||||
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-create -A noarch -n baz-1.0_1 -s "baz pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -d -a $PWD/*.xbps
|
||||
atf_check_equal $? 0
|
||||
rm -f *.xbps
|
||||
cd ..
|
||||
output="$(xbps-query -C empty.conf -i --repository=some_repo --repository=vanished_repo -L | tr -d '\n')"
|
||||
atf_check_equal "$output" " 2 ${PWD}/some_repo (RSA unsigned) -1 vanished_repo (RSA maybe-signed)"
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case list_repos
|
||||
}
|
Loading…
Reference in New Issue
Block a user