From 3dce6ab1edd64fa6b3901bde190581a929511339 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Wed, 21 Sep 2016 14:11:04 +0200 Subject: [PATCH] bin/xbps-query: add --list-repolock-pkgs --- bin/xbps-query/defs.h | 1 + bin/xbps-query/list.c | 18 ++++++++++++++++++ bin/xbps-query/main.c | 13 +++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/bin/xbps-query/defs.h b/bin/xbps-query/defs.h index 5d883948..99806cf3 100644 --- a/bin/xbps-query/defs.h +++ b/bin/xbps-query/defs.h @@ -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_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_repolock_pkgs(struct xbps_handle *, xbps_object_t, const char *, void *, bool *); int list_orphans(struct xbps_handle *); int list_pkgs_pkgdb(struct xbps_handle *); diff --git a/bin/xbps-query/list.c b/bin/xbps-query/list.c index 542b8700..ddda8be8 100644 --- a/bin/xbps-query/list.c +++ b/bin/xbps-query/list.c @@ -122,6 +122,24 @@ list_hold_pkgs(struct xbps_handle *xhp _unused, 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 list_orphans(struct xbps_handle *xhp) { diff --git a/bin/xbps-query/main.c b/bin/xbps-query/main.c index 3a28fa17..17ee498b 100644 --- a/bin/xbps-query/main.c +++ b/bin/xbps-query/main.c @@ -60,6 +60,7 @@ usage(bool fail) " -l --list-pkgs List installed packages\n" " -L --list-repos List registered repositories\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" " -O --list-orphans List package orphans\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-pkgs", no_argument, NULL, 'l' }, { "list-hold-pkgs", no_argument, NULL, 'H' }, + { "list-repolock-pkgs", no_argument, NULL, 3 }, { "memory-sync", no_argument, NULL, 'M' }, { "list-manual-pkgs", no_argument, NULL, 'm' }, { "list-orphans", no_argument, NULL, 'O' }, @@ -108,14 +110,14 @@ main(int argc, char **argv) struct xbps_handle xh; const char *pkg, *rootdir, *cachedir, *confdir, *props, *catfile; 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 show, pkg_search, regex, repo_mode, opmode, fulldeptree; rootdir = cachedir = confdir = props = pkg = catfile = NULL; flags = rv = c = 0; 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; repo_mode = opmode = false; @@ -208,6 +210,9 @@ main(int argc, char **argv) case 2: catfile = optarg; break; + case 3: + list_repolock = opmode = true; + break; case '?': usage(true); /* NOTREACHED */ @@ -254,6 +259,10 @@ main(int argc, char **argv) /* list on hold pkgs */ 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) { /* list manual pkgs */ rv = xbps_pkgdb_foreach_cb(&xh, list_manual_pkgs, NULL);