bin/xbps-query: add --list-repolock-pkgs

This commit is contained in:
Michael Gehring 2016-09-21 14:11:04 +02:00
parent 7d06fb0e71
commit 3dce6ab1ed
3 changed files with 30 additions and 2 deletions

View File

@ -60,6 +60,7 @@ unsigned int find_longest_pkgver(struct xbps_handle *, xbps_object_t);
int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_pkgs_in_dict(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_manual_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_hold_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_hold_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_repolock_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *);
int list_orphans(struct xbps_handle *); int list_orphans(struct xbps_handle *);
int list_pkgs_pkgdb(struct xbps_handle *); int list_pkgs_pkgdb(struct xbps_handle *);

View File

@ -122,6 +122,24 @@ list_hold_pkgs(struct xbps_handle *xhp _unused,
return 0; return 0;
} }
int
list_repolock_pkgs(struct xbps_handle *xhp _unused,
xbps_object_t obj,
const char *key _unused,
void *arg _unused,
bool *loop_done _unused)
{
const char *pkgver;
if (xbps_dictionary_get(obj, "repolock")) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver);
}
return 0;
}
int int
list_orphans(struct xbps_handle *xhp) list_orphans(struct xbps_handle *xhp)
{ {

View File

@ -60,6 +60,7 @@ usage(bool fail)
" -l --list-pkgs List installed packages\n" " -l --list-pkgs List installed packages\n"
" -L --list-repos List registered repositories\n" " -L --list-repos List registered repositories\n"
" -H --list-hold-pkgs List packages on hold state\n" " -H --list-hold-pkgs List packages on hold state\n"
" --list-repolock-pkgs List repolocked packages\n"
" -m --list-manual-pkgs List packages installed explicitly\n" " -m --list-manual-pkgs List packages installed explicitly\n"
" -O --list-orphans List package orphans\n" " -O --list-orphans List package orphans\n"
" -o --ownedby FILE Search for package files by matching STRING or REGEX\n" " -o --ownedby FILE Search for package files by matching STRING or REGEX\n"
@ -86,6 +87,7 @@ main(int argc, char **argv)
{ "list-repos", no_argument, NULL, 'L' }, { "list-repos", no_argument, NULL, 'L' },
{ "list-pkgs", no_argument, NULL, 'l' }, { "list-pkgs", no_argument, NULL, 'l' },
{ "list-hold-pkgs", no_argument, NULL, 'H' }, { "list-hold-pkgs", no_argument, NULL, 'H' },
{ "list-repolock-pkgs", no_argument, NULL, 3 },
{ "memory-sync", no_argument, NULL, 'M' }, { "memory-sync", no_argument, NULL, 'M' },
{ "list-manual-pkgs", no_argument, NULL, 'm' }, { "list-manual-pkgs", no_argument, NULL, 'm' },
{ "list-orphans", no_argument, NULL, 'O' }, { "list-orphans", no_argument, NULL, 'O' },
@ -108,14 +110,14 @@ main(int argc, char **argv)
struct xbps_handle xh; struct xbps_handle xh;
const char *pkg, *rootdir, *cachedir, *confdir, *props, *catfile; const char *pkg, *rootdir, *cachedir, *confdir, *props, *catfile;
int c, flags, rv; int c, flags, rv;
bool list_pkgs, list_repos, orphans, own; bool list_pkgs, list_repos, orphans, own, list_repolock;
bool list_manual, list_hold, show_prop, show_files, show_deps, show_rdeps; bool list_manual, list_hold, show_prop, show_files, show_deps, show_rdeps;
bool show, pkg_search, regex, repo_mode, opmode, fulldeptree; bool show, pkg_search, regex, repo_mode, opmode, fulldeptree;
rootdir = cachedir = confdir = props = pkg = catfile = NULL; rootdir = cachedir = confdir = props = pkg = catfile = NULL;
flags = rv = c = 0; flags = rv = c = 0;
list_pkgs = list_repos = list_hold = orphans = pkg_search = own = false; list_pkgs = list_repos = list_hold = orphans = pkg_search = own = false;
list_manual = show_prop = show_files = false; list_manual = list_repolock = show_prop = show_files = false;
regex = show = show_deps = show_rdeps = fulldeptree = false; regex = show = show_deps = show_rdeps = fulldeptree = false;
repo_mode = opmode = false; repo_mode = opmode = false;
@ -208,6 +210,9 @@ main(int argc, char **argv)
case 2: case 2:
catfile = optarg; catfile = optarg;
break; break;
case 3:
list_repolock = opmode = true;
break;
case '?': case '?':
usage(true); usage(true);
/* NOTREACHED */ /* NOTREACHED */
@ -254,6 +259,10 @@ main(int argc, char **argv)
/* list on hold pkgs */ /* list on hold pkgs */
rv = xbps_pkgdb_foreach_cb(&xh, list_hold_pkgs, NULL); rv = xbps_pkgdb_foreach_cb(&xh, list_hold_pkgs, NULL);
} else if (list_repolock) {
/* list repolocked packages */
rv = xbps_pkgdb_foreach_cb(&xh, list_repolock_pkgs, NULL);
} else if (list_manual) { } else if (list_manual) {
/* list manual pkgs */ /* list manual pkgs */
rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL); rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL);