xbps-repo: implement new target 'pkg-list' to list pkgs from target repo.

This commit is contained in:
Juan RP
2011-12-03 10:37:31 +01:00
parent cb2e941b48
commit 43d85c76b3
9 changed files with 75 additions and 23 deletions

View File

@@ -41,6 +41,7 @@ struct xferstat {
struct list_pkgver_cb {
pkg_state_t state;
size_t pkgver_len;
bool check_state;
};
/* from transaction.c */

View File

@@ -43,17 +43,18 @@ list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
(void)loop_done;
if (xbps_pkg_state_dictionary(obj, &curstate))
return EINVAL;
if (lpc->state == 0) {
/* Only list packages that are fully installed */
if (curstate != XBPS_PKG_STATE_INSTALLED)
return 0;
} else {
/* Only list packages with specified state */
if (curstate != lpc->state)
return 0;
if (lpc->check_state) {
if (xbps_pkg_state_dictionary(obj, &curstate))
return EINVAL;
if (lpc->state == 0) {
/* Only list packages that are fully installed */
if (curstate != XBPS_PKG_STATE_INSTALLED)
return 0;
} else {
/* Only list packages with specified state */
if (curstate != lpc->state)
return 0;
}
}
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);

View File

@@ -198,6 +198,7 @@ main(int argc, char **argv)
goto out;
}
lpc.check_state = true;
lpc.state = 0;
if (argv[1]) {
if (strcmp(argv[1], "installed") == 0)