xbps-query(8): -L now prints all repos, including non working repos (close #11).

This commit is contained in:
Juan RP 2013-07-26 11:42:52 +02:00
parent e0643acbb0
commit 20f2d10527
5 changed files with 34 additions and 17 deletions

10
NEWS
View File

@ -1,5 +1,15 @@
xbps-0.26 (???):
* xbps-query(8): make -L list all repositories in the configuration file, even
the non working ones and print -1 in them. Closes issue #11 from github.
$ xbps-query -L
-1 /mnt/foo
-1 /blah/foo
2619 /mnt/xbps_builder/host/binpkgs
16 /mnt/xbps_builder/host/binpkgs/nonfree
$
* xbps-query(8): fixed some memleaks in local and repository owned mode.
* xbps-query(8): fix regression in -R, also print repository string object.

View File

@ -156,8 +156,7 @@ repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done)
(void)arg;
(void)done;
printf("%s (%u packages)\n", repo->uri,
xbps_dictionary_count(repo->idx));
printf("%5zd %s\n", repo->idx ? (ssize_t)xbps_dictionary_count(repo->idx) : -1, repo->uri);
return 0;
}

View File

@ -1,4 +1,4 @@
.Dd March 4, 2013
.Dd July 26, 2013
.Os Void Linux
.Dt xbps-query 8
.Sh NAME
@ -101,7 +101,9 @@ and can be fully removed with
Package state is unknown.
.El
.It Fl L, Fl -list-repos
Lists registered and working repositories.
Lists repositories and the number of packages contained on them. If a repository is not
available the number of packages will be
.Sy -1 .
.It Fl m, Fl -list-manual-pkgs
Lists registered packages in the package database (pkgdb) that were installed
manually by the user (i.e not as dependency of any package).

View File

@ -84,7 +84,7 @@ xbps_repo_open(struct xbps_handle *xhp, const char *url)
archive_read_support_format_tar(repo->ar);
if (archive_read_open_filename(repo->ar, repofile, ARCHIVE_READ_BLOCKSIZE)) {
xbps_dbg_printf(xhp, "cannot open repository file %s: %s\n",
xbps_dbg_printf(xhp, "[repo] cannot open repository file %s: %s\n",
repofile, strerror(archive_errno(repo->ar)));
archive_read_free(repo->ar);
free(repo);
@ -105,9 +105,11 @@ xbps_repo_get_plist(struct xbps_repo *repo, const char *file)
int rv;
assert(repo);
assert(repo->ar);
assert(file);
if (repo->ar == NULL)
return NULL;
for (;;) {
rv = archive_read_next_header(repo->ar, &entry);
if (rv == ARCHIVE_EOF || rv == ARCHIVE_FATAL)
@ -137,6 +139,9 @@ xbps_repo_close(struct xbps_repo *repo)
{
assert(repo);
if (repo->ar == NULL)
return;
archive_read_free(repo->ar);
if (xbps_object_type(repo->idx) == XBPS_TYPE_DICTIONARY)
xbps_object_release(repo->idx);
@ -151,12 +156,15 @@ xbps_repo_get_virtualpkg(struct xbps_repo *repo, const char *pkg)
xbps_dictionary_t pkgd;
assert(repo);
assert(repo->ar);
assert(pkg);
if (repo->ar == NULL)
return NULL;
if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx);
if (repo->idx == NULL)
return NULL;
}
pkgd = xbps_find_virtualpkg_in_dict(repo->xhp, repo->idx, pkg);
if (pkgd) {
@ -173,12 +181,15 @@ xbps_repo_get_pkg(struct xbps_repo *repo, const char *pkg)
xbps_dictionary_t pkgd;
assert(repo);
assert(repo->ar);
assert(pkg);
if (repo->ar == NULL)
return NULL;
if (xbps_object_type(repo->idx) != XBPS_TYPE_DICTIONARY) {
repo->idx = xbps_repo_get_plist(repo, XBPS_PKGINDEX);
assert(repo->idx);
if (repo->idx == NULL)
return NULL;
}
pkgd = xbps_find_pkg_in_dict(repo->idx, pkg);
if (pkgd) {

View File

@ -68,15 +68,10 @@ xbps_rpool_init(struct xbps_handle *xhp)
assert(rp);
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
if ((rp->repo = xbps_repo_open(xhp, repouri)) == NULL) {
free(rp);
continue;
rp->repo = calloc(1, sizeof(struct xbps_repo));
assert(rp->repo);
}
rp->repo->idx = xbps_repo_get_plist(rp->repo, XBPS_PKGINDEX);
if (rp->repo->idx == NULL) {
xbps_repo_close(rp->repo);
free(rp);
continue;
}
rp->repo->uri = repouri;
rp->repo->xhp = xhp;
SIMPLEQ_INSERT_TAIL(&rpool_queue, rp, entries);