From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AD56013835A for ; Fri, 14 Aug 2020 10:09:44 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CA231E081E; Fri, 14 Aug 2020 10:09:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 98CFDE081B for ; Fri, 14 Aug 2020 10:09:43 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 48EE734F329 for ; Fri, 14 Aug 2020 10:09:42 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DFD5C313 for ; Fri, 14 Aug 2020 10:09:40 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1597399526.72830c415c6c2050ecf7d90e8c739d2764bc9e09.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: man/include/, man/, / X-VCS-Repository: proj/portage-utils X-VCS-Files: man/include/qlist.optdesc.yaml man/qlist.1 qlist.c qmerge.c X-VCS-Directories: / man/ man/include/ X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 72830c415c6c2050ecf7d90e8c739d2764bc9e09 X-VCS-Branch: master Date: Fri, 14 Aug 2020 10:09:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 40c1a8ed-9e1a-45e8-b9a1-b046e3945e09 X-Archives-Hash: 529b06278f00bbd25bfba00263151585 commit: 72830c415c6c2050ecf7d90e8c739d2764bc9e09 Author: Fabian Groffen gentoo org> AuthorDate: Fri Aug 14 10:05:26 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Aug 14 10:05:26 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=72830c41 qlist: add -t (tree) and -m (masks) arguments -t allow traversing the configured trees -m apply masks from profiles E.g. useful to find the latest available non-masked version of a package: % qlist -Itvm mypackage Signed-off-by: Fabian Groffen gentoo.org> man/include/qlist.optdesc.yaml | 6 ++++ man/qlist.1 | 10 +++++- qlist.c | 70 +++++++++++++++++++++++++++++++++++------- qmerge.c | 5 +-- 4 files changed, 77 insertions(+), 14 deletions(-) diff --git a/man/include/qlist.optdesc.yaml b/man/include/qlist.optdesc.yaml index 30d8446..1145fa9 100644 --- a/man/include/qlist.optdesc.yaml +++ b/man/include/qlist.optdesc.yaml @@ -3,6 +3,8 @@ installed: | name if the package is currently installed. binpkgs: | Operate on binary packages instead of installed packges. +tree: | + Used with \fB\-I\fR to list packages available in the tree. umap: | List USE-flags enabled when the package was installed. This flag implies \fB\-I\fR. @@ -16,6 +18,10 @@ columns: | Like \fB\-Iv\fR, but package name and version are separated by a space for easy consumption by e.g.\ shell scripts which can read space-separated columns. +masks: | + Filter matches for packages that are masked via the profiles. In + particular useful in combination with \fB\-Itv\fR to find the latest + available version of a given package. verbose: | When used with \fB\-I\fR, print the package version next to name. When listing the package contents, \fB\-v\fR displays symlinks with diff --git a/man/qlist.1 b/man/qlist.1 index 676ee96..db4be0d 100644 --- a/man/qlist.1 +++ b/man/qlist.1 @@ -1,5 +1,5 @@ .\" generated by mkman.py, please do NOT edit! -.TH qlist "1" "Nov 2019" "Gentoo Foundation" "qlist" +.TH qlist "1" "Aug 2020" "Gentoo Foundation" "qlist" .SH NAME qlist \- list files owned by pkgname .SH SYNOPSIS @@ -22,6 +22,9 @@ name if the package is currently installed. \fB\-k\fR, \fB\-\-binpkgs\fR Operate on binary packages instead of installed packges. .TP +\fB\-t\fR, \fB\-\-tree\fR +Used with \fB\-I\fR to list packages available in the tree. +.TP \fB\-S\fR, \fB\-\-slots\fR Display installed packages with slots (use twice for subslots). .TP @@ -38,6 +41,11 @@ Like \fB\-Iv\fR, but package name and version are separated by a space for easy consumption by e.g.\ shell scripts which can read space-separated columns. .TP +\fB\-m\fR, \fB\-\-masks\fR +Filter matches for packages that are masked via the profiles. In +particular useful in combination with \fB\-Itv\fR to find the latest +available version of a given package. +.TP \fB\-\-showdebug\fR Show /usr/lib/debug and /usr/src/debug files. .TP diff --git a/qlist.c b/qlist.c index cd60083..3652c0a 100644 --- a/qlist.c +++ b/qlist.c @@ -22,14 +22,16 @@ #include "xpak.h" #include "xregex.h" -#define QLIST_FLAGS "IkSRUcDedosF:" COMMON_FLAGS +#define QLIST_FLAGS "IktSRUcmDedosF:" COMMON_FLAGS static struct option const qlist_long_opts[] = { {"installed", no_argument, NULL, 'I'}, {"binpkgs", no_argument, NULL, 'k'}, + {"tree", no_argument, NULL, 't'}, {"slots", no_argument, NULL, 'S'}, {"repo", no_argument, NULL, 'R'}, {"umap", no_argument, NULL, 'U'}, {"columns", no_argument, NULL, 'c'}, + {"masks", no_argument, NULL, 'm'}, {"showdebug", no_argument, NULL, 128}, {"exact", no_argument, NULL, 'e'}, {"dir", no_argument, NULL, 'd'}, @@ -42,10 +44,12 @@ static struct option const qlist_long_opts[] = { static const char * const qlist_opts_help[] = { "Just show installed package names", "Use binpkgs instead of installed packages", + "Use available packages in the tree instead of installed", "Display installed packages with slots (use twice for subslots)", "Display installed packages with repository", "Display installed packages with flags used", "Display column view", + "Exclude matches masked by profiles", "Show /usr/lib/debug and /usr/src/debug files", "Exact match (only CAT/PN or PN without PV)", "Only show directories", @@ -175,13 +179,15 @@ qlist_match( tree_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, - bool exact); + bool exact, + bool applymasks); bool qlist_match( tree_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, - bool exact) + bool exact, + bool applymasks) { char buf[_Q_PATH_MAX]; char uslot[32]; @@ -255,6 +261,30 @@ qlist_match( return false; } + if (applymasks) { + DECLARE_ARRAY(masks); + depend_atom *matom; + char *mask; + size_t n; + bool match = false; + + array_set(package_masks, masks); + + array_for_each(masks, n, mask) { + if ((matom = atom_explode(mask)) == NULL) + continue; + match = atom_compare(atom, matom) == EQUAL; + atom_implode(matom); + if (match) + break; + } + + xarrayfree_int(masks); + + if (match) + return false; + } + if (exact) { int i; @@ -311,10 +341,12 @@ struct qlist_opt_state { bool exact:1; bool all:1; bool do_binpkgs:1; + bool do_tree:1; bool just_pkgname:1; bool show_dir:1; bool show_obj:1; bool show_sym:1; + bool apply_masks:1; bool need_full_atom:1; bool show_umap:1; bool show_dbg:1; @@ -337,7 +369,8 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv) if (!state->all) { for (i = optind; i < state->argc; ++i) if (qlist_match(pkg_ctx, state->argv[i], - &state->atoms[i - optind], state->exact)) + &state->atoms[i - optind], state->exact, + state->apply_masks)) break; if (i == state->argc) return 0; @@ -415,10 +448,12 @@ int qlist_main(int argc, char **argv) .exact = false, .all = false, .do_binpkgs = false, + .do_tree = false, .just_pkgname = false, .show_dir = false, .show_obj = false, .show_sym = false, + .apply_masks = false, .need_full_atom = false, .show_umap = false, .show_dbg = false, @@ -431,6 +466,7 @@ int qlist_main(int argc, char **argv) COMMON_GETOPTS_CASES(qlist) case 'I': state.just_pkgname = true; break; case 'k': state.do_binpkgs = true; break; + case 't': state.do_tree = true; break; case 'S': state.just_pkgname = true; show_slots++; break; case 'R': state.just_pkgname = show_repo = true; break; case 'U': state.just_pkgname = state.show_umap = true; break; @@ -440,6 +476,7 @@ int qlist_main(int argc, char **argv) case 'o': state.show_obj = true; break; case 's': state.show_sym = true; break; case 'c': do_columns = true; break; + case 'm': state.apply_masks = true; break; case 'F': state.fmt = optarg; break; } } @@ -486,13 +523,24 @@ int qlist_main(int argc, char **argv) state.buf = xmalloc(state.buflen); state.atoms = xcalloc(argc - optind, sizeof(*state.atoms)); ret = 1; - if (state.do_binpkgs) - vdb = tree_open_binpkg(portroot, pkgdir); - else - vdb = tree_open_vdb(portroot, portvdb); - if (vdb != NULL) { - ret = tree_foreach_pkg_sorted(vdb, qlist_cb, &state, NULL); - tree_close(vdb); + if (state.do_tree) { + size_t n; + const char *overlay; + + array_for_each(overlays, n, overlay) { + vdb = tree_open(portroot, overlay); + ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, &state, NULL); + tree_close(vdb); + } + } else { + if (state.do_binpkgs) + vdb = tree_open_binpkg(portroot, pkgdir); + else + vdb = tree_open_vdb(portroot, portvdb); + if (vdb != NULL) { + ret = tree_foreach_pkg_sorted(vdb, qlist_cb, &state, NULL); + tree_close(vdb); + } } free(state.buf); for (i = optind; i < state.argc; ++i) diff --git a/qmerge.c b/qmerge.c index f246e57..d407cd7 100644 --- a/qmerge.c +++ b/qmerge.c @@ -1781,7 +1781,8 @@ extern bool qlist_match( tree_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, - bool exact); + bool exact, + bool applymasks); static int qmerge_unmerge_cb(tree_pkg_ctx *pkg_ctx, void *priv) @@ -1798,7 +1799,7 @@ qmerge_unmerge_cb(tree_pkg_ctx *pkg_ctx, void *priv) (void)list_set(priv, &todo); for (p = todo; *p != NULL; p++) { - if (qlist_match(pkg_ctx, *p, NULL, true)) + if (qlist_match(pkg_ctx, *p, NULL, true, false)) pkg_unmerge(pkg_ctx, NULL, cp_argc, cp_argv, cpm_argc, cpm_argv); }